Beispiel #1
0
bot = telebot.TeleBot(config.token)
bot.set_update_listener(listener)
apihelper.proxy = config.proxy

subject_select = telebot.types.ReplyKeyboardMarkup(one_time_keyboard=True)
for x in list(config.subject_list.keys()):
    subject_select.add(x)
set_select = telebot.types.ReplyKeyboardMarkup(one_time_keyboard=True)
for x in config.command_list[1:3]:
    set_select.add('/{}'.format(x))

user_step = Vedis(config.user_step_file)
user_subject = Vedis(config.user_subject_file)

user_step.open()
user_subject.open()

@bot.message_handler(commands=[config.command_list[0]])
def command_start(message):
    if not user_step.exists(message.chat.id):
        with user_step.transaction() and user_subject.transaction():
            user_step[message.chat.id] = 1
            user_subject[message.chat.id] = ''
        get_help(message)
    else:
        bot.send_message(message.chat.id,
                     'Используйте комманду /{}, чтобы получить справку'
                     .format(config.command_list[3]))