feat: add ANO_PREFIX bot response

This commit is contained in:
cătălin 2025-05-27 18:23:36 +02:00
commit 7131930d8e
No known key found for this signature in database
7 changed files with 607 additions and 541 deletions

View file

@ -1,6 +1,6 @@
apiVersion: v2 apiVersion: v2
appVersion: 0.3.4 appVersion: 0.3.5
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
name: huesoporro name: huesoporro
type: application type: application
version: 0.3.4 version: 0.3.5

View file

@ -8,7 +8,7 @@ fullnameOverride: ''
image: image:
pullPolicy: Always pullPolicy: Always
repository: git.roboces.dev/catalin/huesoporro repository: git.roboces.dev/catalin/huesoporro
tag: 0.3.4 tag: 0.3.5
imagePullSecrets: [] imagePullSecrets: []
ingress: ingress:
annotations: {} annotations: {}

View file

@ -19,10 +19,10 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1733328505, "lastModified": 1747046372,
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -46,10 +46,31 @@
"type": "github" "type": "github"
} }
}, },
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1747372754,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": { "gitignore": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"pre-commit-hooks", "git-hooks",
"nixpkgs" "nixpkgs"
] ]
}, },
@ -83,7 +104,7 @@
}, },
"nixpkgs-python": { "nixpkgs-python": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
@ -101,33 +122,15 @@
"type": "github" "type": "github"
} }
}, },
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1737465171,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"devenv": "devenv", "devenv": "devenv",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-python": "nixpkgs-python", "nixpkgs-python": "nixpkgs-python",
"pre-commit-hooks": "pre-commit-hooks" "pre-commit-hooks": [
"git-hooks"
]
} }
} }
}, },

View file

@ -1,6 +1,6 @@
[project] [project]
name = "huesoporro" name = "huesoporro"
version = "0.3.4" version = "0.3.5"
description = "Misc Twitch bot" description = "Misc Twitch bot"
readme = "README.md" readme = "README.md"
authors = [ authors = [
@ -24,6 +24,7 @@ dependencies = [
"pytz>=2024.2", "pytz>=2024.2",
"discord-py>=2.4.0", "discord-py>=2.4.0",
"tenacity>=9.0.0", "tenacity>=9.0.0",
"uvicorn>=0.34.0",
] ]
[project.scripts] [project.scripts]

View file

@ -117,6 +117,6 @@ app = create_app()
if __name__ == "__main__": if __name__ == "__main__":
s = Settings.get() 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 = uvicorn.Server(config)
server.run() server.run()

View file

@ -151,6 +151,7 @@ class MessageType(StrEnum):
YES = "YES" YES = "YES"
WHAT = "WHAT" WHAT = "WHAT"
LAUGH = "LAUGH" LAUGH = "LAUGH"
ANO_SUFFIX = "ANO_SUFFIX"
OTHER = "OTHER" OTHER = "OTHER"
@ -168,6 +169,8 @@ class MessageHandler:
"keking", "keking",
"KEKW", "KEKW",
"OMEGADANCEBUTFAST", "OMEGADANCEBUTFAST",
"xdd",
"xdding",
] ]
self.send = channel_send_func self.send = channel_send_func
@ -175,16 +178,17 @@ class MessageHandler:
"""Determines the type of message based on its content""" """Determines the type of message based on its content"""
if content.startswith("!"): if content.startswith("!"):
return MessageType.COMMAND return MessageType.COMMAND
if content == "Yes": if content in ["Yes", "yes"]:
return MessageType.YES return MessageType.YES
if content.startswith("WHAT"): if content.startswith("WHAT"):
return MessageType.WHAT return MessageType.WHAT
if content.endswith("ano") and len(content) > 3: # noqa: PLR2004
return MessageType.ANO_SUFFIX
if content in self.laugh_patterns: if content in self.laugh_patterns:
return MessageType.LAUGH return MessageType.LAUGH
return MessageType.OTHER return MessageType.OTHER
async def handle_laugh(self) -> str: async def handle_laugh(self) -> str:
"""Handles laugh messages"""
return random.choice(self.laugh_patterns) # noqa: S311 return random.choice(self.laugh_patterns) # noqa: S311
@ -200,6 +204,7 @@ class SaveMessagesCog(commands.Cog):
MessageType.YES: self._create_typed_send("yes"), MessageType.YES: self._create_typed_send("yes"),
MessageType.WHAT: self._create_typed_send("what"), MessageType.WHAT: self._create_typed_send("what"),
MessageType.LAUGH: self._create_typed_send("laugh"), MessageType.LAUGH: self._create_typed_send("laugh"),
MessageType.ANO_SUFFIX: self._create_typed_send("ano_suffix"),
} }
for func in self.send_functions.values(): for func in self.send_functions.values():
@ -227,13 +232,10 @@ class SaveMessagesCog(commands.Cog):
if not message.author: if not message.author:
return return
# Store reference to current message for send functions
self.current_message = message self.current_message = message
# Store the message content
await self.store_svc.run(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) msg_type = self.message_handler.get_message_type(message.content)
response = None response = None
@ -247,11 +249,14 @@ class SaveMessagesCog(commands.Cog):
response = "WHAT Ramon" response = "WHAT Ramon"
case MessageType.LAUGH: case MessageType.LAUGH:
response = await self.message_handler.handle_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: case MessageType.OTHER:
return return
if response and msg_type in self.send_functions: 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) await self.backoff_svc.call_async(self.send_functions[msg_type], response)

1037
uv.lock generated

File diff suppressed because it is too large Load diff