Update upgraded gift regex

Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
KurimuzonAkuma 2025-05-08 16:21:42 +03:00 committed by wulan17
parent 9ff40dc90b
commit b65279046e
No known key found for this signature in database
GPG key ID: 737814D4B5FF0420
3 changed files with 4 additions and 3 deletions

View file

@ -231,6 +231,7 @@ class Client(Methods):
PARENT_DIR = Path(sys.argv[0]).parent PARENT_DIR = Path(sys.argv[0]).parent
INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:joinchat/|\+))([\w-]+)$") INVITE_LINK_RE = re.compile(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:joinchat/|\+))([\w-]+)$")
UPGRADED_GIFT_RE = re.compile(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:nft/|\+))([\w-]+)$")
WORKERS = min(32, (os.cpu_count() or 0) + 4) # os.cpu_count() can be None WORKERS = min(32, (os.cpu_count() or 0) + 4) # os.cpu_count() can be None
WORKDIR = PARENT_DIR WORKDIR = PARENT_DIR

View file

@ -47,7 +47,7 @@ class GetUpgradedGift:
# Get information about upgraded gift by slug # Get information about upgraded gift by slug
gift = await client.get_upgraded_gift("SignetRing-903") gift = await client.get_upgraded_gift("SignetRing-903")
""" """
match = re.match(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:nft/|\+))([\w-]+)$", link) match = self.UPGRADED_GIFT_RE.match(link)
if match: if match:
slug = match.group(1) slug = match.group(1)

View file

@ -62,8 +62,8 @@ class SetPinnedGifts:
if not isinstance(gift, str): if not isinstance(gift, str):
raise ValueError(f"gift id has to be str, but {type(gift)} was provided") raise ValueError(f"gift id has to be str, but {type(gift)} was provided")
saved_gift_match = re.match(r"^(-\d+)_(\d+)$", gift) saved_gift_match = re.match(r"^(\d+)_(\d+)$", str(gift))
slug_match = self.UPGRADED_GIFT_RE.match(gift) slug_match = self.UPGRADED_GIFT_RE.match(str(gift))
if saved_gift_match: if saved_gift_match:
stargifts.append( stargifts.append(