Skip to content

Commit a4fe57a

Browse files
authored
Merge pull request #59 from PyAr/add_unknown_command_handler
add unrecognised command handler. add @ to admin list
2 parents c1e24c4 + 80edac7 commit a4fe57a

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

bin/run_bot.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from telegram.ext import Application
2+
from telegram.ext import Application, MessageHandler, filters
33
from pycamp_bot.commands import auth
44
from pycamp_bot.commands import voting
55
from pycamp_bot.commands import manage_pycamp
@@ -12,6 +12,10 @@
1212
from pycamp_bot.models import models_db_connection
1313
from pycamp_bot.logger import logger
1414

15+
async def unknown_command(update, context):
16+
text = "No reconozco el comando, para ver comandos válidos usá /ayuda"
17+
await context.bot.send_message(chat_id=update.message.chat_id, text=text)
18+
1519

1620
def set_handlers(application):
1721
base.set_handlers(application)
@@ -23,6 +27,7 @@ def set_handlers(application):
2327
raffle.set_handlers(application)
2428
schedule.set_handlers(application)
2529
announcements.set_handlers(application)
30+
application.add_handler(MessageHandler(filters.COMMAND, unknown_command))
2631

2732

2833
if __name__ == '__main__':

src/pycamp_bot/commands/auth.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,17 @@ async def revoke_admin(update, context):
8686
user.admin = False
8787
user.save()
8888
await context.bot.send_message(chat_id=chat_id,
89-
text='Un admin a caido --{}--.'.format(fallen_admin))
89+
text='Un admin ha caido --{}--.'.format(fallen_admin))
9090

9191

9292
async def list_admins(update, context):
9393
chat_id = update.message.chat_id
9494

9595
admins = get_admins_username()
96-
rply_msg = 'Los administradores son:\n'
96+
rply_msg = 'Lxs administradorxs son:\n'
9797

9898
for admin in admins:
99-
rply_msg += admin
100-
rply_msg += '\n'
99+
rply_msg += '@' + admin + '\n'
101100

102101
await context.bot.send_message(chat_id=chat_id, text=rply_msg)
103102

src/pycamp_bot/commands/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ def set_handlers(application):
4545

4646
application.add_handler(CommandHandler('start', start))
4747
application.add_handler(CommandHandler('ayuda', help))
48+
application.add_handler(CommandHandler('help', help))

0 commit comments

Comments
 (0)