@@ -234,19 +234,25 @@ def format_wizards_schedule(agenda):
234234 )
235235 return msg
236236
237- async def show_wizards_schedule ( update , context ):
237+ def aux_resolve_show_all ( message ):
238238 show_all = False
239- parameters = update . message .text .strip ().split (' ' , 1 )
239+ parameters = message .text .strip ().split (' ' , 1 )
240240 if len (parameters ) == 2 :
241241 flag = parameters [1 ].strip ().lower ()
242- show_all = (flag == "completa" )
242+ show_all = (flag == "completa" ) # Once here, the only parameter must be valid
243243 if not show_all :
244- await context .bot .send_message (
245- chat_id = update .message .chat_id ,
246- text = "El comando solo acepta un parámetro (opcional): 'completa'. ¿Probás de nuevo?" ,
247- )
248- return
244+ # The parameter was something else...
245+ raise ValueError ("Wrong parameter" )
249246 elif len (parameters ) > 2 :
247+ # Too many parameters...
248+ raise ValueError ("Wrong parameter" )
249+ return show_all
250+
251+
252+ async def show_wizards_schedule (update , context ):
253+ try :
254+ show_all = aux_resolve_show_all (update .message )
255+ except ValueError :
250256 await context .bot .send_message (
251257 chat_id = update .message .chat_id ,
252258 text = "El comando solo acepta un parámetro (opcional): 'completa'. ¿Probás de nuevo?" ,
@@ -259,6 +265,7 @@ async def show_wizards_schedule(update, context):
259265 if not show_all :
260266 agenda = agenda .where (WizardAtPycamp .end > datetime .now ())
261267 agenda = agenda .order_by (WizardAtPycamp .init )
268+
262269 msg = format_wizards_schedule (agenda )
263270
264271 await context .bot .send_message (
0 commit comments