diff --git a/davtelepot/__init__.py b/davtelepot/__init__.py index 33b22df..c932723 100644 --- a/davtelepot/__init__.py +++ b/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" diff --git a/davtelepot/custombot.py b/davtelepot/custombot.py index 467679b..5720d1a 100644 --- a/davtelepot/custombot.py +++ b/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.