diff --git a/efb_telegram_master/bot_manager.py b/efb_telegram_master/bot_manager.py index 116633c7..b16aaa16 100644 --- a/efb_telegram_master/bot_manager.py +++ b/efb_telegram_master/bot_manager.py @@ -489,9 +489,16 @@ def edit_message_caption(self, *args, **kwargs): return self.updater.bot.edit_message_caption(*args, **kwargs) @Decorators.retry_on_timeout + @Decorators.caption_affix_decorator @Decorators.retry_on_chat_migration def edit_message_media(self, *args, **kwargs): - return self.updater.bot.edit_message_media(*args, **kwargs) + text = kwargs.pop('caption', None) + parse_mode = kwargs.pop('parse_mode', None) + media = kwargs.pop('media', None) + caption_entities = kwargs.pop('caption_entities', None) + media.caption = text + media.caption_entities = caption_entities + return self.updater.bot.edit_message_media(media=media, *args, **kwargs) def reply_error(self, update, errmsg): """ diff --git a/efb_telegram_master/slave_message.py b/efb_telegram_master/slave_message.py index 8c4e9eeb..b76a2574 100644 --- a/efb_telegram_master/slave_message.py +++ b/efb_telegram_master/slave_message.py @@ -458,7 +458,8 @@ def slave_message_image(self, msg: Message, tg_dest: TelegramChatID, msg_templat media = InputMediaDocument(file) else: media = InputMediaPhoto(file) - self.bot.edit_message_media(chat_id=old_msg_id[0], message_id=old_msg_id[1], media=media) + return self.bot.edit_message_media(chat_id=old_msg_id[0], message_id=old_msg_id[1], media=media, reply_markup=reply_markup, + prefix=msg_template, suffix=reactions, caption=text, parse_mode="HTML") return self.bot.edit_message_caption(chat_id=old_msg_id[0], message_id=old_msg_id[1], reply_markup=reply_markup, prefix=msg_template, suffix=reactions, caption=text, parse_mode="HTML") @@ -535,7 +536,8 @@ def slave_message_animation(self, msg: Message, tg_dest: TelegramChatID, msg_tem if edit_media: assert msg.file and msg.path file = self.process_file_obj(msg.file, msg.path) - self.bot.edit_message_media(chat_id=old_msg_id[0], message_id=old_msg_id[1], media=InputMediaAnimation(file)) + return self.bot.edit_message_media(chat_id=old_msg_id[0], message_id=old_msg_id[1], media=InputMediaAnimation(file), reply_markup=reply_markup, + prefix=msg_template, suffix=reactions, caption=text, parse_mode="HTML") return self.bot.edit_message_caption(chat_id=old_msg_id[0], message_id=old_msg_id[1], prefix=msg_template, suffix=reactions, reply_markup=reply_markup, @@ -693,7 +695,8 @@ def slave_message_file(self, msg: Message, tg_dest: TelegramChatID, msg_template if edit_media: assert msg.file is not None and msg.path is not None file = self.process_file_obj(msg.file, msg.path) - self.bot.edit_message_media(chat_id=old_msg_id[0], message_id=old_msg_id[1], media=InputMediaDocument(file)) + return self.bot.edit_message_media(chat_id=old_msg_id[0], message_id=old_msg_id[1], media=InputMediaDocument(file), reply_markup=reply_markup, + prefix=msg_template, suffix=reactions, caption=text, parse_mode="HTML") return self.bot.edit_message_caption(chat_id=old_msg_id[0], message_id=old_msg_id[1], reply_markup=reply_markup, prefix=msg_template, suffix=reactions, caption=text, parse_mode="HTML") assert msg.file is not None and msg.path is not None @@ -828,7 +831,8 @@ def slave_message_video(self, msg: Message, tg_dest: TelegramChatID, msg_templat if edit_media: assert msg.file is not None and msg.path is not None file = self.process_file_obj(msg.file, msg.path) - self.bot.edit_message_media(chat_id=old_msg_id[0], message_id=old_msg_id[1], media=InputMediaVideo(file)) + return self.bot.edit_message_media(chat_id=old_msg_id[0], message_id=old_msg_id[1], media=InputMediaVideo(file), reply_markup=reply_markup, + prefix=msg_template, suffix=reactions, caption=text, parse_mode="HTML") return self.bot.edit_message_caption(chat_id=old_msg_id[0], message_id=old_msg_id[1], reply_markup=reply_markup, prefix=msg_template, suffix=reactions, caption=text, parse_mode="HTML") assert msg.file is not None and msg.path is not None