Fix db status, remove db ship
This commit is contained in:
parent
deb50b4abc
commit
e214b9f885
2 changed files with 53 additions and 45 deletions
|
@ -52,12 +52,15 @@ async def parse_db_status() -> dict:
|
||||||
cells = row.find_all("td")
|
cells = row.find_all("td")
|
||||||
for cell in cells:
|
for cell in cells:
|
||||||
if "column--comment" in cell["class"]:
|
if "column--comment" in cell["class"]:
|
||||||
text = cell.find("span").get_text()
|
status_title, detail, *_ = [
|
||||||
|
x.get_text() for x in cell.find_all("div")
|
||||||
|
]
|
||||||
|
text = status_title
|
||||||
if cell != "Unavailable":
|
if cell != "Unavailable":
|
||||||
text += ": " + cell.find("div").get_text()
|
text += ": " + detail
|
||||||
cell = text.strip()
|
cell = text.strip()
|
||||||
elif "column--status" in cell["class"]:
|
elif "column--status" in cell["class"]:
|
||||||
info = cell.find("span")["class"]
|
info = cell.find("div")["class"]
|
||||||
if any("green" in x for x in info):
|
if any("green" in x for x in info):
|
||||||
cell = CUSTOM_EMOJIS.get("ico_clock_green", "🟢")
|
cell = CUSTOM_EMOJIS.get("ico_clock_green", "🟢")
|
||||||
elif any("yellow" in x for x in info):
|
elif any("yellow" in x for x in info):
|
||||||
|
@ -100,37 +103,42 @@ class DbrandCog(Extension):
|
||||||
sub_cmd_name="status", sub_cmd_description="Get dbrand operational status"
|
sub_cmd_name="status", sub_cmd_description="Get dbrand operational status"
|
||||||
)
|
)
|
||||||
async def _status(self, ctx: InteractionContext) -> None:
|
async def _status(self, ctx: InteractionContext) -> None:
|
||||||
status = self.cache.get("status")
|
try:
|
||||||
if not status or status["cache_expiry"] <= datetime.now(tz=timezone.utc):
|
status = self.cache.get("status")
|
||||||
status = await parse_db_status()
|
if not status or status["cache_expiry"] <= datetime.now(tz=timezone.utc):
|
||||||
status["cache_expiry"] = datetime.now(tz=timezone.utc) + timedelta(hours=2)
|
status = await parse_db_status()
|
||||||
self.cache["status"] = status
|
status["cache_expiry"] = datetime.now(tz=timezone.utc) + timedelta(
|
||||||
status = status.get("operations")
|
hours=2
|
||||||
emojies = [x["Status"] for x in status]
|
)
|
||||||
fields = [
|
self.cache["status"] = status
|
||||||
EmbedField(name=f'{x["Status"]} {x["Service"]}', value=x["Detail"])
|
status = status.get("operations")
|
||||||
for x in status
|
emojies = [x["Status"] for x in status]
|
||||||
]
|
fields = [
|
||||||
color = "#FBBD1E"
|
EmbedField(name=f'{x["Status"]} {x["Service"]}', value=x["Detail"])
|
||||||
if all("green" in x for x in emojies):
|
for x in status
|
||||||
color = "#38F657"
|
]
|
||||||
elif all("red" in x for x in emojies):
|
color = "#FBBD1E"
|
||||||
color = "#F12D20"
|
if all("green" in x for x in emojies):
|
||||||
embed = build_embed(
|
color = "#38F657"
|
||||||
title="Operational Status",
|
elif all("red" in x for x in emojies):
|
||||||
description="Current dbrand operational status.\n[View online](https://dbrand.com/status)",
|
color = "#F12D20"
|
||||||
fields=fields,
|
embed = build_embed(
|
||||||
url="https://dbrand.com/status",
|
title="Operational Status",
|
||||||
color=color,
|
description="Current dbrand operational status.\n[View online](https://dbrand.com/status)",
|
||||||
)
|
fields=fields,
|
||||||
|
url="https://dbrand.com/status",
|
||||||
|
color=color,
|
||||||
|
)
|
||||||
|
|
||||||
embed.set_thumbnail(url="https://dev.zevaryx.com/db_logo.png")
|
embed.set_thumbnail(url="https://dev.zevaryx.com/db_logo.png")
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
text="dbrand.com",
|
text="dbrand.com",
|
||||||
icon_url="https://dev.zevaryx.com/db_logo.png",
|
icon_url="https://dev.zevaryx.com/db_logo.png",
|
||||||
)
|
)
|
||||||
|
|
||||||
await ctx.send(embeds=embed)
|
await ctx.send(embeds=embed)
|
||||||
|
except:
|
||||||
|
self.bot.logger.error("Encountered error", exc_info=True)
|
||||||
|
|
||||||
async def _db_support_cmd(self, ctx: InteractionContext) -> None:
|
async def _db_support_cmd(self, ctx: InteractionContext) -> None:
|
||||||
status = self.cache.get("status")
|
status = self.cache.get("status")
|
||||||
|
@ -182,7 +190,7 @@ class DbrandCog(Extension):
|
||||||
async def _support(self, ctx: InteractionContext) -> None:
|
async def _support(self, ctx: InteractionContext) -> None:
|
||||||
return await self._db_support_cmd(ctx)
|
return await self._db_support_cmd(ctx)
|
||||||
|
|
||||||
# @db.subcommand(sub_cmd_name="gripcheck", sub_cmd_description="Watch a dbrand grip get thrown")
|
# @db.subcommand(sub_cmd_name="gripcheck", sub_cmd_description="Watch a dbrand grip get thrown")
|
||||||
async def _gripcheck(self, ctx: InteractionContext) -> None:
|
async def _gripcheck(self, ctx: InteractionContext) -> None:
|
||||||
video_url = "https://cdn.discordapp.com/attachments/599068193339736096/890679742263623751/video0.mov"
|
video_url = "https://cdn.discordapp.com/attachments/599068193339736096/890679742263623751/video0.mov"
|
||||||
image_url = "https://cdn.discordapp.com/attachments/599068193339736096/890680198306095104/image0.jpg"
|
image_url = "https://cdn.discordapp.com/attachments/599068193339736096/890680198306095104/image0.jpg"
|
||||||
|
@ -219,17 +227,17 @@ class DbrandCog(Extension):
|
||||||
)
|
)
|
||||||
await ctx.send(embeds=embed)
|
await ctx.send(embeds=embed)
|
||||||
|
|
||||||
@db.subcommand(
|
# @db.subcommand(
|
||||||
sub_cmd_name="ship",
|
# sub_cmd_name="ship",
|
||||||
sub_cmd_description="Get shipping information for your country",
|
# sub_cmd_description="Get shipping information for your country",
|
||||||
)
|
# )
|
||||||
@slash_option(
|
# @slash_option(
|
||||||
name="search",
|
# name="search",
|
||||||
description="Country search query (2 character code, country name, flag emoji)",
|
# description="Country search query (2 character code, country name, flag emoji)",
|
||||||
opt_type=OptionType.STRING,
|
# opt_type=OptionType.STRING,
|
||||||
required=True,
|
# required=True,
|
||||||
)
|
# )
|
||||||
@cooldown(bucket=Buckets.USER, rate=1, interval=2)
|
# @cooldown(bucket=Buckets.USER, rate=1, interval=2)
|
||||||
async def _shipping(self, ctx: InteractionContext, search: str) -> None:
|
async def _shipping(self, ctx: InteractionContext, search: str) -> None:
|
||||||
if not re.match(r"^[A-Z- ]+$", search, re.IGNORECASE):
|
if not re.match(r"^[A-Z- ]+$", search, re.IGNORECASE):
|
||||||
if re.match(
|
if re.match(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "jarvis"
|
name = "jarvis"
|
||||||
version = "2.5.1"
|
version = "2.5.2"
|
||||||
description = "JARVIS admin bot"
|
description = "JARVIS admin bot"
|
||||||
authors = ["Zevaryx <zevaryx@gmail.com>"]
|
authors = ["Zevaryx <zevaryx@gmail.com>"]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue