mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
pyrofork: types: Wallpaper: Make document optional
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
300984bd13
commit
be6c2ff437
1 changed files with 5 additions and 3 deletions
|
|
@ -54,7 +54,7 @@ class Wallpaper(Object):
|
||||||
self,
|
self,
|
||||||
id: int,
|
id: int,
|
||||||
slug: str,
|
slug: str,
|
||||||
document: "types.Document",
|
document: "types.Document" = None,
|
||||||
is_creator: bool = None,
|
is_creator: bool = None,
|
||||||
is_default: bool = None,
|
is_default: bool = None,
|
||||||
is_pattern: bool = None,
|
is_pattern: bool = None,
|
||||||
|
|
@ -73,7 +73,9 @@ class Wallpaper(Object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client: "pyrogram.Client", wallpaper: "raw.base.WallPaper") -> "Wallpaper":
|
def _parse(client: "pyrogram.Client", wallpaper: "raw.base.WallPaper") -> "Wallpaper":
|
||||||
doc = wallpaper.document
|
doc = None
|
||||||
|
if not isinstance(wallpaper, raw.types.WallPaperNoFile):
|
||||||
|
doc = wallpaper.document
|
||||||
attributes = {type(i): i for i in doc.attributes}
|
attributes = {type(i): i for i in doc.attributes}
|
||||||
|
|
||||||
file_name = getattr(
|
file_name = getattr(
|
||||||
|
|
@ -84,7 +86,7 @@ class Wallpaper(Object):
|
||||||
return Wallpaper(
|
return Wallpaper(
|
||||||
id=wallpaper.id,
|
id=wallpaper.id,
|
||||||
slug=wallpaper.slug,
|
slug=wallpaper.slug,
|
||||||
document=types.Document._parse(client, doc, file_name),
|
document=types.Document._parse(client, doc, file_name) if doc is not None else None,
|
||||||
is_creator=getattr(wallpaper, "creator", None),
|
is_creator=getattr(wallpaper, "creator", None),
|
||||||
is_default=getattr(wallpaper, "default", None),
|
is_default=getattr(wallpaper, "default", None),
|
||||||
is_pattern=getattr(wallpaper, "pattern", None),
|
is_pattern=getattr(wallpaper, "pattern", None),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue