From 258a99628b20a79615e3e7cacf0452dc1d6fcc10 Mon Sep 17 00:00:00 2001 From: Zaid Date: Fri, 27 Sep 2024 01:50:36 +0300 Subject: [PATCH] fixes --- tgram/template/main.py | 4 ++-- tgram/tgbot.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tgram/template/main.py b/tgram/template/main.py index bb98c8a..3ea7555 100644 --- a/tgram/template/main.py +++ b/tgram/template/main.py @@ -6,7 +6,7 @@ from tgram import TgBot # from tgram.types import LinkPreviewOptions -from config import TOKEN +from config import BOT_TOKEN logging.basicConfig(level=logging.INFO) py_version = sys.version_info[:2] @@ -15,7 +15,7 @@ async def main(): bot = TgBot( - TOKEN, + BOT_TOKEN, # parse_mode="Markdown", # link_preview_options=LinkPreviewOptions(is_disabled=True), plugins="./plugins", diff --git a/tgram/tgbot.py b/tgram/tgbot.py index 4a4ca6b..c0f0a23 100644 --- a/tgram/tgbot.py +++ b/tgram/tgbot.py @@ -454,17 +454,16 @@ def me(self) -> "tgram.types.User": if self._me: return self._me - async def func(): - self.me = await self.get_me() + import requests - return self.me + response = requests.get(self._api_url + "getMe").json() - task = self.loop.create_task(func()) + if not response["ok"]: + raise APIException._from_json(response) - while not task.done(): - pass + self._me = tgram.types.User._parse(self, response["result"]) - return task.result() + return self._me wrap(RedisStorage)