Skip to content

Commit 1d25865

Browse files
committed
WIP on command to show wizards schedule
1 parent 27e6c05 commit 1d25865

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/pycamp_bot/commands/wizard.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import random
2+
from collections import defaultdict
23
from datetime import datetime, timedelta
34

45
from telegram.ext import CommandHandler
@@ -176,10 +177,40 @@ async def schedule_wizards(update, context):
176177
)
177178

178179

180+
async def show_wizards_schedule(update, context):
181+
_, pycamp = get_active_pycamp()
182+
183+
agenda = WizardAtPycamp.select().where(pycamp == pycamp).order_by(WizardAtPycamp.init)
184+
per_day = defaultdict(list)
185+
for entry in agenda:
186+
k = entry.init.strftime("%a %d de %b")
187+
per_day[k].append(entry)
188+
189+
msg = "Esta es la agenda de magos para el PyCamp {}".format(pycamp.headquarters)
190+
for day, items in per_day.items():
191+
msg += "\nEl día _{}_:\n".format(day)
192+
for i in items:
193+
msg += "\t \\- {} a {}:\t*{}* \n".format(
194+
i.init.strftime("%H:%M"),
195+
i.end.strftime("%H:%M"),
196+
"@" + i.wizard.username
197+
)
198+
199+
logger.debug(msg)
200+
201+
await context.bot.send_message(
202+
chat_id=update.message.chat_id,
203+
text=msg,
204+
parse_mode="MarkdownV2"
205+
)
206+
207+
179208
def set_handlers(application):
180209
application.add_handler(
181210
CommandHandler('evocar_magx', summon_wizard))
182211
application.add_handler(
183212
CommandHandler('ser_magx', become_wizard))
184213
application.add_handler(
185214
CommandHandler('agendar_magos', schedule_wizards))
215+
application.add_handler(
216+
CommandHandler('ver_agenda_magx', show_wizards_schedule))

0 commit comments

Comments
 (0)