def mockUpdate(self, text): message = Message(0, None, None, None) message.text = text update = Update(0) if self.edited: update.edited_message = message else: update.message = message return update
def mockUpdate(self, text): message = Message(0, User(0, 'Testuser'), None, Chat(0, Chat.GROUP)) message.text = text update = Update(0) if self.edited: update.edited_message = message else: update.message = message return update
def mockUpdate(self, text): message = Message(0, None, None, None) message.text = text update = Update(0) if self.edited: update.edited_message = message else: update.message = message return update
def mock_update(self, text): message = Message(0, User(0, 'Testuser'), None, Chat(0, Chat.GROUP), bot=self) message.text = text update = Update(0) if self.edited: update.edited_message = message else: update.message = message return update
def adapt_edited_message(self, update: Update, context: CallbackContext) -> None: """ Method to modify :py:class:telegram.Update containing edited message, so that it can be handled a a normal received message. Dispatches modified update again. Args: update: context: """ update.message = update.edited_message update.edited_message = None self.updater.dispatcher.process_update(update)
def edit_admin_message(update: Update, context: CallbackContext): """Edit the message of admins sent to user.""" database = context.bot_data["database"] user_id = update.edited_message.from_user.id message_id = update.edited_message.message_id user_id, dest_message_id = database.get_user_dest_message_id_from_admins( message_id) if not _is_legit_reply(update, context): return if user_id: send_edited_message(context.bot, update.edited_message, dest_message_id, user_id, False) else: user_id, reply_to = get_user_src_message(update, context) update.edited_message, update.message = update.message, update.edited_message context.job_queue.run_once( callback=_send_users, when=Literal.DELAY_SECONDS, context=(update, user_id, reply_to), )
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