Skip to content

Commit

Permalink
fix emojis in tracker status
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapppa committed Apr 27, 2024
1 parent 1bc27a4 commit ea17f85
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions chiya/utils/trackerstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ async def do_refresh(self, session: aiohttp.ClientSession) -> None:
def get_embed_color(self, embed: discord.Embed):
status = list(set([field.value for field in embed.fields]))
if len(status) == 1:
if status[0] == "<:status_online:596576749790429200> Online":
if status[0] == "🟒 Online":
return discord.Color.green()
elif status[0] == "<:status_dnd:596576774364856321> Unstable":
elif status[0] == "🟠 Unstable":
return discord.Color.orange()
elif status[0] == "<:status_offline:596576752013279242> Offline":
elif status[0] == "πŸ”΄ Offline":
return discord.Color.red()
else:
if "<:status_online:596576749790429200> Online" not in status:
if "🟒 Online" not in status:
return discord.Color.red()
else:
return discord.Color.orange()
Expand Down Expand Up @@ -85,11 +85,11 @@ def normalize_value(self, value):
"""
match value:
case "1":
return "<:status_online:596576749790429200> Online"
return "🟒 Online"
case "2":
return "<:status_dnd:596576774364856321> Unstable"
return "🟠 Unstable"
case "0":
return "<:status_offline:596576752013279242> Offline"
return "πŸ”΄ Offline"


class TrackerStatusAB(TrackerStatus):
Expand All @@ -110,7 +110,7 @@ def get_status_embed(self, ctx: discord.Interaction = None) -> discord.Embed:
self.do_refresh()

if not self.cache_data.get("status", False):
embed.set_footer("<:status_offline:596576752013279242> API Failed")
embed.set_footer("πŸ”΄ API Failed")

for key, value in self.cache_data.get("status", {}).items():
embed.add_field(name=key, value=self.normalize_value(value.get("status")), inline=True)
Expand All @@ -125,11 +125,11 @@ def normalize_value(self, value):
"""
match value:
case 1:
return "<:status_online:596576749790429200> Online"
return "🟒 Online"
case 2:
return "<:status_dnd:596576774364856321> Unstable"
return "🟠 Unstable"
case 0:
return "<:status_offline:596576752013279242> Offline"
return "πŸ”΄ Offline"


class TrackerStatusUptimeRobot(TrackerStatus):
Expand Down Expand Up @@ -163,16 +163,13 @@ def normalize_value(self, value: dict):
Converts API data values into user-friendly text with status availability icon.
"""
if value.get("label") == "success":
return "<:status_online:596576749790429200> Online"
return "🟒 Online"
ratio = float(value.get("ratio", "0"))
if float(value.get("ratio")) > 95:
return "<:status_dnd:596576774364856321> Unstable"
return "🟠 Unstable"
elif ratio > 0:
return "<:status_offline:596576752013279242> Offline"

return "<:status_offline:596576752013279242> Unknown"


return "πŸ”΄ Offline"
return "πŸ”΄ Unknown"
class TrackerStatusMAM(TrackerStatusUptimeRobot):
def __init__(self) -> None:
super().__init__("MAM", "https://status.myanonamouse.net/api/getMonitorList/vl59BTEJX")

0 comments on commit ea17f85

Please sign in to comment.