Пример #1
0
def change_timezone_2(msg):
    if states[msg.chat.id] == 'cancel':
        return
    timezone = msg.text
    keyboard = ui.generate_menu('cancel')
    database.change_settings(msg.chat.id, {'timezone': int(timezone)})
    bot.send_message(msg.chat.id, ui.text['success'], reply_markup=keyboard)
Пример #2
0
def change_timetable_3(msg):
    if states[msg.chat.id] == 'cancel':
        return
    times = utils.parse_time(msg.text)
    timetables = {states[msg.chat.id]: times}
    database.add_timetable(msg.chat.id, timetables)
    keyboard = ui.generate_menu('cancel')
    bot.send_message(msg.chat.id, ui.text['success'], reply_markup=keyboard)
Пример #3
0
def change_timetable_2(msg):
    if states[msg.chat.id] == 'cancel':
        return
    keyboard = ui.generate_menu('user_input')
    msg_to_answer = bot.send_message(msg.chat.id, ui.text['change'].format(day=constants.days_of_week_long[msg.text]), reply_markup=keyboard,
                                     parse_mode='HTML')
    states[msg.chat.id] = msg.text
    bot.register_next_step_handler(msg_to_answer, change_timetable_3)
Пример #4
0
def delete_timetable_2(msg):
    if states[msg.chat.id] == 'cancel':
        return
    timetable = database.get_timetable(msg.chat.id).get(msg.text)
    if not timetable:
        keyboard = ui.generate_menu('cancel')
        bot.send_message(msg.chat.id, ui.text['day_empty'], reply_markup=keyboard)
        return
    keyboard = telebot.types.InlineKeyboardMarkup(row_width=2)
    keyboard.add(*[telebot.types.InlineKeyboardButton(time, callback_data=time) for time in timetable])
    notes = '\n'.join([' - '.join([a, b]) for a, b in timetable.items()])
    states[msg.chat.id] = msg.text
    bot.send_message(msg.chat.id, ui.text['choose_delete'].format(notes=notes), reply_markup=keyboard, parse_mode='HTML')
Пример #5
0
def change_timetable(msg):
    keyboard = ui.generate_menu('days')
    bot.send_message(msg.chat.id, ui.text['days'], reply_markup=keyboard, parse_mode='HTML')
    states[msg.chat.id] = 'change'
Пример #6
0
def cancel(msg):
    states[msg.chat.id] = 'cancel'
    keyboard = ui.generate_menu('cancel')
    bot.send_message(msg.chat.id, ui.text['cancel'], reply_markup=keyboard)
Пример #7
0
def start(msg):
    keyboard = ui.generate_menu('main')
    bot.send_message(msg.chat.id, ui.text['main'], reply_markup=keyboard, parse_mode='HTML')
    states[msg.chat.id] = 'main'
    database.add_user(msg.chat.id)
Пример #8
0
def delete_timetable_3(call):
    database.delete_note(call.from_user.id, states[call.from_user.id], call.data)
    bot.edit_message_reply_markup(call.from_user.id, call.message.message_id)
    keyboard = ui.generate_menu('cancel')
    bot.delete_message(call.from_user.id, call.message.message_id)
    bot.send_message(call.from_user.id, ui.text['success'], reply_markup=keyboard)
Пример #9
0
def change_timezone(msg):
    keyboard = ui.generate_menu('timezones')
    msg_to_answer = bot.send_message(msg.chat.id, ui.text['change_timezone'], reply_markup=keyboard, parse_mode='HTML')
    bot.register_next_step_handler(msg_to_answer, change_timezone_2)
Пример #10
0
def settings(msg):
    keyboard = ui.generate_menu('settings')
    states[msg.chat.id] = 'settings'
    bot.send_message(msg.chat.id, ui.text['settings'], reply_markup=keyboard, parse_mode='HTML')