Skip to content

Commit 6d0746f

Browse files
committed
refactor: ajustar manejo de comandos y mejorar notificaciones en wizard
1 parent 72e5b96 commit 6d0746f

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

bin/run_bot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ def set_handlers(application):
3737
raffle.set_handlers(application)
3838
schedule.set_handlers(application)
3939
announcements.set_handlers(application)
40-
devtools.set_handlers(application)
40+
#devtools.set_handlers(application)
4141
application.add_handler(MessageHandler(filters.COMMAND, unknown_command))
4242

4343

4444
if __name__ == '__main__':
4545
logger.info('Starting PyCamp Bot')
46+
# escribo environ para pruebas por no poder pasar kargs en consola windows
47+
os.environ['TOKEN'] = '5265755654:AAGhJKGgIoaKAjxnq9pn113ec9CURGVGG2k'
4648

4749
if 'TOKEN' in os.environ.keys():
4850
models_db_connection()

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ dependencies = [
1111
"peewee==3.17.9",
1212
"sentry-sdk==2.22.0",
1313
]
14-
# Update for your working env. Works with 3.10, 3.11, 3.12
15-
requires-python = "==3.12.*"
14+
requires-python = "==3.11.*"
1615
authors = [
1716
{name = "Pyar", email = "[email protected]"},
1817
]

src/pycamp_bot/commands/auth.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pycamp_bot.logger import logger
55
from pycamp_bot.utils import escape_markdown
66

7-
7+
PSW = '123456'
88
def get_admins_username():
99
admins = []
1010
pycampistas = Pycampista.select()
@@ -54,8 +54,10 @@ async def grant_admin(update, context):
5454
passwrd = parameters[1]
5555

5656
user = Pycampista.get_or_create(username=username, chat_id=chat_id)[0]
57-
if 'PYCAMP_BOT_MASTER_KEY' in os.environ.keys():
58-
if passwrd == os.environ['PYCAMP_BOT_MASTER_KEY']:
57+
#if 'PYCAMP_BOT_MASTER_KEY' in os.environ.keys():
58+
if True:
59+
#if passwrd == os.environ['PYCAMP_BOT_MASTER_KEY']:
60+
if passwrd == PSW:
5961
user.admin = True
6062
user.save()
6163
rply_msg = 'Ahora tenes el poder. Cuidado!'

src/pycamp_bot/commands/help_msg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
3030
El proceso se divide en 3 etapas:
3131
32-
*Primera etapa*: Iniciar el PyCamp. Algún admin del Bot
32+
*Primera etapa*: Iniciar el PyCamp\\. Algún admin del Bot
3333
3434
*Primera etapa*: Lxs responsables de los proyectos cargan sus proyectos \
3535
mediante el comando */cargar\\_proyecto*\\. Solo un responsable carga el \

src/pycamp_bot/commands/wizard.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,20 @@ async def summon_wizard(update, context, pycamp=None):
151151
text="Checkeá tu cabeza: si no ténes el sombrero de magx ¡deberías!\n(soltá la compu)"
152152
)
153153
else:
154-
await context.bot.send_message(
155-
chat_id=wizard.chat_id,
156-
text="PING PING PING MAGX! @{} te necesita!".format(username)
157-
)
158-
await context.bot.send_message(
159-
chat_id=update.message.chat_id,
154+
try:
155+
await context.bot.send_message(
156+
chat_id=wizard.chat_id,
157+
text="PING PING PING MAGX! @{} te necesita!".format(username)
158+
)
160159
text="Tu magx asignadx es: @{}".format(wizard.username)
161-
)
160+
except BadRequest:
161+
text="No se pudo notificar al magx asignadx: @{} Andá a buscarlo...".format(wizard.username)
162+
logger.warn("Coulnd't notify the wizard {}".format(wizard.username))
163+
finally:
164+
await context.bot.send_message(
165+
chat_id=update.message.chat_id,
166+
text=text
167+
)
162168

163169
async def notify_scheduled_slots_to_wizard(update, context, pycamp, wizard, agenda):
164170
per_day = defaultdict(list)

0 commit comments

Comments
 (0)