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")
|
||||
for cell in cells:
|
||||
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":
|
||||
text += ": " + cell.find("div").get_text()
|
||||
text += ": " + detail
|
||||
cell = text.strip()
|
||||
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):
|
||||
cell = CUSTOM_EMOJIS.get("ico_clock_green", "🟢")
|
||||
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"
|
||||
)
|
||||
async def _status(self, ctx: InteractionContext) -> None:
|
||||
status = self.cache.get("status")
|
||||
if not status or status["cache_expiry"] <= datetime.now(tz=timezone.utc):
|
||||
status = await parse_db_status()
|
||||
status["cache_expiry"] = datetime.now(tz=timezone.utc) + timedelta(hours=2)
|
||||
self.cache["status"] = status
|
||||
status = status.get("operations")
|
||||
emojies = [x["Status"] for x in status]
|
||||
fields = [
|
||||
EmbedField(name=f'{x["Status"]} {x["Service"]}', value=x["Detail"])
|
||||
for x in status
|
||||
]
|
||||
color = "#FBBD1E"
|
||||
if all("green" in x for x in emojies):
|
||||
color = "#38F657"
|
||||
elif all("red" in x for x in emojies):
|
||||
color = "#F12D20"
|
||||
embed = build_embed(
|
||||
title="Operational Status",
|
||||
description="Current dbrand operational status.\n[View online](https://dbrand.com/status)",
|
||||
fields=fields,
|
||||
url="https://dbrand.com/status",
|
||||
color=color,
|
||||
)
|
||||
try:
|
||||
status = self.cache.get("status")
|
||||
if not status or status["cache_expiry"] <= datetime.now(tz=timezone.utc):
|
||||
status = await parse_db_status()
|
||||
status["cache_expiry"] = datetime.now(tz=timezone.utc) + timedelta(
|
||||
hours=2
|
||||
)
|
||||
self.cache["status"] = status
|
||||
status = status.get("operations")
|
||||
emojies = [x["Status"] for x in status]
|
||||
fields = [
|
||||
EmbedField(name=f'{x["Status"]} {x["Service"]}', value=x["Detail"])
|
||||
for x in status
|
||||
]
|
||||
color = "#FBBD1E"
|
||||
if all("green" in x for x in emojies):
|
||||
color = "#38F657"
|
||||
elif all("red" in x for x in emojies):
|
||||
color = "#F12D20"
|
||||
embed = build_embed(
|
||||
title="Operational Status",
|
||||
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_footer(
|
||||
text="dbrand.com",
|
||||
icon_url="https://dev.zevaryx.com/db_logo.png",
|
||||
)
|
||||
embed.set_thumbnail(url="https://dev.zevaryx.com/db_logo.png")
|
||||
embed.set_footer(
|
||||
text="dbrand.com",
|
||||
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:
|
||||
status = self.cache.get("status")
|
||||
|
@ -182,7 +190,7 @@ class DbrandCog(Extension):
|
|||
async def _support(self, ctx: InteractionContext) -> None:
|
||||
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:
|
||||
video_url = "https://cdn.discordapp.com/attachments/599068193339736096/890679742263623751/video0.mov"
|
||||
image_url = "https://cdn.discordapp.com/attachments/599068193339736096/890680198306095104/image0.jpg"
|
||||
|
@ -219,17 +227,17 @@ class DbrandCog(Extension):
|
|||
)
|
||||
await ctx.send(embeds=embed)
|
||||
|
||||
@db.subcommand(
|
||||
sub_cmd_name="ship",
|
||||
sub_cmd_description="Get shipping information for your country",
|
||||
)
|
||||
@slash_option(
|
||||
name="search",
|
||||
description="Country search query (2 character code, country name, flag emoji)",
|
||||
opt_type=OptionType.STRING,
|
||||
required=True,
|
||||
)
|
||||
@cooldown(bucket=Buckets.USER, rate=1, interval=2)
|
||||
# @db.subcommand(
|
||||
# sub_cmd_name="ship",
|
||||
# sub_cmd_description="Get shipping information for your country",
|
||||
# )
|
||||
# @slash_option(
|
||||
# name="search",
|
||||
# description="Country search query (2 character code, country name, flag emoji)",
|
||||
# opt_type=OptionType.STRING,
|
||||
# required=True,
|
||||
# )
|
||||
# @cooldown(bucket=Buckets.USER, rate=1, interval=2)
|
||||
async def _shipping(self, ctx: InteractionContext, search: str) -> None:
|
||||
if not re.match(r"^[A-Z- ]+$", search, re.IGNORECASE):
|
||||
if re.match(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "jarvis"
|
||||
version = "2.5.1"
|
||||
version = "2.5.2"
|
||||
description = "JARVIS admin bot"
|
||||
authors = ["Zevaryx <zevaryx@gmail.com>"]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue