Queer European MD passionate about IT
Browse Source

get_me method needed for legacy mode

Davte 5 năm trước cách đây
mục cha
commit
f689d9b95a
2 tập tin đã thay đổi với 20 bổ sung1 xóa
  1. 1 1
      davtelepot/__init__.py
  2. 19 0
      davtelepot/custombot.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.0.1"
+__version__ = "2.0.2"
 __maintainer__ = "Davide Testa"
 __contact__ = "t.me/davte"
 

+ 19 - 0
davtelepot/custombot.py

@@ -1881,6 +1881,25 @@ class Bot(telepot.aio.Bot, Gettable):
             error=None
         )
 
+    async def get_me(self):
+        """Get bot information.
+
+        Restart bots if bot can't be got.
+        """
+        try:
+            me = await self.getMe()
+            self.bot_name = me["username"]
+            self.telegram_id = me['id']
+        except Exception as e:
+            logging.error(
+                "Could not get bot\n{e}".format(
+                    e=e
+                )
+            )
+            await asyncio.sleep(5*60)
+            self.restart_bots()
+            return
+
     async def continue_running(self):
         """Get updates.