Queer European MD passionate about IT
Procházet zdrojové kódy

Method to send disposable messages implemented

Davte před 5 roky
rodič
revize
0e7a93c5be
2 změnil soubory, kde provedl 13 přidání a 1 odebrání
  1. 1 1
      davtelepot/__init__.py
  2. 12 0
      davtelepot/bot.py

+ 1 - 1
davtelepot/__init__.py

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

+ 12 - 0
davtelepot/bot.py

@@ -1146,6 +1146,18 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
             )
         return sent_message_update
 
+    async def send_disposable_message(self, *args, interval=60, **kwargs):
+        sent_message = await self.reply(*args, **kwargs)
+        if sent_message is None:
+            return
+        task = self.delete_message(update=sent_message)
+        self.final_tasks.append(task)
+        await asyncio.sleep(interval)
+        await task
+        if task in self.final_tasks:
+            self.final_tasks.remove(task)
+        return
+
     async def edit_message_text(self, text,
                                 chat_id=None, message_id=None,
                                 inline_message_id=None,