def start_Command(update, context): """Start command explaining what can do this bot and asking for user location.""" logger.info('User {} starts a new conversation'.format( update.message.from_user.first_name)) msgMng.send_txtMsg(update, msgs.welcome_msg) msgMng.send_txtMsg(update, msgs.location_msg) return LOCATION
def location(update, context): """User shared location, and is used to 'calculate' its TZ.""" tz = tf.timezone_at(lng=update.message.location["longitude"], lat=update.message.location["latitude"]) msgMng.send_txtMsg(update, msgs.timezone_msg + tz) logger.info('User {} timezone is {}'.format( update.message.from_user.first_name, tz)) userTZ[0] = timezone(tz) return LOOP
def nextflight_Command(update, context): """User asked for information about the space flight.""" logger.info('User {} request next space flight info'.format( update.message.from_user.first_name)) next_msg, photo = next_Command(userTZ) """Based on the photo/infographic availability, the text does or doesn't include the photo""" if photo is not None: msgMng.send_photoMsg(update, next_msg, photo) else: msgMng.send_txtMsg(update, next_msg) return LOOP
def cancel_Command(update, context): """Cancel command to end the conversation with the bot.""" logger.info('User {} ended conversation'.format( update.message.from_user.first_name)) msgMng.send_txtMsg(update, msgs.cancel_msg) return ConversationHandler.END
def unknown_Command(update, context): """User introduced an unknown command.""" logger.info('User {} send an unknown command {}'.format( update.message.from_user.first_name, update.message.text)) msgMng.send_txtMsg(update, msgs.unknown_msg) return LOOP
def nextevent_Command(update, context): """User asked for information about the next event""" logger.info('User {} request info of next event'.format( update.message.from_user.first_name)) next_msg = event_Command(userTZ) msgMng.send_txtMsg(update, next_msg)
def help_Command(update, context): """User asked for the list of commands.""" logger.info('User {} request the list of commands'.format( update.message.from_user.first_name)) msgMng.send_txtMsg(update, msgs.commands_msg) return LOOP
def skip_location(update, context): """User doesn't want to share location, so UTC will be used.""" logger.info('User {} didn\'t shared location'.format( update.message.from_user.first_name)) msgMng.send_txtMsg(update, msgs.skip_location_msg) return LOOP