From 8ca9045ebc3bfd622c9c847455b19fa9f88ab45e Mon Sep 17 00:00:00 2001 From: wulan17 Date: Sat, 6 Apr 2024 20:19:51 +0700 Subject: [PATCH] Pyrofork: Add update_birthday method Signed-off-by: wulan17 --- compiler/docs/compiler.py | 1 + pyrogram/methods/users/__init__.py | 2 + pyrogram/methods/users/update_birthday.py | 59 +++++++++++++++++++++++ pyrogram/types/user_and_chats/birthday.py | 7 +++ 4 files changed, 69 insertions(+) create mode 100644 pyrogram/methods/users/update_birthday.py diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index c0c6558d..3894590d 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -277,6 +277,7 @@ def pyrogram_api(): set_profile_photo delete_profile_photos set_username + update_birthday update_profile block_user unblock_user diff --git a/pyrogram/methods/users/__init__.py b/pyrogram/methods/users/__init__.py index d4811af4..feb96a9b 100644 --- a/pyrogram/methods/users/__init__.py +++ b/pyrogram/methods/users/__init__.py @@ -38,6 +38,7 @@ from .set_emoji_status import SetEmojiStatus from .set_profile_photo import SetProfilePhoto from .set_username import SetUsername from .unblock_user import UnblockUser +from .update_birthday import UpdateBirthday from .update_profile import UpdateProfile @@ -60,6 +61,7 @@ class Users( SetUsername, GetChatPhotosCount, UnblockUser, + UpdateBirthday, UpdateProfile, GetDefaultEmojiStatuses, SetEmojiStatus, diff --git a/pyrogram/methods/users/update_birthday.py b/pyrogram/methods/users/update_birthday.py new file mode 100644 index 00000000..bb511aa6 --- /dev/null +++ b/pyrogram/methods/users/update_birthday.py @@ -0,0 +1,59 @@ +# Pyrofork - Telegram MTProto API Client Library for Python +# Copyright (C) 2022-present Mayuri-Chan +# +# This file is part of Pyrofork. +# +# Pyrofork is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrofork is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrofork. If not, see . + +import pyrogram +from pyrogram import raw, types + + +class UpdateBirthday: + async def update_birthday( + self: "pyrogram.Client", + day: int, + month: int, + year: int = None + ) -> bool: + """Update your birthday details. + + .. include:: /_includes/usable-by/users.rst + + Parameters: + day (``int``): + Day of birth. + + month (``int``): + Month of birth. + + year (``int``, *optional*): + Year of birth. + + Returns: + ``bool``: True on success. + + Example: + .. code-block:: python + + # Update your birthday to 1st January 2000 + await app.update_profile(day=1, month=1, year=2000) + """ + birthday = types.Birthday(day=day, month=month, year=year) + birthday = await birthday.write() + + r = await self.invoke(raw.functions.account.UpdateBirthday(birthday=birthday)) + if r: + return True + return False diff --git a/pyrogram/types/user_and_chats/birthday.py b/pyrogram/types/user_and_chats/birthday.py index 7c5d83ed..0f87981d 100644 --- a/pyrogram/types/user_and_chats/birthday.py +++ b/pyrogram/types/user_and_chats/birthday.py @@ -55,3 +55,10 @@ class Birthday(Object): month=birthday.month, year=birthday.year ) + + async def write(self) -> "raw.types.Birthday": + return raw.types.Birthday( + day=self.day, + month=self.month, + year=self.year + )