Skip to content

Commit fced7d8

Browse files
committed
show partial list of agenda wizards
1 parent 0aade41 commit fced7d8

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/pycamp_bot/commands/wizard.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,39 @@ def format_wizards_schedule(agenda):
223223
return msg
224224

225225
async def show_wizards_schedule(update, context):
226+
show_all = False
227+
parameters = update.message.text.strip().split(' ', 1)
228+
if len(parameters) == 2:
229+
flag = parameters[1].strip().lower()
230+
show_all = (flag == "completa")
231+
if not show_all:
232+
await context.bot.send_message(
233+
chat_id=update.message.chat_id,
234+
text="El comando solo acepta un parámetro (opcional): 'completa'. ¿Probás de nuevo?",
235+
)
236+
return
237+
elif len(parameters) > 2:
238+
await context.bot.send_message(
239+
chat_id=update.message.chat_id,
240+
text="El comando solo acepta un parámetro (opcional): 'completa'. ¿Probás de nuevo?",
241+
)
242+
return
243+
226244
_, pycamp = get_active_pycamp()
227245

228-
agenda = WizardAtPycamp.select().where(pycamp == pycamp).order_by(WizardAtPycamp.init)
246+
agenda = WizardAtPycamp.select().where(WizardAtPycamp.pycamp == pycamp)
247+
if not show_all:
248+
agenda = agenda.where(WizardAtPycamp.end > datetime.now())
249+
agenda = agenda.order_by(WizardAtPycamp.init)
229250
msg = format_wizards_schedule(agenda)
230-
logger.debug(msg)
231251

232252
await context.bot.send_message(
233253
chat_id=update.message.chat_id,
234254
text=msg,
235255
parse_mode="MarkdownV2"
236256
)
257+
logger.debug("Wizards schedule delivered to {}".format(update.message.from_user.username))
258+
237259

238260

239261
def set_handlers(application):

0 commit comments

Comments
 (0)