Update pyrogram

This commit is contained in:
Andrea Cavalli 2024-11-26 01:27:47 +01:00
parent 9d8010298d
commit fbfa22073d
2 changed files with 18 additions and 2 deletions

View File

@ -111,6 +111,7 @@ class RockServerStorage(Storage):
self._save_user_peers = save_user_peers self._save_user_peers = save_user_peers
self._username_to_id = LRU(100_000) self._username_to_id = LRU(100_000)
self._update_to_state = LRU(100_000)
self._phone_to_id = LRU(100_000) self._phone_to_id = LRU(100_000)
super().__init__(name=self._session_id) 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) 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): 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): if isinstance(peer_id, str) or (not self._save_user_peers and peer_id > 0):
raise KeyError(f"ID not found: {peer_id}") raise KeyError(f"ID not found: {peer_id}")
@ -317,4 +334,3 @@ class RockServerStorage(Storage):
async def is_bot(self, value: bool = object): async def is_bot(self, value: bool = object):
return await self._accessor('is_bot', value) return await self._accessor('is_bot', value)

View File

@ -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 bson~=0.5.10
thriftpy2~=0.5.2 thriftpy2~=0.5.2
lru-dict~=1.3.0 lru-dict~=1.3.0