pyrofork: types: Wallpaper: Make document optional

Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
wulan17 2025-06-09 19:30:04 +07:00
parent 300984bd13
commit be6c2ff437
No known key found for this signature in database
GPG key ID: 737814D4B5FF0420

View file

@ -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,6 +73,8 @@ 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 = None
if not isinstance(wallpaper, raw.types.WallPaperNoFile):
doc = wallpaper.document doc = wallpaper.document
attributes = {type(i): i for i in doc.attributes} attributes = {type(i): i for i in doc.attributes}
@ -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),