Queer European MD passionate about IT
浏览代码

When editing message, make each message reply to the previous

Davte 5 年之前
父节点
当前提交
568694f3aa
共有 2 个文件被更改,包括 14 次插入11 次删除
  1. 1 1
      davtelepot/__init__.py
  2. 13 10
      davtelepot/bot.py

+ 1 - 1
davtelepot/__init__.py

@@ -7,7 +7,7 @@ __author__ = "Davide Testa"
 __email__ = "davide@davte.it"
 __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
 __license__ = "GNU General Public License v3.0"
-__version__ = "2.1.5"
+__version__ = "2.1.6"
 __maintainer__ = "Davide Testa"
 __contact__ = "t.me/davte"
 

+ 13 - 10
davtelepot/bot.py

@@ -973,7 +973,7 @@ class Bot(TelegramBot, ObjectWithDatabase):
                 message_id = message_identifier['message_id']
             if 'inline_message_id' in message_identifier:
                 inline_message_id = message_identifier['inline_message_id']
-        for i, text_chunk in enumerate(
+        for i, (text_chunk, is_last) in enumerate(
             self.split_message_text(
                 text=text,
                 limit=self.__class__.TELEGRAM_MESSAGES_MAX_LEN - 200,
@@ -995,16 +995,19 @@ class Bot(TelegramBot, ObjectWithDatabase):
                     # Inline keyboards attached to inline query results may be
                     # in chats the bot cannot reach.
                     break
+                updates = [update]
             else:
-                await self.send_message(
-                    text=text_chunk,
-                    chat_id=chat_id,
-                    parse_mode=parse_mode,
-                    disable_web_page_preview=disable_web_page_preview,
-                    reply_markup=reply_markup,
-                    update=update,
-                    reply_to_update=True,
-                    send_default_keyboard=False
+                updates.append(
+                    await self.send_message(
+                        text=text_chunk,
+                        chat_id=chat_id,
+                        parse_mode=parse_mode,
+                        disable_web_page_preview=disable_web_page_preview,
+                        reply_markup=(reply_markup if is_last else None),
+                        update=updates[-1],
+                        reply_to_update=True,
+                        send_default_keyboard=False
+                    )
                 )
         return edited_message