示例#1
0
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
示例#2
0
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
示例#3
0
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
示例#4
0
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
示例#5
0
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
示例#6
0
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)
示例#7
0
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
示例#8
0
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