2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 12:57:52 +00:00

Rename PyrogramType to Object

This commit is contained in:
Dan 2019-06-03 16:56:37 +02:00
parent d5517f4d5f
commit 9a44c79a82
66 changed files with 168 additions and 159 deletions

View File

@ -22,12 +22,12 @@ import pyrogram
from pyrogram.api import types
from .inline_query_result import InlineQueryResult
from ..messages_and_media import Location
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..update import Update
from ..user_and_chats import User
class InlineQuery(PyrogramType, Update):
class InlineQuery(Object, Update):
"""An incoming inline query.
When the user sends an empty query, your bot could return some default or trending results.

View File

@ -16,7 +16,7 @@
# 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 ..pyrogram_type import PyrogramType
from ..object import Object
"""- :obj:`InlineQueryResultCachedAudio`
- :obj:`InlineQueryResultCachedDocument`
@ -39,7 +39,7 @@ from ..pyrogram_type import PyrogramType
- :obj:`InlineQueryResultVoice`"""
class InlineQueryResult(PyrogramType):
class InlineQueryResult(Object):
"""One result of an inline query.
Pyrogram currently supports results of the following 20 types:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultAudio(PyrogramType):
class InlineQueryResultAudio(Object):
"""Represents a link to an mp3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
Attributes:

View File

@ -23,10 +23,10 @@ from pyrogram.api import types
from pyrogram.errors import FileIdInvalid
from pyrogram.client.ext import utils, BaseClient
from pyrogram.client.style import HTML, Markdown
from pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultCachedAudio(PyrogramType):
class InlineQueryResultCachedAudio(Object):
"""Represents a link to an audio file stored on the Telegram servers.
By default, this audio file will be sent by the user. Alternatively, you can use *input_message_content* to send a
message with the specified content instead of the audio.

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultCachedDocument(PyrogramType):
class InlineQueryResultCachedDocument(Object):
"""Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultCachedGif(PyrogramType):
class InlineQueryResultCachedGif(Object):
"""Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultCachedMpeg4Gif(PyrogramType):
class InlineQueryResultCachedMpeg4Gif(Object):
"""Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultCachedPhoto(PyrogramType):
class InlineQueryResultCachedPhoto(Object):
"""Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultCachedSticker(PyrogramType):
class InlineQueryResultCachedSticker(Object):
"""Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultCachedVideo(PyrogramType):
class InlineQueryResultCachedVideo(Object):
"""Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultCachedVoice(PyrogramType):
class InlineQueryResultCachedVoice(Object):
"""Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultContact(PyrogramType):
class InlineQueryResultContact(Object):
"""Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultDocument(PyrogramType):
class InlineQueryResultDocument(Object):
"""Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultGame(PyrogramType):
class InlineQueryResultGame(Object):
"""Represents a Game.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultGif(PyrogramType):
class InlineQueryResultGif(Object):
"""Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultLocation(PyrogramType):
class InlineQueryResultLocation(Object):
"""Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultMpeg4Gif(PyrogramType):
class InlineQueryResultMpeg4Gif(Object):
"""Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
Attributes:

View File

@ -18,10 +18,10 @@
from pyrogram.api import types
from pyrogram.client.style import HTML, Markdown
from pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultPhoto(PyrogramType):
class InlineQueryResultPhoto(Object):
"""Represents a link to a photo. By default, this photo will be sent by the user with optional caption.
Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultVenue(PyrogramType):
class InlineQueryResultVenue(Object):
"""Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultVideo(PyrogramType):
class InlineQueryResultVideo(Object):
"""Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
class InlineQueryResultVoice(PyrogramType):
class InlineQueryResultVoice(Object):
"""Represents a link to a voice recording in an .ogg container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message.
Attributes:

View File

@ -16,10 +16,10 @@
# 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 ..pyrogram_type import PyrogramType
from ..object import Object
class InputMedia(PyrogramType):
class InputMedia(Object):
"""Content of a media message to be sent.
It should be one of:

