From fbfa22073d3370d3676b9d0f1046930475307d30 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Tue, 26 Nov 2024 01:27:47 +0100 Subject: [PATCH] Update pyrogram --- pyrogram_rockserver_storage/__init__.py | 18 +++++++++++++++++- requirements.txt | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pyrogram_rockserver_storage/__init__.py b/pyrogram_rockserver_storage/__init__.py index c06570f..337196d 100644 --- a/pyrogram_rockserver_storage/__init__.py +++ b/pyrogram_rockserver_storage/__init__.py @@ -111,6 +111,7 @@ class RockServerStorage(Storage): self._save_user_peers = save_user_peers self._username_to_id = LRU(100_000) + self._update_to_state = LRU(100_000) self._phone_to_id = LRU(100_000) super().__init__(name=self._session_id) @@ -236,6 +237,22 @@ class RockServerStorage(Storage): await self._client.putMulti(0, self._peer_col, keys_multi, value_multi) + async def update_usernames(self, usernames: List[Tuple[int, List[str]]]): + for t in usernames: + id_ = t[0] + id_usernames = t[1] + for username in id_usernames: + self._username_to_id[username] = id_ + + async def update_state(self, value: Tuple[int, int, int, int, int] = object): + if value == object: + return sorted(self._update_to_state.values(), key=lambda x: x[3], reverse=False) + else: + if isinstance(value, int): + self._update_to_state.pop(value) + else: + self._update_to_state[value[0]] = value + async def get_peer_by_id(self, peer_id: int): if isinstance(peer_id, str) or (not self._save_user_peers and peer_id > 0): raise KeyError(f"ID not found: {peer_id}") @@ -317,4 +334,3 @@ class RockServerStorage(Storage): async def is_bot(self, value: bool = object): return await self._accessor('is_bot', value) - diff --git a/requirements.txt b/requirements.txt index dfbe1b1..213a0ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pyrogram @ git+https://github.com/cavallium/faster-pyrogram@847a353ce65b9b7edaef9a05eb71b20f107d67da +Pyrogram @ git+https://github.com/cavallium/faster-pyrogram@12f9207e1ba817719bb121e0275453279829fd76 bson~=0.5.10 thriftpy2~=0.5.2 lru-dict~=1.3.0