|
1 | 1 | import random |
| 2 | +from collections import defaultdict |
2 | 3 | from datetime import datetime, timedelta |
3 | 4 |
|
4 | 5 | from telegram.ext import CommandHandler |
@@ -176,10 +177,40 @@ async def schedule_wizards(update, context): |
176 | 177 | ) |
177 | 178 |
|
178 | 179 |
|
| 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 | + |
179 | 208 | def set_handlers(application): |
180 | 209 | application.add_handler( |
181 | 210 | CommandHandler('evocar_magx', summon_wizard)) |
182 | 211 | application.add_handler( |
183 | 212 | CommandHandler('ser_magx', become_wizard)) |
184 | 213 | application.add_handler( |
185 | 214 | CommandHandler('agendar_magos', schedule_wizards)) |
| 215 | + application.add_handler( |
| 216 | + CommandHandler('ver_agenda_magx', show_wizards_schedule)) |
0 commit comments