mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-06 15:14:52 +00:00
fix: attributes parsing
This commit is contained in:
parent
8ceec293ba
commit
a04c91db31
2 changed files with 11 additions and 7 deletions
|
|
@ -361,11 +361,11 @@ class StarGift(Object):
|
||||||
symbol = None
|
symbol = None
|
||||||
|
|
||||||
for key, value in attributes.items():
|
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)
|
model = await types.StarGiftAttribute._parse(client, value)
|
||||||
elif isinstance(key, raw.types.StarGiftAttributeBackdrop):
|
elif key is raw.types.StarGiftAttributeBackdrop:
|
||||||
backdrop = await types.StarGiftAttribute._parse(client, value)
|
backdrop = await types.StarGiftAttribute._parse(client, value, True)
|
||||||
elif isinstance(key, raw.types.StarGiftAttributePattern):
|
elif key is raw.types.StarGiftAttributePattern:
|
||||||
symbol = await types.StarGiftAttribute._parse(client, value)
|
symbol = await types.StarGiftAttribute._parse(client, value)
|
||||||
|
|
||||||
return StarGift(
|
return StarGift(
|
||||||
|
|
|
||||||
|
|
@ -67,14 +67,18 @@ class StarGiftAttribute(Object):
|
||||||
async def _parse(
|
async def _parse(
|
||||||
client,
|
client,
|
||||||
attr: "raw.base.StarGiftAttribute",
|
attr: "raw.base.StarGiftAttribute",
|
||||||
|
backdrop: bool = False,
|
||||||
) -> "StarGiftAttribute":
|
) -> "StarGiftAttribute":
|
||||||
|
sticker = None
|
||||||
|
if not backdrop:
|
||||||
doc = attr.document
|
doc = attr.document
|
||||||
attributes = {type(i): i for i in doc.attributes}
|
attributes = {type(i): i for i in doc.attributes}
|
||||||
|
sticker = await types.Sticker._parse(client, doc, attributes)
|
||||||
|
|
||||||
return StarGiftAttribute(
|
return StarGiftAttribute(
|
||||||
name=attr.name,
|
name=attr.name,
|
||||||
type=enums.StarGiftAttributeType(type(attr)),
|
type=enums.StarGiftAttributeType(type(attr)),
|
||||||
sticker=await types.Sticker._parse(client, doc, attributes),
|
sticker=sticker,
|
||||||
rarity=attr.rarity_permille,
|
rarity=attr.rarity_permille,
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue