def get_file(update, context): file = update.effective_message.document.get_file() try: menu = parse_document(file.download()) except ParseError as err: reply(update, context, messages['fail'] + "\n" + str(err), back_btn) return 1 test_msg = update.effective_chat.send_message('Testing...') status_msg = update.effective_message.reply_text(messages['test'], quote=True) try: for submenu in menu.values(): test_msg.edit_text(submenu['message'], reply_markup=submenu['buttons']) except RetryAfter as err: status_msg.edit_text(f"Ошибка Телеграма:\n{err}\n{messages['flood']}") reply(update, context, messages['fail'], back_btn) return 1 except TelegramError as err: status_msg.edit_text( f"```{submenu['message']}```\nОшибка Телеграма:\n{err}\n" # type: ignore "Скорее всего, в тексте неэкранированный спецсимвол, " "используемый для разметки.") reply(update, context, messages['fail'], back_btn) return 1 finally: test_msg.delete() try: os.remove('menu.xlsx') except OSError: pass file.download(custom_path='./menu.xlsx') context.bot_data['menu'] = menu logging.info("Меню обновлено.") status_msg.edit_text(messages['success']) return back(update, context)
def ask_confirm(update, context): context.user_data['phone'] = update.effective_message.text confirm_message = messages['confirm'].format(**context.user_data) reply(update, context, confirm_message, buttons['confirm']) return 3
def ask_phone(update, context): context.user_data['name'] = update.effective_message.text reply(update, context, messages['phone'], buttons['back']) return 2
def ask_name(update, context): reply(update, context, messages['name'], buttons['back']) return 1
def admin(update, context): if update.effective_user.id != context.bot_data['admin']: update.effective_message.delete() return -1 reply(update, context, messages['admin'], back_btn) return 1