View File

@ -18,10 +18,10 @@
from pyrogram.api.types import InputPhoneContact as RawInputPhoneContact
from pyrogram.session.internals import MsgId
from ..pyrogram_type import PyrogramType
from ..object import Object
class InputPhoneContact(PyrogramType):
class InputPhoneContact(Object):
"""A Phone Contact to be added in your Telegram address book.
It is intended to be used with :meth:`~Client.add_contacts() <pyrogram.Client.add_contacts>`

View File

@ -16,14 +16,14 @@
# 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 ..pyrogram_type import PyrogramType
from ..object import Object
"""- :obj:`InputLocationMessageContent`
- :obj:`InputVenueMessageContent`
- :obj:`InputContactMessageContent`"""
class InputMessageContent(PyrogramType):
class InputMessageContent(Object):
"""Content of a message to be sent as a result of an inline query.
Pyrogram currently supports the following 4 types:

View File

@ -16,10 +16,10 @@
# 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 ..pyrogram_type import PyrogramType
from ..object import Object
class CallbackGame(PyrogramType):
class CallbackGame(Object):
"""Placeholder, currently holds no information.
Use BotFather to set up your game.

View File

@ -22,12 +22,12 @@ from typing import Union
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..update import Update
from ..user_and_chats import User
class CallbackQuery(PyrogramType, Update):
class CallbackQuery(Object, Update):
"""An incoming callback query from a callback button in an inline keyboard.
If the button that originated the query was attached to a message sent by the bot, the field *message*

View File

@ -17,10 +17,10 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from pyrogram.api.types import ReplyKeyboardForceReply
from ..pyrogram_type import PyrogramType
from ..object import Object
class ForceReply(PyrogramType):
class ForceReply(Object):
"""Object used to force clients to show a reply interface.
Upon receiving a message with this object, Telegram clients will display a reply interface to the user.

View File

@ -19,11 +19,11 @@
import pyrogram
from pyrogram.api import types
from pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
from pyrogram.client.types.user_and_chats import User
class GameHighScore(PyrogramType):
class GameHighScore(Object):
"""One row of the high scores table for a game.
Parameters:

View File

@ -20,11 +20,11 @@ from typing import List
import pyrogram
from pyrogram.api import types
from pyrogram.client.types.pyrogram_type import PyrogramType
from pyrogram.client.types.object import Object
from .game_high_score import GameHighScore
class GameHighScores(PyrogramType):
class GameHighScores(Object):
"""The high scores table for a game.
Parameters:

View File

@ -23,10 +23,10 @@ from pyrogram.api.types import (
KeyboardButtonSwitchInline, KeyboardButtonGame
)
from .callback_game import CallbackGame
from ..pyrogram_type import PyrogramType
from ..object import Object
class InlineKeyboardButton(PyrogramType):
class InlineKeyboardButton(Object):
"""One button of an inline keyboard.
You must use exactly one of the optional fields.

View File

@ -20,10 +20,10 @@ from typing import List
from pyrogram.api.types import ReplyInlineMarkup, KeyboardButtonRow
from . import InlineKeyboardButton
from ..pyrogram_type import PyrogramType
from ..object import Object
class InlineKeyboardMarkup(PyrogramType):
class InlineKeyboardMarkup(Object):
"""An inline keyboard that appears right next to the message it belongs to.
Parameters:

View File

@ -18,10 +18,10 @@
from pyrogram.api.types import KeyboardButton as RawKeyboardButton
from pyrogram.api.types import KeyboardButtonRequestPhone, KeyboardButtonRequestGeoLocation
from ..pyrogram_type import PyrogramType
from ..object import Object
class KeyboardButton(PyrogramType):
class KeyboardButton(Object):
"""One button of the reply keyboard.
For simple text buttons String can be used instead of this object to specify text of the button.
Optional fields are mutually exclusive.

