def update_subscription(_bot: Bot, update: Update) -> None: user_id = update.effective_user.id if not User.get(user_id=user_id).is_subscribed(): subscribe_user(user_id) update.message.reply_text(BOT_SUBSCRIBED_USR, reply_markup=get_keyboard(update)) else: unsubscribe_user(user_id) update.message.reply_text(BOT_UNSUBSCRIBED_USR, reply_markup=get_keyboard(update))
def update_subscription(bot, update): c = db.cursor() if not subscribed(update.message.from_user.id): c.execute('INSERT INTO subscribers VALUES (%s)', (update.message.from_user.id, )) update.message.reply_text(BOT_SUBSCRIBED_USR, reply_markup=get_keyboard(update, True)) else: c.execute('DELETE FROM subscribers WHERE id=(%s)', (update.message.from_user.id, )) update.message.reply_text(BOT_UNSUBSCRIBED_USR, reply_markup=get_keyboard(update, False)) db.commit() c.close()
def cancel(bot, update, user_data): update.message.reply_text(BOT_CANCELLED, reply_markup=get_keyboard( update, subscribed(update.message.from_user.id))) user_data.clear() return ConversationHandler.END
def receive_feedback(bot, update): update.message.reply_text(BOT_FEEDBACK_SENT_USR, reply_markup=get_keyboard( update, subscribed(update.message.from_user.id))) bot.send_message(alexfox, update.message.text) return ConversationHandler.END
def receive_feedback(bot: Bot, update: Update) -> int: update.message.reply_text(BOT_FEEDBACK_SENT_USR, reply_markup=get_keyboard(update)) bot.send_message(alexfox, BOT_DELIVER_FEEDBACK.format(update.effective_user.name, update.message.text), parse_mode='markdown') return ConversationHandler.END
def process_choice_budget(message): try: user_markup = get_keyboard(telebot=telebot, item_list=storage['budget']) msg = bot.reply_to(message, 'Выберите бюджет на человека', reply_markup=user_markup) bot.register_next_step_handler(msg, process_send_number) except Exception as e: log.exception(e) bot.reply_to(message, 'Введите команду /help')
def process_choice_count(message): try: user_markup = get_keyboard(telebot=telebot, item_list=storage['nights_count']) msg = bot.reply_to(message, 'Выберите количество ночей', reply_markup=user_markup) bot.register_next_step_handler(msg, process_choice_budget) except Exception as e: log.exception(e) bot.reply_to(message, 'Введите команду /help')
def send_instructions(bot, update, start=False): if update.message.text == MENU_ROADS: text = BOT_PRIVATE_ROAD_REPORT_USR elif update.message.text == '/start' or start: text = BOT_ACTION_SELECT else: text = BOT_UNRECOGNIZED_MESSAGE update.message.reply_text(text, reply_markup=get_keyboard( update, subscribed(update.message.from_user.id)))
def send_instructions(_bot: Bot, update: Update, start=False) -> None: instructions = {MENU_ROADS: BOT_PRIVATE_ROAD_REPORT_USR, '/start inline-help': BOT_INLINE_INSTRUCTIONS, '/start': BOT_ACTION_SELECT} if update.message.text in instructions: text = instructions[update.message.text] elif start: text = BOT_ACTION_SELECT else: text = BOT_UNRECOGNIZED_MESSAGE update.message.reply_markdown( text, reply_markup=get_keyboard(update))
def process_choice_country(message): try: if message.text != '/start': msg = bot.reply_to(message, 'Выберите пожалуйста вариант из меню') bot.register_next_step_handler(msg, process_choice_country) return user_markup = get_keyboard(telebot=telebot, item_list=storage['country']) msg = bot.reply_to(message, 'Выберите страну для визита', reply_markup=user_markup) bot.register_next_step_handler(msg, process_choice_date) except Exception as e: log.exception(e) bot.reply_to(message, 'Введите команду /help')
def cancel(_bot: Bot, update: Update, user_data: dict) -> int: update.message.reply_text(BOT_CANCELLED, reply_markup=get_keyboard(update)) user_data.clear() return ConversationHandler.END