Skip to content

Commit ddc6603

Browse files
committed
Add /config action
1 parent 6fd8210 commit ddc6603

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

bot.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/enb python3
22

33
from datetime import datetime as DateTime
4+
import itertools
45
import argparse
56
import logging
67
import sys
@@ -102,6 +103,22 @@ async def command_zen(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
102103
parse_mode=ParseMode.HTML,
103104
)
104105

106+
async def command_config(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
107+
self.trace('Received command: /config')
108+
buff = [
109+
'Probabilidad de responder: {config.VERBOSITY:.2f}',
110+
'Disparadores:',
111+
]
112+
trigger_words = sorted(list(itertools.chain(*config.REPLIES.keys())))
113+
for word in trigger_words:
114+
buff.append(f' - {word}')
115+
text = '\n'.join(buff)
116+
await context.bot.send_message(
117+
chat_id=update.effective_chat.id,
118+
text=text,
119+
parse_mode=ParseMode.HTML,
120+
)
121+
105122
async def welcome(self, update: Update, context):
106123
self.trace('Received new user event')
107124
new_member = update.message.new_chat_members[0]
@@ -153,6 +170,9 @@ def run(self):
153170
# Zen Command
154171
application.add_handler(CommandHandler('zen', self.command_zen))
155172

173+
# Config Command
174+
application.add_handler(CommandHandler('config', self.command_config))
175+
156176
welcome_handler = MessageHandler(
157177
filters.StatusUpdate.NEW_CHAT_MEMBERS,
158178
self.welcome,

config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@ def bot_replies_enabled() -> bool:
9898

9999
REPLIES = {
100100
("java",): "BIBA JABA!! ☕️",
101+
("rust",): "BIBA RRRRUST!! ☕️",
102+
("ruby",): "BIBA RRRRUBÍ!! ☕️",
101103
("cobol",): "BIBA KOBOL!! 💾",
102104
("javascript",): "BIBA JABAESKRIPT!! 🔮",
103105
("php",): "BIBA PEHACHEPÉ!.! ⛱",
106+
("perl",): "BIBA PERRRRRL! 🐫",
104107
("chatgpt", "gpt", "openai"): "BIBA CHATJEPETÉ!! 🤖",
105108
(
106109
"he visto",

utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_reply_regex(trigger_words: Tuple[str]):
6767
Build a regex to match on the trigger words
6868
"""
6969
pattern = "|".join([fr"\b{word}\b" for word in trigger_words])
70-
return re.compile(pattern, re.I)
70+
return re.compile(pattern, re.IGNORECASE)
7171

7272

7373
def bot_wants_to_reply() -> bool:

0 commit comments

Comments
 (0)