View File

@ -21,10 +21,10 @@ from typing import List, Union
from pyrogram.api.types import KeyboardButtonRow
from pyrogram.api.types import ReplyKeyboardMarkup as RawReplyKeyboardMarkup
from . import KeyboardButton
from ..pyrogram_type import PyrogramType
from ..object import Object
class ReplyKeyboardMarkup(PyrogramType):
class ReplyKeyboardMarkup(Object):
"""A custom keyboard with reply options.
Parameters:

View File

@ -17,10 +17,10 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from pyrogram.api.types import ReplyKeyboardHide
from ..pyrogram_type import PyrogramType
from ..object import Object
class ReplyKeyboardRemove(PyrogramType):
class ReplyKeyboardRemove(Object):
"""Object used to tell clients to remove a bot keyboard.
Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display

View File

@ -16,17 +16,17 @@
# 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 .pyrogram_type import PyrogramType
from .object import Object
class PyrogramList(list):
class List(list):
__slots__ = []
def __str__(self):
# noinspection PyCallByClass
return PyrogramType.__str__(self)
return Object.__str__(self)
def __repr__(self):
return "pyrogram.client.types.pyrogram_list.PyrogramList([{}])".format(
",".join(PyrogramType.__repr__(i) for i in self)
",".join(Object.__repr__(i) for i in self)
)

View File

@ -22,11 +22,11 @@ from typing import List
import pyrogram
from pyrogram.api import types
from .thumbnail import Thumbnail
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class Animation(PyrogramType):
class Animation(Object):
"""An animation file (GIF or H.264/MPEG-4 AVC video without sound).
Parameters:

View File

@ -22,11 +22,11 @@ from typing import List
import pyrogram
from pyrogram.api import types
from .thumbnail import Thumbnail
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class Audio(PyrogramType):
class Audio(Object):
"""An audio file to be treated as music by the Telegram clients.
Parameters:

View File

@ -19,10 +19,10 @@
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
class Contact(PyrogramType):
class Contact(Object):
"""A phone contact.
Parameters:

View File

@ -22,11 +22,11 @@ from typing import List
import pyrogram
from pyrogram.api import types
from .thumbnail import Thumbnail
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class Document(PyrogramType):
class Document(Object):
"""A generic file (as opposed to photos, voice messages, audio files, ...).
Parameters:

View File

@ -20,10 +20,10 @@ import pyrogram
from pyrogram.api import types
from .animation import Animation
from .photo import Photo
from ..pyrogram_type import PyrogramType
from ..object import Object
class Game(PyrogramType):
class Game(Object):
"""A game.
Use BotFather to create and edit games, their short names will act as unique identifiers.

View File

@ -19,10 +19,10 @@
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
class Location(PyrogramType):
class Location(Object):
"""A point on the map.
Parameters:

View File

@ -27,7 +27,7 @@ from .contact import Contact
from .location import Location
from .message_entity import MessageEntity
from ..messages_and_media.photo import Photo
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..update import Update
from ..user_and_chats.chat import Chat
from ..user_and_chats.user import User
@ -59,7 +59,7 @@ class Str(str):
return self._client.html.unparse(self, self._entities)
class Message(PyrogramType, Update):
class Message(Object, Update):
"""A message.
Parameters:

View File

@ -19,11 +19,11 @@
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..user_and_chats.user import User
class MessageEntity(PyrogramType):
class MessageEntity(Object):
"""One special entity in a text message.
For example, hashtags, usernames, URLs, etc.

View File

@ -21,12 +21,12 @@ from typing import List, Union
import pyrogram
from pyrogram.api import types
from .message import Message
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..update import Update
from ..user_and_chats import Chat
class Messages(PyrogramType, Update):
class Messages(Object, Update):
"""Contains a chat's messages.
Parameters:

View File

@ -22,11 +22,11 @@ from typing import List
import pyrogram
from pyrogram.api import types
from .thumbnail import Thumbnail
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class Photo(PyrogramType):
class Photo(Object):
"""A Photo.
Parameters:

