Skip to content

Commit 51652bc

Browse files
committed
New admin command to generate the Wizzards agenda
1 parent 44dcd94 commit 51652bc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/pycamp_bot/commands/wizard.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,36 @@ async def summon_wizard(update, context):
9494
text="Tu magx asignadx es: @{}".format(wizard.username)
9595
)
9696

97+
98+
@admin_needed
99+
async def schedule_wizards(update, context):
100+
_, pycamp = get_active_pycamp()
101+
logger.info(pycamp)
102+
103+
schedule = define_wizards_schedule(pycamp)
104+
105+
for slot, wizard in schedule.items():
106+
start, end = slot
107+
WizardAtPycamp.create(
108+
pycamp=pycamp,
109+
wizard=wizard,
110+
slot_ini=start,
111+
slot_end=end
112+
)
113+
logger.debug("From {} to {} the wizard is {}".format(start, end, wizard.username))
114+
115+
# Mandar mensajes a los magos con su agenda propia
116+
msg = "Lista la agenda de magos."
117+
await context.bot.send_message(
118+
chat_id=update.message.chat_id,
119+
text=msg
120+
)
121+
122+
97123
def set_handlers(application):
98124
application.add_handler(
99125
CommandHandler('evocar_magx', summon_wizard))
100126
application.add_handler(
101127
CommandHandler('ser_magx', become_wizard))
128+
application.add_handler(
129+
CommandHandler('agendar_magos', schedule_wizards))

0 commit comments

Comments
 (0)