Skip to content

Commit

Permalink
Pyrofork: Add update_birthday method
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Apr 6, 2024
1 parent 20ad2c8 commit 06f6233
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def get_title_list(s: str) -> list:
set_profile_photo
delete_profile_photos
set_username
update_birthday
update_profile
block_user
unblock_user
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/users/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
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


Expand All @@ -60,6 +61,7 @@ class Users(
SetUsername,
GetChatPhotosCount,
UnblockUser,
UpdateBirthday,
UpdateProfile,
GetDefaultEmojiStatuses,
SetEmojiStatus,
Expand Down
59 changes: 59 additions & 0 deletions pyrogram/methods/users/update_birthday.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/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 <http://www.gnu.org/licenses/>.

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
7 changes: 7 additions & 0 deletions pyrogram/types/user_and_chats/birthday.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ def _parse(birthday: "raw.types.Birthday" = None) -> "Birthday":
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
)

0 comments on commit 06f6233

Please sign in to comment.