def handler_to_enter_time_period(update: Update, context: CallbackContext): text = update.message.text if text == Buttons.cancel: return exit_point(update, context) if not check_right_time_period(text): update.message.reply_text(text=text_wrong_enter_time()) return States.TO_ENTER_TIME_PERIOD graph_controller = context.user_data['statistics'] graph_controller.update_time_period(text) user = session.query(User).filter( User.telegram_user_id == update.message.from_user.id).first() update.callback_query = context.user_data['temp_callback_query'] handler_button_choose_time_period(update, context, user) context.user_data.pop('temp_callback_query') bot.send_message(chat_id=update.message.from_user.id, text=text_success_change_time_period(), reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END
def create_update(self, json_obj): update_id = self._get_simple_field(json_obj, 'update_id') message = self.get_message(json_obj) edited_message = self.get_edited_message(json_obj) channel_post = self.get_channel_post(json_obj) edited_channel_post = self.get_edited_channel_post(json_obj) inline_query = self.get_inline_query(json_obj) chosen_inline_result = self.get_chosen_inline_result(json_obj) callback_query = self.get_callback_query(json_obj) update = Update( update_id=update_id ) if message: update.message = message if edited_message: update.edited_message = edited_message if channel_post: update.channel_post = channel_post if edited_channel_post: update.edited_channel_post = edited_channel_post if inline_query: update.inline_query = inline_query if chosen_inline_result: update.chosen_inline_result = chosen_inline_result if callback_query: update.callback_query = callback_query return update