Add client id to session file name to avoid conflicts when user tries to add two accounts with the same phone endings

pull/1/head
hikari.ftg 2022-03-31 20:50:03 +00:00
parent a5497fdf9d
commit 94974c8b5a
2 changed files with 3 additions and 11 deletions

View File

@ -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:

View File

@ -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()