feat: add ANO_PREFIX bot response
This commit is contained in:
parent
4c2f85c105
commit
7131930d8e
7 changed files with 607 additions and 541 deletions
|
|
@ -117,6 +117,6 @@ app = create_app()
|
|||
|
||||
if __name__ == "__main__":
|
||||
s = Settings.get()
|
||||
config = uvicorn.Config("main:app", host=s.port, port=s.port, log_level="info")
|
||||
config = uvicorn.Config("main:app", host=s.host, port=s.port, log_level="info")
|
||||
server = uvicorn.Server(config)
|
||||
server.run()
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ class MessageType(StrEnum):
|
|||
YES = "YES"
|
||||
WHAT = "WHAT"
|
||||
LAUGH = "LAUGH"
|
||||
ANO_SUFFIX = "ANO_SUFFIX"
|
||||
OTHER = "OTHER"
|
||||
|
||||
|
||||
|
|
@ -168,6 +169,8 @@ class MessageHandler:
|
|||
"keking",
|
||||
"KEKW",
|
||||
"OMEGADANCEBUTFAST",
|
||||
"xdd",
|
||||
"xdding",
|
||||
]
|
||||
self.send = channel_send_func
|
||||
|
||||
|
|
@ -175,16 +178,17 @@ class MessageHandler:
|
|||
"""Determines the type of message based on its content"""
|
||||
if content.startswith("!"):
|
||||
return MessageType.COMMAND
|
||||
if content == "Yes":
|
||||
if content in ["Yes", "yes"]:
|
||||
return MessageType.YES
|
||||
if content.startswith("WHAT"):
|
||||
return MessageType.WHAT
|
||||
if content.endswith("ano") and len(content) > 3: # noqa: PLR2004
|
||||
return MessageType.ANO_SUFFIX
|
||||
if content in self.laugh_patterns:
|
||||
return MessageType.LAUGH
|
||||
return MessageType.OTHER
|
||||
|
||||
async def handle_laugh(self) -> str:
|
||||
"""Handles laugh messages"""
|
||||
return random.choice(self.laugh_patterns) # noqa: S311
|
||||
|
||||
|
||||
|
|
@ -200,6 +204,7 @@ class SaveMessagesCog(commands.Cog):
|
|||
MessageType.YES: self._create_typed_send("yes"),
|
||||
MessageType.WHAT: self._create_typed_send("what"),
|
||||
MessageType.LAUGH: self._create_typed_send("laugh"),
|
||||
MessageType.ANO_SUFFIX: self._create_typed_send("ano_suffix"),
|
||||
}
|
||||
|
||||
for func in self.send_functions.values():
|
||||
|
|
@ -227,13 +232,10 @@ class SaveMessagesCog(commands.Cog):
|
|||
if not message.author:
|
||||
return
|
||||
|
||||
# Store reference to current message for send functions
|
||||
self.current_message = message
|
||||
|
||||
# Store the message content
|
||||
await self.store_svc.run(message.content)
|
||||
|
||||
# Determine message type and handle accordingly
|
||||
msg_type = self.message_handler.get_message_type(message.content)
|
||||
|
||||
response = None
|
||||
|
|
@ -247,11 +249,14 @@ class SaveMessagesCog(commands.Cog):
|
|||
response = "WHAT Ramon"
|
||||
case MessageType.LAUGH:
|
||||
response = await self.message_handler.handle_laugh()
|
||||
case MessageType.ANO_SUFFIX:
|
||||
response = (
|
||||
f"@{message.author.name} me la agarras con la mano. venga, tira"
|
||||
)
|
||||
case MessageType.OTHER:
|
||||
return
|
||||
|
||||
if response and msg_type in self.send_functions:
|
||||
# Use the type-specific send function
|
||||
await self.backoff_svc.call_async(self.send_functions[msg_type], response)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue