2 Commits 384c78b093 ... c58273362c

Autor SHA1 Mensagem Data
  Kirk Trombley c58273362c Westie+Westier 7 meses atrás
  Kirk Trombley cd4aff06b3 Improve alias logic and clean up selfie variants 7 meses atrás

+ 15 - 20
commands/commands/__init__.py

@@ -1,8 +1,19 @@
-import pkgutil
-
 from rollbot import get_command_config, CommandConfiguration
 
-import commands.curse, commands.hangguy, commands.omen, commands.plex, commands.poll, commands.querying, commands.roll, commands.rollcoin, commands.session, commands.seychelles, commands.simple, commands.tarot, commands.teamspeak, commands.yell
+import commands.curse
+import commands.hangguy
+import commands.omen
+import commands.plex
+import commands.poll
+import commands.querying
+import commands.roll
+import commands.rollcoin
+import commands.session
+import commands.seychelles
+import commands.simple
+import commands.tarot
+import commands.teamspeak
+import commands.yell
 
 __all__ = ["config"]
 config = get_command_config().extend(
@@ -24,22 +35,6 @@ config = get_command_config().extend(
             "groupme": "All your friends are right here, Neil!",
             "ta": "Ivan is a TA!",
         },
-        aliases={
-            "speemteek": "speamteek",
-            "speemteak": "speamteek",
-            "speamteak": "speamteek",
-            "interpret": "inspire",
-            "horoscope": "inspire",
-            "lomg": "bump",
-            "mute": "bump",
-            "fs": "f",
-            "hg": "hangguy",
-            "cookie": "fortune",
-            "wl": "watchlist",
-            "choose": "choice",
-            "omens": "omen",
-            "pollhearts": "poll",
-            "bubble": "bubblewrap",
-        },
+        aliases={"lomg": "bump", "mute": "bump"},
     )
 )

+ 3 - 2
commands/commands/hangguy.py

@@ -4,7 +4,7 @@ from uuid import uuid4
 import re
 
 from rollbot import as_command, initialize_data, RollbotFailure, Response, Command
-from rollbot.injection import Data, Config, Subcommand, Lazy, Args, Origin, SenderName
+from rollbot.injection import Data, Config, Origin, SenderName
 
 
 KEY = "HANG_GUY_SINGLETON"
@@ -181,6 +181,7 @@ class DeadGuy:
         )
 
 