View File

@ -20,10 +20,10 @@ from typing import List
import pyrogram
from .photo import Photo
from ..pyrogram_type import PyrogramType
from ..object import Object
class Photos(PyrogramType):
class Photos(Object):
"""Contains a user's profile pictures.
Parameters:

View File

@ -21,11 +21,11 @@ from typing import List, Union
import pyrogram
from pyrogram.api import types
from .poll_option import PollOption
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..update import Update
class Poll(PyrogramType, Update):
class Poll(Object, Update):
"""A Poll.
Parameters:

View File

@ -17,10 +17,10 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from ..pyrogram_type import PyrogramType
from ..object import Object
class PollOption(PyrogramType):
class PollOption(Object):
"""Contains information about one answer option in a poll.
Parameters:

View File

@ -24,11 +24,11 @@ import pyrogram
from pyrogram.api import types, functions
from pyrogram.errors import StickersetInvalid
from .thumbnail import Thumbnail
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class Sticker(PyrogramType):
class Sticker(Object):
"""A sticker.
Parameters:

View File

@ -18,10 +18,10 @@
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
class StrippedThumbnail(PyrogramType):
class StrippedThumbnail(Object):
"""A stripped thumbnail
Parameters:

View File

@ -23,10 +23,10 @@ import pyrogram
from pyrogram.api import types
from pyrogram.client.ext.utils import encode
from .stripped_thumbnail import StrippedThumbnail
from ..pyrogram_type import PyrogramType
from ..object import Object
class Thumbnail(PyrogramType):
class Thumbnail(Object):
"""One size of a photo or a file/sticker thumbnail.
Parameters:

View File

@ -19,10 +19,10 @@
import pyrogram
from pyrogram.api import types
from .location import Location
from ..pyrogram_type import PyrogramType
from ..object import Object
class Venue(PyrogramType):
class Venue(Object):
"""A venue.
Parameters:

View File

@ -22,11 +22,11 @@ from typing import List
import pyrogram
from pyrogram.api import types
from .thumbnail import Thumbnail
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class Video(PyrogramType):
class Video(Object):
"""A video file.
Parameters:

View File

@ -22,11 +22,11 @@ from typing import List
import pyrogram
from pyrogram.api import types
from .thumbnail import Thumbnail
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class VideoNote(PyrogramType):
class VideoNote(Object):
"""A video note.
Parameters:

View File

@ -20,11 +20,11 @@ from struct import pack
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class Voice(PyrogramType):
class Voice(Object):
"""A voice note.
Parameters:

View File

@ -23,7 +23,12 @@ from json import dumps
import pyrogram
class PyrogramType:
class Meta(type, metaclass=type("", (type,), {"__str__": lambda _: "~hi"})):
def __str__(self):
return "<class 'pyrogram.{}'>".format(self.__name__)
class Object(metaclass=Meta):
__slots__ = ["_client"]
def __init__(self, client: "pyrogram.BaseClient" = None):
@ -32,35 +37,26 @@ class PyrogramType:
if self._client is None:
del self._client
def __eq__(self, other: "PyrogramType") -> bool:
for attr in self.__slots__:
try:
if getattr(self, attr) != getattr(other, attr):
return False
except AttributeError:
return False
@staticmethod
def default(obj: "Object"):
if isinstance(obj, bytes):
return repr(obj)
return True
return OrderedDict(
[("_", "pyrogram." + obj.__class__.__name__)]
+ [
(attr, "*" * len(getattr(obj, attr)))
if attr == "phone_number"
else (attr, str(datetime.fromtimestamp(getattr(obj, attr))))
if attr.endswith("date")
else (attr, getattr(obj, attr))
for attr in obj.__slots__
if getattr(obj, attr) is not None
]
)
def __str__(self) -> str:
def default(obj: PyrogramType):
try:
return OrderedDict(
[("_", "pyrogram." + obj.__class__.__name__)]
+ [
(attr, "*" * len(getattr(obj, attr)))
if attr == "phone_number"
else (attr, str(datetime.fromtimestamp(getattr(obj, attr))))
if attr.endswith("date")
else (attr, getattr(obj, attr))
for attr in obj.__slots__
if getattr(obj, attr) is not None
]
)
except AttributeError:
return repr(obj)
return dumps(self, indent=4, default=default, ensure_ascii=False)
return dumps(self, indent=4, default=Object.default, ensure_ascii=False)
def __repr__(self) -> str:
return "pyrogram.{}({})".format(
@ -72,5 +68,18 @@ class PyrogramType:
)
)
def __eq__(self, other: "Object") -> bool:
for attr in self.__slots__:
try:
if getattr(self, attr) != getattr(other, attr):
return False
except AttributeError:
return False
return True
def __getitem__(self, item):
return getattr(self, item)
def __setitem__(self, key, value):
setattr(self, key, value)

View File

@ -22,10 +22,10 @@ import pyrogram
from pyrogram.api import types
from .chat_permissions import ChatPermissions
from .chat_photo import ChatPhoto
from ..pyrogram_type import PyrogramType
from ..object import Object
class Chat(PyrogramType):
class Chat(Object):
"""A chat.
Parameters:

View File

@ -19,10 +19,10 @@
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
class ChatMember(PyrogramType):
class ChatMember(Object):
"""Contains information about one member of a chat.
Parameters:

View File

@ -21,10 +21,10 @@ from typing import List
import pyrogram
from pyrogram.api import types
from .chat_member import ChatMember
from ..pyrogram_type import PyrogramType
from ..object import Object
class ChatMembers(PyrogramType):
class ChatMembers(Object):
"""Contains information about the members list of a chat.
Parameters:

View File

@ -19,10 +19,10 @@
from typing import Union
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
class ChatPermissions(PyrogramType):
class ChatPermissions(Object):
"""A chat default permissions and a single member permissions within a chat.
Some permissions make sense depending on the context: default chat permissions, restricted/kicked member or

View File

@ -20,11 +20,11 @@ from struct import pack
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
from ...ext.utils import encode
class ChatPhoto(PyrogramType):
class ChatPhoto(Object):
"""A chat photo.
Parameters:

View File

@ -21,11 +21,11 @@ from typing import List
import pyrogram
from pyrogram.api import types
from .chat_photo import ChatPhoto
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..user_and_chats.user import User
class ChatPreview(PyrogramType):
class ChatPreview(Object):
"""A chat preview.
Parameters:

View File

@ -19,11 +19,11 @@
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..user_and_chats import Chat
class Dialog(PyrogramType):
class Dialog(Object):
"""A user's dialog.
Parameters:

View File

@ -22,10 +22,10 @@ import pyrogram
from pyrogram.api import types
from .dialog import Dialog
from ..messages_and_media import Message
from ..pyrogram_type import PyrogramType
from ..object import Object
class Dialogs(PyrogramType):
class Dialogs(Object):
"""Contains a user's dialogs chunk.
Parameters:

View File

@ -20,10 +20,10 @@ import pyrogram
from pyrogram.api import types
from .chat_photo import ChatPhoto
from .user_status import UserStatus
from ..pyrogram_type import PyrogramType
from ..object import Object
class User(PyrogramType):
class User(Object):
"""A Telegram user or bot.
Parameters:

View File

@ -19,11 +19,11 @@
import pyrogram
from pyrogram.api import types
from ..pyrogram_type import PyrogramType
from ..object import Object
from ..update import Update
class UserStatus(PyrogramType, Update):
class UserStatus(Object, Update):
"""A User status (Last Seen privacy).
.. note::