mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-09-28 03:45:55 +00:00
Add birthday attribute to Chat class
This commit is contained in:
parent
68ffa1ffc2
commit
6b79475be4
@ -423,6 +423,7 @@ def pyrogram_api():
|
|||||||
categories = dict(
|
categories = dict(
|
||||||
users_chats="""
|
users_chats="""
|
||||||
Users & Chats
|
Users & Chats
|
||||||
|
Birthday
|
||||||
BusinessInfo
|
BusinessInfo
|
||||||
BusinessMessage
|
BusinessMessage
|
||||||
BusinessRecipients
|
BusinessRecipients
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from .birthday import Birthday
|
||||||
from .business_info import BusinessInfo
|
from .business_info import BusinessInfo
|
||||||
from .business_message import BusinessMessage
|
from .business_message import BusinessMessage
|
||||||
from .business_recipients import BusinessRecipients
|
from .business_recipients import BusinessRecipients
|
||||||
@ -49,6 +50,7 @@ from .video_chat_scheduled import VideoChatScheduled
|
|||||||
from .video_chat_started import VideoChatStarted
|
from .video_chat_started import VideoChatStarted
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
"Birthday",
|
||||||
"BusinessInfo",
|
"BusinessInfo",
|
||||||
"BusinessMessage",
|
"BusinessMessage",
|
||||||
"BusinessRecipients",
|
"BusinessRecipients",
|
||||||
|
62
pyrogram/types/user_and_chats/birthday.py
Normal file
62
pyrogram/types/user_and_chats/birthday.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram 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.
|
||||||
|
#
|
||||||
|
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from pyrogram import raw
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class Birthday(Object):
|
||||||
|
"""Birthday information of a user.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
day (``int``):
|
||||||
|
Birthday day.
|
||||||
|
|
||||||
|
month (``int``):
|
||||||
|
Birthday month.
|
||||||
|
|
||||||
|
year (``int``, *optional*):
|
||||||
|
Birthday year.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
day: int,
|
||||||
|
month: int,
|
||||||
|
year: int = None
|
||||||
|
|
||||||
|
):
|
||||||
|
self.day = day
|
||||||
|
self.month = month
|
||||||
|
self.year = year
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(
|
||||||
|
birthday: "raw.types.Birthday" = None
|
||||||
|
) -> Optional["Birthday"]:
|
||||||
|
if not birthday:
|
||||||
|
return
|
||||||
|
|
||||||
|
return Birthday(
|
||||||
|
day=birthday.day,
|
||||||
|
month=birthday.month,
|
||||||
|
year=getattr(birthday, "year", None)
|
||||||
|
)
|
@ -174,6 +174,9 @@ class Chat(Object):
|
|||||||
|
|
||||||
business_info (:obj:`~pyrogram.types.BusinessInfo`, *optional*):
|
business_info (:obj:`~pyrogram.types.BusinessInfo`, *optional*):
|
||||||
Business information of a chat.
|
Business information of a chat.
|
||||||
|
|
||||||
|
birthday (:obj:`~pyrogram.types.Birthday`, *optional*):
|
||||||
|
Information about user birthday.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -221,7 +224,8 @@ class Chat(Object):
|
|||||||
level: int = None,
|
level: int = None,
|
||||||
reply_color: "types.ChatColor" = None,
|
reply_color: "types.ChatColor" = None,
|
||||||
profile_color: "types.ChatColor" = None,
|
profile_color: "types.ChatColor" = None,
|
||||||
business_info: "types.BusinessInfo" = None
|
business_info: "types.BusinessInfo" = None,
|
||||||
|
birthday: "types.Birthday" = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
@ -267,6 +271,7 @@ class Chat(Object):
|
|||||||
self.reply_color = reply_color
|
self.reply_color = reply_color
|
||||||
self.profile_color = profile_color
|
self.profile_color = profile_color
|
||||||
self.business_info = business_info
|
self.business_info = business_info
|
||||||
|
self.birthday = birthday
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_user_chat(client, user: raw.types.User) -> "Chat":
|
def _parse_user_chat(client, user: raw.types.User) -> "Chat":
|
||||||
@ -390,6 +395,7 @@ class Chat(Object):
|
|||||||
parsed_chat.bio = full_user.about
|
parsed_chat.bio = full_user.about
|
||||||
parsed_chat.folder_id = getattr(full_user, "folder_id", None)
|
parsed_chat.folder_id = getattr(full_user, "folder_id", None)
|
||||||
parsed_chat.business_info = types.BusinessInfo._parse(client, full_user, users)
|
parsed_chat.business_info = types.BusinessInfo._parse(client, full_user, users)
|
||||||
|
parsed_chat.birthday = types.Birthday._parse(getattr(full_user, "birthday", None))
|
||||||
|
|
||||||
if full_user.pinned_msg_id:
|
if full_user.pinned_msg_id:
|
||||||
parsed_chat.pinned_message = await client.get_messages(
|
parsed_chat.pinned_message = await client.get_messages(
|
||||||
|
@ -164,10 +164,10 @@ class User(Object, Update):
|
|||||||
``user.mention("another name")`` for a custom name. To choose a different style
|
``user.mention("another name")`` for a custom name. To choose a different style
|
||||||
("html" or "md"/"markdown") use ``user.mention(style="md")``.
|
("html" or "md"/"markdown") use ``user.mention(style="md")``.
|
||||||
|
|
||||||
reply_color (:obj:`~pyrogram.types.ChatColor`, *optional*)
|
reply_color (:obj:`~pyrogram.types.ChatColor`, *optional*):
|
||||||
Chat reply color.
|
Chat reply color.
|
||||||
|
|
||||||
profile_color (:obj:`~pyrogram.types.ChatColor`, *optional*)
|
profile_color (:obj:`~pyrogram.types.ChatColor`, *optional*):
|
||||||
Chat profile color.
|
Chat profile color.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user