From b34b1c516f3ea58ee6fbe2078f4e987b7cdf08f5 Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Sun, 17 Jun 2018 17:48:17 +0000 Subject: [PATCH 1/3] Quit failing wank.party seems to have a garbage tier connection to Telegram, so work around this by looping reconnects indefinitely, without crashing to preserve runtime state. --- uniborg/uniborg.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/uniborg/uniborg.py b/uniborg/uniborg.py index 5040b7a..ce3e12d 100644 --- a/uniborg/uniborg.py +++ b/uniborg/uniborg.py @@ -52,8 +52,19 @@ class Uniborg(TelegramClient): self.me = await self.get_me() self.uid = telethon.utils.get_peer_id(self.me) + async def _reconnect_nofail(self): + while True: + try: + self.connect() + except ConnectionError: + pass + def run(self): - self.loop.run_forever() + while True: + try: + self.run_until_disconnected() + except ConnectionError: + self.loop.run_until_complete(self._reconnect_nofail()) def load_plugin(self, shortname): self.load_plugin_from_file(f"{self._plugin_path}/{shortname}.py") From 23971d8a6a7d551205aec4ee42c54aa965ab3553 Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Sun, 17 Jun 2018 17:54:33 +0000 Subject: [PATCH 2/3] Fix missing await --- uniborg/uniborg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uniborg/uniborg.py b/uniborg/uniborg.py index ce3e12d..d40ebdb 100644 --- a/uniborg/uniborg.py +++ b/uniborg/uniborg.py @@ -55,7 +55,7 @@ class Uniborg(TelegramClient): async def _reconnect_nofail(self): while True: try: - self.connect() + await self.connect() except ConnectionError: pass From 1d3ac0a21565fbcfd0e8e36ffc76eb5eee3cc455 Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Sun, 17 Jun 2018 20:06:31 +0000 Subject: [PATCH 3/3] fix --- uniborg/uniborg.py | 1 + 1 file changed, 1 insertion(+) diff --git a/uniborg/uniborg.py b/uniborg/uniborg.py index d40ebdb..0eabbfc 100644 --- a/uniborg/uniborg.py +++ b/uniborg/uniborg.py @@ -56,6 +56,7 @@ class Uniborg(TelegramClient): while True: try: await self.connect() + return except ConnectionError: pass