From 3cdb595b5566577bb48cbbab3ab8d7988c6a060c Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Sun, 8 Apr 2018 17:30:50 +0300 Subject: [PATCH] Handle bot tokens --- uniborg/telethon.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uniborg/telethon.py b/uniborg/telethon.py index 1d8c488..6a6cf7a 100644 --- a/uniborg/telethon.py +++ b/uniborg/telethon.py @@ -14,7 +14,7 @@ import telethon.events from . import hacks class Uniborg(TelegramClient): - def __init__(self, session, *, plugin_path="plugins", **kwargs): + def __init__(self, session, *, plugin_path="plugins", bot_token=None, **kwargs): # TODO: handle non-string session self._name = session self._logger = logging.getLogger(session) @@ -30,7 +30,7 @@ class Uniborg(TelegramClient): # precedence self._event_builders = hacks.ReverseList() - self._loop.run_until_complete(self._async_init()) + self._loop.run_until_complete(self._async_init(bot_token=bot_token)) core_plugin = Path(__file__).parent / "_core.py" self.load_plugin_from_file(core_plugin) @@ -38,8 +38,8 @@ class Uniborg(TelegramClient): for p in Path().glob(f"{self._plugin_path}/*.py"): self.load_plugin_from_file(p) - async def _async_init(self): - await self.start() + async def _async_init(self, **kwargs): + await self.start(**kwargs) self.me = await self.get_me() self.uid = telethon.utils.get_peer_id(self.me)