+@as_command("hg")
 @as_command
 async def hangguy(
     cmd: Command,
@@ -242,7 +243,7 @@ async def hangguy(
                 dead = DeadGuy.from_guy(game)
                 game.reset_guy()
                 await dead_store.save(
-                    f"{uuid4().hex}-{datetime.now().isoformat()}", dead_guy
+                    f"{uuid4().hex}-{datetime.now().isoformat()}", dead
                 )
                 txt += f"\noh god oh fuck, the guy is dead!\nYou failed to guess {game.puzzle}\nThe guy has been buried."
 

+ 1 - 0
commands/commands/omen.py

@@ -8,6 +8,7 @@ from commands.simple import inquire
 
 from rollbot.types import Attachment
 
+@as_command("omens")
 @as_command
 async def omen(req: Request, logger: Logger):
     inquiry = inquire()

+ 1 - 0
commands/commands/poll.py

@@ -11,6 +11,7 @@ HEARTS = ["❤️", "💚", "💛", "💙", "🤎", "💜", "🧡"]
 TITLE_PAT = re.compile(r"\s*[tT]itle:\s*(.+)")
 
 
+@as_command("pollhearts")
 @as_command
 def poll(origin: Origin, name: SenderName, args: Args, arg_list: ArgList, cmd: Command):
     if origin != "DISCORD":

+ 23 - 46
commands/commands/querying.py

@@ -1,4 +1,3 @@
-from cmath import log
 from logging import Logger
 import random
 import asyncio
@@ -10,8 +9,11 @@ from commands.teamspeak import teamspeak
 
 from rollbot import as_command, RollbotFailure, Attachment
 from rollbot.injection import Request, Args, Arg, Config, Reply
+from rollbot.types import Command
 
 
+@as_command("interpret")
+@as_command("horoscope")
 @as_command
 async def inspire(req: Request, logger: Logger):
     """
@@ -157,57 +159,32 @@ async def riddle(args: Args, req: Request, logger: Logger, sleep: Config("riddle
     yield "\n\n".join(("Here's the riddle answer from before!", riddle, answer))
 
 
-@as_command
-async def selfie(req: Request, logger: Logger):
-    try:
-        async with req.get(
-            "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/ne/GEOCOLOR/latest.jpg"
-        ) as res:
-            res.raise_for_status()
-            return Attachment("image", await res.read())
-    except:
-        logger.exception("Failed to call GOES16")
-        RollbotFailure.SERVICE_DOWN.raise_exc(detail="Failed to call GOES16")
-
-
-@as_command
-async def southie(req: Request, logger: Logger):
-    try:
-        async with req.get(
-            "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/se/GEOCOLOR/latest.jpg"
-        ) as res:
-            res.raise_for_status()
-            return Attachment("image", await res.read())
-    except:
-        logger.exception("Failed to call GOES16")
-        RollbotFailure.SERVICE_DOWN.raise_exc(detail="Failed to call GOES16")
-
-
-
-@as_command
-async def southier(req: Request, logger: Logger):
-    try:
-        async with req.get(
-            "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/gm/GEOCOLOR/latest.jpg"
-        ) as res:
-            res.raise_for_status()
-            return Attachment("image", await res.read())
-    except:
-        logger.exception("Failed to call GOES16")
-        RollbotFailure.SERVICE_DOWN.raise_exc(detail="Failed to call GOES16")
-
-
-@as_command
-async def seaboardie(req: Request, logger: Logger):
+SELFIE_SECTORS = {
+    "selfie": "ne", # Northeast
+    "southie": "se", # Southeast
+    "southier": "gm", # Gulf of Mexico
+    "seaboardie": "eus", # Eastern US
+    "westie": "cgl", # Central/Great Lakes
+    "westier": "psw", # Pacific Southwest
+}
+
+@as_command("westie")
+@as_command("westier")
+@as_command("southie")
+@as_command("southier")
+@as_command("seaboardie")
+@as_command    
+async def selfie(req: Request, logger: Logger, cmd: Command):
+    sector = SELFIE_SECTORS.get(cmd.raw_name.casefold(), "ne")
     try:
         async with req.get(
-            "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/eus/GEOCOLOR/latest.jpg"
+            f"https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/{sector}/GEOCOLOR/latest.jpg"
         ) as res:
             res.raise_for_status()
             return Attachment("image", await res.read())
     except:
-        logger.exception("Failed to call GOES16")
-        RollbotFailure.SERVICE_DOWN.raise_exc(detail="Failed to call GOES16")
+        logger.exception(f"Failed to call GOES16 for sector {sector}")
+        RollbotFailure.SERVICE_DOWN.raise_exc(detail=f"Failed to call GOES16 for sector {sector}")
 
 
 @as_command

+ 4 - 0
commands/commands/simple.py

@@ -42,6 +42,7 @@ def console(argstr: Args):
     return random.choice(opts)
 
 
+@as_command("choose")
 @as_command
 def choice(args: Args, arg_list: ArgList):
     for delim in ("|", ";", ","):
@@ -162,6 +163,7 @@ FFFFFFF
 """.strip()
 
 
+@as_command("fs")
 @as_command("f")
 def finchat(cmd: Command):
     return "frick!" if cmd.raw_name == "f" else Fs
@@ -197,6 +199,8 @@ def unfeed():
     return random.choice(("What's your problem?", "Bro why", "Come on!!!!"))
 
 
+@as_command("bubbles")
+@as_command("bubble")
 @as_command
 def bubblewrap(args: Args):
     try:

+ 3 - 0
commands/commands/teamspeak.py

@@ -32,6 +32,9 @@ async def teemspeem(query: Config("teamspeak.query"), req: Request, logger: Logg
     return result.replace("k", "m").replace("K", "M")
 
 
+@as_command("speemteek")
+@as_command("speemteak")
+@as_command("speamteak")
 @as_command
 async def speamteek(query: Config("teamspeak.query"), req: Request, logger: Logger):
     return (await teamspeak(query, req, logger))[::-1]