From c29dad21ea65dfb2e03a3a3187103e749dda7ceb Mon Sep 17 00:00:00 2001 From: "hikari.ftg" Date: Mon, 21 Mar 2022 16:24:04 +0000 Subject: [PATCH] Add send_file exception ignore --- hikka/inline.py | 11 +++++++++-- hikka/main.py | 7 ++----- hikka/translations/dynamic.py | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/hikka/inline.py b/hikka/inline.py index 4e18792..328e038 100755 --- a/hikka/inline.py +++ b/hikka/inline.py @@ -528,8 +528,15 @@ class InlineManager: await m.delete() await r.delete() - m = await conv.send_file(photo) - r = await conv.get_response() + try: + m = await conv.send_file(photo) + r = await conv.get_response() + except Exception: + # In case user was not able to send photo to + # BotFather, it is not a critical issue, so + # just ignore it + m = await conv.send_message("/cancel") + r = await conv.get_response() await m.delete() await r.delete() diff --git a/hikka/main.py b/hikka/main.py index b3a6500..4c2cd7f 100755 --- a/hikka/main.py +++ b/hikka/main.py @@ -219,9 +219,6 @@ def get_phones(arguments): ) authtoken = {} - - if arguments.setup: - authtoken = {} if arguments.tokens: for token in arguments.tokens: phone = sorted(filter(lambda phone: ":" not in phone, phones.values()))[0] @@ -595,8 +592,8 @@ async def amain(first, client, allclients, web, arguments): upd = r"Update required" if diff else r"Up-to-date" termux = bool( - os.popen('echo $PREFIX | grep -o "com.termux"').read() - ) # skipcq: BAN-B605, BAN-B607 + os.popen('echo $PREFIX | grep -o "com.termux"').read() # skipcq: BAN-B605, BAN-B607 + ) _platform = "Termux" if termux else "Unknown" logo1 = f""" diff --git a/hikka/translations/dynamic.py b/hikka/translations/dynamic.py index 9f734bd..70cd3d7 100755 --- a/hikka/translations/dynamic.py +++ b/hikka/translations/dynamic.py @@ -25,7 +25,7 @@ class Strings: self._babel = babel def __getitem__(self, key): - return self._babel.getkey(self._prefix + key) or self._strings[key] + return self._babel.getkey(f"{self._prefix}{key}") or self._strings[key] def __call__(self, key, message=None): if isinstance(message, str):