Merge pull request #107 from TheRealMal/main

fix: attributes parsing
This commit is contained in:
Yasir Aris M 2025-01-06 19:18:29 +07:00 committed by GitHub
commit 9e101ef4d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View file

@ -361,11 +361,11 @@ class StarGift(Object):
symbol = None
for key, value in attributes.items():
if isinstance(key, raw.types.StarGiftAttributeModel):
if key is raw.types.StarGiftAttributeModel:
model = await types.StarGiftAttribute._parse(client, value)
elif isinstance(key, raw.types.StarGiftAttributeBackdrop):
backdrop = await types.StarGiftAttribute._parse(client, value)
elif isinstance(key, raw.types.StarGiftAttributePattern):
elif key is raw.types.StarGiftAttributeBackdrop:
backdrop = await types.StarGiftAttribute._parse(client, value, True)
elif key is raw.types.StarGiftAttributePattern:
symbol = await types.StarGiftAttribute._parse(client, value)
return StarGift(

View file

@ -67,14 +67,18 @@ class StarGiftAttribute(Object):
async def _parse(
client,
attr: "raw.base.StarGiftAttribute",
backdrop: bool = False,
) -> "StarGiftAttribute":
doc = attr.document
attributes = {type(i): i for i in doc.attributes}
sticker = None
if not backdrop:
doc = attr.document
attributes = {type(i): i for i in doc.attributes}
sticker = await types.Sticker._parse(client, doc, attributes)
return StarGiftAttribute(
name=attr.name,
type=enums.StarGiftAttributeType(type(attr)),
sticker=await types.Sticker._parse(client, doc, attributes),
sticker=sticker,
rarity=attr.rarity_permille,
client=client
)