get_me method needed for legacy mode

This commit is contained in:
Davte 2019-07-14 20:01:07 +02:00
parent 0ac4553591
commit f689d9b95a
2 changed files with 20 additions and 1 deletions

View File

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

View File

@ -1881,6 +1881,25 @@ class Bot(telepot.aio.Bot, Gettable):
error=None 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): async def continue_running(self):
"""Get updates. """Get updates.