mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-23 23:34:28 +00:00
Fix issues with Python 3.10 (#766)
This commit is contained in:
parent
428cbf56a6
commit
6efd01937f
@ -18,8 +18,6 @@
|
||||
|
||||
from typing import List
|
||||
|
||||
from async_lru import alru_cache
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from pyrogram import types
|
||||
@ -105,18 +103,35 @@ class Sticker(Object):
|
||||
self.thumbs = thumbs
|
||||
# self.mask_position = mask_position
|
||||
|
||||
cache = {}
|
||||
|
||||
@staticmethod
|
||||
@alru_cache(maxsize=256)
|
||||
async def _get_sticker_set_name(send, input_sticker_set_id):
|
||||
try:
|
||||
return (await send(
|
||||
set_id = input_sticker_set_id[0]
|
||||
set_access_hash = input_sticker_set_id[1]
|
||||
|
||||
name = Sticker.cache.get((set_id, set_access_hash), None)
|
||||
|
||||
if name is not None:
|
||||
return name
|
||||
|
||||
name = (await send(
|
||||
raw.functions.messages.GetStickerSet(
|
||||
stickerset=raw.types.InputStickerSetID(
|
||||
id=input_sticker_set_id[0],
|
||||
access_hash=input_sticker_set_id[1]
|
||||
id=set_id,
|
||||
access_hash=set_access_hash
|
||||
)
|
||||
)
|
||||
)).set.short_name
|
||||
|
||||
Sticker.cache[(set_id, set_access_hash)] = name
|
||||
|
||||
if len(Sticker.cache) > 250:
|
||||
for i in range(50):
|
||||
Sticker.cache.pop(next(iter(Sticker.cache)))
|
||||
|
||||
return name
|
||||
except StickersetInvalid:
|
||||
return None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user