Fix db status, remove db ship

This commit is contained in:
Zeva Rose 2023-11-10 20:05:00 -07:00
parent deb50b4abc
commit e214b9f885
2 changed files with 53 additions and 45 deletions

View file

@ -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,10 +103,13 @@ class DbrandCog(Extension):
sub_cmd_name="status", sub_cmd_description="Get dbrand operational status"
)
async def _status(self, ctx: InteractionContext) -> None:
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)
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]
@ -131,6 +137,8 @@ class DbrandCog(Extension):
)
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(

View file

@ -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>"]