feat: add ANO_PREFIX bot response
This commit is contained in:
parent
4c2f85c105
commit
7131930d8e
7 changed files with 607 additions and 541 deletions
|
|
@ -1,6 +1,6 @@
|
|||
apiVersion: v2
|
||||
appVersion: 0.3.4
|
||||
appVersion: 0.3.5
|
||||
description: A Helm chart for Kubernetes
|
||||
name: huesoporro
|
||||
type: application
|
||||
version: 0.3.4
|
||||
version: 0.3.5
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ fullnameOverride: ''
|
|||
image:
|
||||
pullPolicy: Always
|
||||
repository: git.roboces.dev/catalin/huesoporro
|
||||
tag: 0.3.4
|
||||
tag: 0.3.5
|
||||
imagePullSecrets: []
|
||||
ingress:
|
||||
annotations: {}
|
||||
|
|
|
|||
55
devenv.lock
55
devenv.lock
|
|
@ -19,10 +19,10 @@
|
|||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1733328505,
|
||||
"lastModified": 1747046372,
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -46,10 +46,31 @@
|
|||
"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": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"pre-commit-hooks",
|
||||
"git-hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
|
|
@ -83,7 +104,7 @@
|
|||
},
|
||||
"nixpkgs-python": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-compat": "flake-compat_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
|
|
@ -101,33 +122,15 @@
|
|||
"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": {
|
||||
"inputs": {
|
||||
"devenv": "devenv",
|
||||
"git-hooks": "git-hooks",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-python": "nixpkgs-python",
|
||||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
"pre-commit-hooks": [
|
||||
"git-hooks"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "huesoporro"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
description = "Misc Twitch bot"
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
|
|
@ -24,6 +24,7 @@ dependencies = [
|
|||
"pytz>=2024.2",
|
||||
"discord-py>=2.4.0",
|
||||
"tenacity>=9.0.0",
|
||||
"uvicorn>=0.34.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
|
|
|||
|
|
@ -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