From 94974c8b5adac4deb8615edf1b06f3ad79cd2f3d Mon Sep 17 00:00:00 2001 From: "hikari.ftg" Date: Thu, 31 Mar 2022 20:50:03 +0000 Subject: [PATCH] Add client id to session file name to avoid conflicts when user tries to add two accounts with the same phone endings --- hikka/main.py | 12 ++---------- hikka/web/root.py | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/hikka/main.py b/hikka/main.py index e2e871a..20d3e6d 100755 --- a/hikka/main.py +++ b/hikka/main.py @@ -349,12 +349,12 @@ class Hikka: importlib.invalidate_caches() self._get_api_token() - def fetch_clients_from_web(self) -> None: + async def fetch_clients_from_web(self) -> None: for client in self.web.clients: session = SQLiteSession( os.path.join( self.arguments.data_root or os.path.dirname(utils.get_base_dir()), - f"hikka-+{'X' * (len(client.phone) - 5)}{client.phone[-4:]}", + f"hikka-+{'x' * (len(client.phone) - 5)}{client.phone[-4:]}-{(await client.get_me()).id}", ) ) @@ -456,14 +456,6 @@ class Hikka: loops = [self.amain_wrapper(client) for client in self.clients] self.loop.run_until_complete(asyncio.gather(*loops)) - async def reconnect_clients(self) -> None: - for client in self.clients: - await client.disconnect() - - self.fetch_clients_from_web() - self._init_clients() - self._init_loop() - async def amain_wrapper(self, client) -> None: """Wrapper around amain""" async with client: diff --git a/hikka/web/root.py b/hikka/web/root.py index 1b90876..58e7941 100644 --- a/hikka/web/root.py +++ b/hikka/web/root.py @@ -194,7 +194,7 @@ class Web: first_session = not bool(main.hikka.clients) - main.hikka.fetch_clients_from_web() + await main.hikka.fetch_clients_from_web() self.clients_set.set()