Exemplo n.º 1
0
def cmd_new_alarm(message):
    mydb = SQLighter(config.database_schedules_file)
    # If not in VIP list - exit
    if mydb.count_entries_for_id(message.chat.id) == 5 and int(message.chat.id) not in config.vip_list:
        bot.send_message(message.chat.id, config.lang.s_error_maximum_number_of_notes)
        mydb.close()
        return None

    set_new_state(message.chat.id, StateMachine.States.STATE_NEWALARM)

    # if user haven't set timezone - ask him to set one
    if not offset_storage.exists(str(message.chat.id)):
        logger.debug('User {0!s} is going to set new alarm. It\'s his first appear'.format(
            str(message.from_user.username) + ' (' + str(message.chat.id) + ')'))
        set_new_state(message.chat.id, StateMachine.States.STATE_SETTING_TIMEZONE_FOR_ALARM)
        bot.send_message(message.chat.id, config.lang.s_common_guide_timezone)
    # if we already have his timezone saved - ask him to set time
    else:
        logger.debug('User {0!s} is going to set new alarm. He has been here before'.format(
            str(message.from_user.username) + ' (' + str(message.chat.id) + ')'))
        set_new_state(message.chat.id, StateMachine.States.STATE_SETTING_TIME)
        bot.send_message(message.chat.id, config.lang.s_common_guide_time)