mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-24 07:51:44 +00:00
Add support for emoji status
This commit is contained in:
parent
2cd0f38602
commit
7a53c3da57
@ -385,6 +385,7 @@ def pyrogram_api():
|
|||||||
ChatJoiner
|
ChatJoiner
|
||||||
Dialog
|
Dialog
|
||||||
Restriction
|
Restriction
|
||||||
|
EmojiStatus
|
||||||
""",
|
""",
|
||||||
messages_media="""
|
messages_media="""
|
||||||
Messages & Media
|
Messages & Media
|
||||||
|
@ -30,6 +30,7 @@ from .chat_photo import ChatPhoto
|
|||||||
from .chat_preview import ChatPreview
|
from .chat_preview import ChatPreview
|
||||||
from .chat_privileges import ChatPrivileges
|
from .chat_privileges import ChatPrivileges
|
||||||
from .dialog import Dialog
|
from .dialog import Dialog
|
||||||
|
from .emoji_status import EmojiStatus
|
||||||
from .invite_link_importer import InviteLinkImporter
|
from .invite_link_importer import InviteLinkImporter
|
||||||
from .restriction import Restriction
|
from .restriction import Restriction
|
||||||
from .user import User
|
from .user import User
|
||||||
@ -59,5 +60,6 @@ __all__ = [
|
|||||||
"VideoChatScheduled",
|
"VideoChatScheduled",
|
||||||
"ChatJoinRequest",
|
"ChatJoinRequest",
|
||||||
"ChatPrivileges",
|
"ChatPrivileges",
|
||||||
"ChatJoiner"
|
"ChatJoiner",
|
||||||
|
"EmojiStatus"
|
||||||
]
|
]
|
||||||
|
67
pyrogram/types/user_and_chats/emoji_status.py
Normal file
67
pyrogram/types/user_and_chats/emoji_status.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# 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 datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
from pyrogram import utils
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class EmojiStatus(Object):
|
||||||
|
"""A user emoji status.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
custom_emoji_id (``int``):
|
||||||
|
Custom emoji id.
|
||||||
|
|
||||||
|
until_date (:py:obj:`~datetime.datetime`, *optional*):
|
||||||
|
Valid until date.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
client: "pyrogram.Client" = None,
|
||||||
|
custom_emoji_id: int,
|
||||||
|
until_date: Optional[datetime] = None
|
||||||
|
):
|
||||||
|
super().__init__(client)
|
||||||
|
|
||||||
|
self.custom_emoji_id = custom_emoji_id
|
||||||
|
self.until_date = until_date
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatus"]:
|
||||||
|
if isinstance(emoji_status, raw.types.EmojiStatusEmpty):
|
||||||
|
return None
|
||||||
|
|
||||||
|
if isinstance(emoji_status, raw.types.EmojiStatus):
|
||||||
|
return EmojiStatus(
|
||||||
|
client=client,
|
||||||
|
custom_emoji_id=emoji_status.document_id
|
||||||
|
)
|
||||||
|
|
||||||
|
if isinstance(emoji_status, raw.types.EmojiStatusUntil):
|
||||||
|
return EmojiStatus(
|
||||||
|
client=client,
|
||||||
|
custom_emoji_id=emoji_status.document_id,
|
||||||
|
until_date=utils.timestamp_to_datetime(emoji_status.until)
|
||||||
|
)
|
@ -121,6 +121,9 @@ class User(Object, Update):
|
|||||||
language_code (``str``, *optional*):
|
language_code (``str``, *optional*):
|
||||||
IETF language tag of the user's language.
|
IETF language tag of the user's language.
|
||||||
|
|
||||||
|
emoji_status (:obj:`~pyrogram.types.EmojiStatus`, *optional*):
|
||||||
|
Emoji status.
|
||||||
|
|
||||||
dc_id (``int``, *optional*):
|
dc_id (``int``, *optional*):
|
||||||
User's or bot's assigned DC (data center). Available only in case the user has set a public profile photo.
|
User's or bot's assigned DC (data center). Available only in case the user has set a public profile photo.
|
||||||
Note that this information is approximate; it is based on where Telegram stores a user profile pictures and
|
Note that this information is approximate; it is based on where Telegram stores a user profile pictures and
|
||||||
@ -167,6 +170,7 @@ class User(Object, Update):
|
|||||||
next_offline_date: datetime = None,
|
next_offline_date: datetime = None,
|
||||||
username: str = None,
|
username: str = None,
|
||||||
language_code: str = None,
|
language_code: str = None,
|
||||||
|
emoji_status: Optional[str] = None,
|
||||||
dc_id: int = None,
|
dc_id: int = None,
|
||||||
phone_number: str = None,
|
phone_number: str = None,
|
||||||
photo: "types.ChatPhoto" = None,
|
photo: "types.ChatPhoto" = None,
|
||||||
@ -193,6 +197,7 @@ class User(Object, Update):
|
|||||||
self.next_offline_date = next_offline_date
|
self.next_offline_date = next_offline_date
|
||||||
self.username = username
|
self.username = username
|
||||||
self.language_code = language_code
|
self.language_code = language_code
|
||||||
|
self.emoji_status = emoji_status
|
||||||
self.dc_id = dc_id
|
self.dc_id = dc_id
|
||||||
self.phone_number = phone_number
|
self.phone_number = phone_number
|
||||||
self.photo = photo
|
self.photo = photo
|
||||||
@ -229,6 +234,7 @@ class User(Object, Update):
|
|||||||
**User._parse_status(user.status, user.bot),
|
**User._parse_status(user.status, user.bot),
|
||||||
username=user.username,
|
username=user.username,
|
||||||
language_code=user.lang_code,
|
language_code=user.lang_code,
|
||||||
|
emoji_status=types.EmojiStatus._parse(client, user.emoji_status),
|
||||||
dc_id=getattr(user.photo, "dc_id", None),
|
dc_id=getattr(user.photo, "dc_id", None),
|
||||||
phone_number=user.phone,
|
phone_number=user.phone,
|
||||||
photo=types.ChatPhoto._parse(client, user.photo, user.id, user.access_hash),
|
photo=types.ChatPhoto._parse(client, user.photo, user.id, user.access_hash),
|
||||||
|
Loading…
Reference in New Issue
Block a user