Remove __slots__ from Pyrogram types
This commit is contained in:
parent
aa135ea457
commit
67112a34e9
@ -25,7 +25,5 @@ class CallbackGame(Object):
|
||||
Use BotFather to set up your game.
|
||||
"""
|
||||
|
||||
__slots__ = []
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
@ -61,8 +61,6 @@ class CallbackQuery(Object, Update):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ["id", "from_user", "chat_instance", "message", "inline_message_id", "data", "game_short_name"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -37,8 +37,6 @@ class ForceReply(Object):
|
||||
2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
|
||||
"""
|
||||
|
||||
__slots__ = ["selective"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
selective: bool = None
|
||||
|
@ -37,8 +37,6 @@ class GameHighScore(Object):
|
||||
Position in high score table for the game.
|
||||
"""
|
||||
|
||||
__slots__ = ["user", "score", "position"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -59,10 +59,6 @@ class InlineKeyboardButton(Object):
|
||||
|
||||
# TODO: Add callback_game and pay fields
|
||||
|
||||
__slots__ = [
|
||||
"text", "url", "callback_data", "switch_inline_query", "switch_inline_query_current_chat", "callback_game"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
text: str,
|
||||
|
@ -32,8 +32,6 @@ class InlineKeyboardMarkup(Object):
|
||||
List of button rows, each represented by a List of InlineKeyboardButton objects.
|
||||
"""
|
||||
|
||||
__slots__ = ["inline_keyboard"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
inline_keyboard: List[List[InlineKeyboardButton]]
|
||||
|
@ -41,8 +41,6 @@ class KeyboardButton(Object):
|
||||
Available in private chats only.
|
||||
"""
|
||||
|
||||
__slots__ = ["text", "request_contact", "request_location"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
text: str,
|
||||
|
@ -50,8 +50,6 @@ class ReplyKeyboardMarkup(Object):
|
||||
select the new language. Other users in the group don't see the keyboard.
|
||||
"""
|
||||
|
||||
__slots__ = ["keyboard", "resize_keyboard", "one_time_keyboard", "selective"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
keyboard: List[List[Union[KeyboardButton, str]]],
|
||||
|
@ -38,8 +38,6 @@ class ReplyKeyboardRemove(Object):
|
||||
keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.
|
||||
"""
|
||||
|
||||
__slots__ = ["selective"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
selective: bool = None
|
||||
|
@ -48,7 +48,6 @@ class InlineQuery(Object, Update):
|
||||
location (:obj:`Location`. *optional*):
|
||||
Sender location, only for bots that request user location.
|
||||
"""
|
||||
__slots__ = ["id", "from_user", "query", "offset", "location"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -53,8 +53,6 @@ class InlineQueryResult(Object):
|
||||
- :obj:`InlineQueryResultAnimation`
|
||||
"""
|
||||
|
||||
__slots__ = ["type", "id", "input_message_content", "reply_markup"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
type: str,
|
||||
|
@ -68,11 +68,6 @@ class InlineQueryResultAnimation(InlineQueryResult):
|
||||
Content of the message to be sent instead of the photo.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
"animation_url", "thumb_url", "title", "description", "caption", "parse_mode", "reply_markup",
|
||||
"input_message_content"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
animation_url: str,
|
||||
|
@ -49,8 +49,6 @@ class InlineQueryResultArticle(InlineQueryResult):
|
||||
Inline keyboard attached to the message.
|
||||
"""
|
||||
|
||||
__slots__ = ["title", "url", "description", "thumb_url"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
title: str,
|
||||
|
@ -68,11 +68,6 @@ class InlineQueryResultPhoto(InlineQueryResult):
|
||||
Content of the message to be sent instead of the photo.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
"photo_url", "thumb_url", "title", "description", "caption", "parse_mode", "reply_markup",
|
||||
"input_message_content"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
photo_url: str,
|
||||
|
@ -30,7 +30,6 @@ class InputMedia(Object):
|
||||
- :obj:`InputMediaPhoto`
|
||||
- :obj:`InputMediaVideo`
|
||||
"""
|
||||
__slots__ = ["media", "caption", "parse_mode"]
|
||||
|
||||
def __init__(self, media: str, caption: str, parse_mode: str):
|
||||
super().__init__()
|
||||
|
@ -56,8 +56,6 @@ class InputMediaAnimation(InputMedia):
|
||||
Animation duration.
|
||||
"""
|
||||
|
||||
__slots__ = ["thumb", "width", "height", "duration"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
media: str,
|
||||
|
@ -58,8 +58,6 @@ class InputMediaAudio(InputMedia):
|
||||
Title of the audio
|
||||
"""
|
||||
|
||||
__slots__ = ["thumb", "duration", "performer", "title"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
media: str,
|
||||
|
@ -47,8 +47,6 @@ class InputMediaDocument(InputMedia):
|
||||
Pass None to completely disable style parsing.
|
||||
"""
|
||||
|
||||
__slots__ = ["thumb"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
media: str,
|
||||
|
@ -43,8 +43,6 @@ class InputMediaPhoto(InputMedia):
|
||||
Pass None to completely disable style parsing.
|
||||
"""
|
||||
|
||||
__slots__ = []
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
media: str,
|
||||
|
@ -61,8 +61,6 @@ class InputMediaVideo(InputMedia):
|
||||
Pass True, if the uploaded video is suitable for streaming.
|
||||
"""
|
||||
|
||||
__slots__ = ["thumb", "width", "height", "duration", "supports_streaming"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
media: str,
|
||||
|
@ -37,8 +37,6 @@ class InputPhoneContact(Object):
|
||||
Contact's last name
|
||||
"""
|
||||
|
||||
__slots__ = []
|
||||
|
||||
def __init__(self, phone: str, first_name: str, last_name: str = ""):
|
||||
super().__init__(None)
|
||||
|
||||
|
@ -31,8 +31,6 @@ class InputMessageContent(Object):
|
||||
- :obj:`InputTextMessageContent`
|
||||
"""
|
||||
|
||||
__slots__ = []
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
|
@ -41,8 +41,6 @@ class InputTextMessageContent(InputMessageContent):
|
||||
Disables link previews for links in this message.
|
||||
"""
|
||||
|
||||
__slots__ = ["message_text", "parse_mode", "disable_web_page_preview"]
|
||||
|
||||
def __init__(self, message_text: str, parse_mode: Union[str, None] = object, disable_web_page_preview: bool = None):
|
||||
super().__init__()
|
||||
|
||||
|
@ -58,8 +58,6 @@ class Animation(Object):
|
||||
Animation thumbnails.
|
||||
"""
|
||||
|
||||
__slots__ = ["file_id", "file_name", "mime_type", "file_size", "date", "width", "height", "duration", "thumbs"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -58,10 +58,6 @@ class Audio(Object):
|
||||
Thumbnails of the music file album cover.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
"file_id", "file_name", "mime_type", "file_size", "date", "duration", "performer", "title", "thumbs"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -42,8 +42,6 @@ class Contact(Object):
|
||||
Additional data about the contact in the form of a vCard.
|
||||
"""
|
||||
|
||||
__slots__ = ["phone_number", "first_name", "last_name", "user_id", "vcard"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -49,8 +49,6 @@ class Document(Object):
|
||||
Document thumbnails as defined by sender.
|
||||
"""
|
||||
|
||||
__slots__ = ["file_id", "file_name", "mime_type", "file_size", "date", "thumbs"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -48,8 +48,6 @@ class Game(Object):
|
||||
Upload via BotFather.
|
||||
"""
|
||||
|
||||
__slots__ = ["id", "title", "short_name", "description", "photo", "animation"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -33,8 +33,6 @@ class Location(Object):
|
||||
Latitude as defined by sender.
|
||||
"""
|
||||
|
||||
__slots__ = ["longitude", "latitude"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -264,17 +264,6 @@ class Message(Object, Update):
|
||||
|
||||
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
|
||||
|
||||
__slots__ = [
|
||||
"message_id", "date", "chat", "from_user", "forward_from", "forward_sender_name", "forward_from_chat",
|
||||
"forward_from_message_id", "forward_signature", "forward_date", "reply_to_message", "mentioned", "empty",
|
||||
"service", "media", "edit_date", "media_group_id", "author_signature", "text", "entities", "caption_entities",
|
||||
"audio", "document", "photo", "sticker", "animation", "game", "video", "voice", "video_note", "caption",
|
||||
"contact", "location", "venue", "web_page", "poll", "new_chat_members", "left_chat_member", "new_chat_title",
|
||||
"new_chat_photo", "delete_chat_photo", "group_chat_created", "supergroup_chat_created", "channel_chat_created",
|
||||
"migrate_to_chat_id", "migrate_from_chat_id", "pinned_message", "game_high_score", "views", "via_bot",
|
||||
"outgoing", "matches", "command", "reply_markup"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -47,8 +47,6 @@ class MessageEntity(Object):
|
||||
For "text_mention" only, the mentioned user.
|
||||
"""
|
||||
|
||||
__slots__ = ["type", "offset", "length", "url", "user"]
|
||||
|
||||
ENTITIES = {
|
||||
types.MessageEntityMention.ID: "mention",
|
||||
types.MessageEntityHashtag.ID: "hashtag",
|
||||
|
@ -49,8 +49,6 @@ class Photo(Object):
|
||||
Available thumbnails of this photo.
|
||||
"""
|
||||
|
||||
__slots__ = ["file_id", "width", "height", "file_size", "date", "thumbs"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -48,8 +48,6 @@ class Poll(Object, Update):
|
||||
Index of your chosen option (0-9), None in case you haven't voted yet.
|
||||
"""
|
||||
|
||||
__slots__ = ["id", "question", "options", "is_closed", "total_voters", "chosen_option"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -35,8 +35,6 @@ class PollOption(Object):
|
||||
The data this poll option is holding.
|
||||
"""
|
||||
|
||||
__slots__ = ["text", "voter_count", "data"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -65,10 +65,6 @@ class Sticker(Object):
|
||||
|
||||
# TODO: Add mask position
|
||||
|
||||
__slots__ = [
|
||||
"file_id", "file_name", "mime_type", "file_size", "date", "width", "height", "emoji", "set_name", "thumbs"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -29,8 +29,6 @@ class StrippedThumbnail(Object):
|
||||
Thumbnail data
|
||||
"""
|
||||
|
||||
__slots__ = ["data"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -43,8 +43,6 @@ class Thumbnail(Object):
|
||||
File size.
|
||||
"""
|
||||
|
||||
__slots__ = ["file_id", "width", "height", "file_size"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -44,8 +44,6 @@ class Venue(Object):
|
||||
|
||||
"""
|
||||
|
||||
__slots__ = ["location", "title", "address", "foursquare_id", "foursquare_type"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -61,11 +61,6 @@ class Video(Object):
|
||||
Video thumbnails.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
"file_id", "width", "height", "duration", "file_name", "mime_type", "supports_streaming", "file_size", "date",
|
||||
"thumbs"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -52,8 +52,6 @@ class VideoNote(Object):
|
||||
Video thumbnails.
|
||||
"""
|
||||
|
||||
__slots__ = ["file_id", "mime_type", "file_size", "date", "length", "duration", "thumbs"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -47,8 +47,6 @@ class Voice(Object):
|
||||
Date the voice was sent in Unix time.
|
||||
"""
|
||||
|
||||
__slots__ = ["file_id", "duration", "waveform", "mime_type", "file_size", "date"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -83,12 +83,6 @@ class WebPage(Object):
|
||||
Author of the webpage, eg the Twitter user for a tweet, or the author in an article.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
"id", "url", "display_url", "type", "site_name", "title", "description",
|
||||
"audio", "document", "photo", "animation", "video",
|
||||
"embed_url", "embed_type", "embed_width", "embed_height", "duration", "author"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -29,8 +29,6 @@ class Meta(type, metaclass=type("", (type,), {"__str__": lambda _: "~hi"})):
|
||||
|
||||
|
||||
class Object(metaclass=Meta):
|
||||
__slots__ = ["_client"]
|
||||
|
||||
def __init__(self, client: "pyrogram.BaseClient" = None):
|
||||
self._client = client
|
||||
|
||||
@ -50,7 +48,7 @@ class Object(metaclass=Meta):
|
||||
else (attr, str(datetime.fromtimestamp(getattr(obj, attr))))
|
||||
if attr.endswith("date")
|
||||
else (attr, getattr(obj, attr))
|
||||
for attr in getattr(obj, "__slots__", [])
|
||||
for attr in filter(lambda x: not x.startswith("_"), obj.__dict__)
|
||||
if getattr(obj, attr) is not None
|
||||
]
|
||||
)
|
||||
@ -63,13 +61,13 @@ class Object(metaclass=Meta):
|
||||
self.__class__.__name__,
|
||||
", ".join(
|
||||
"{}={}".format(attr, repr(getattr(self, attr)))
|
||||
for attr in self.__slots__
|
||||
for attr in filter(lambda x: not x.startswith("_"), self.__dict__)
|
||||
if getattr(self, attr) is not None
|
||||
)
|
||||
)
|
||||
|
||||
def __eq__(self, other: "Object") -> bool:
|
||||
for attr in self.__slots__:
|
||||
for attr in self.__dict__:
|
||||
try:
|
||||
if getattr(self, attr) != getattr(other, attr):
|
||||
return False
|
||||
|
@ -26,8 +26,6 @@ class ContinuePropagation(StopIteration):
|
||||
|
||||
|
||||
class Update:
|
||||
__slots__ = []
|
||||
|
||||
def stop_propagation(self):
|
||||
raise StopPropagation
|
||||
|
||||
|
@ -95,12 +95,6 @@ class Chat(Object):
|
||||
Information about the chat default permissions, for groups and supergroups.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
"id", "type", "is_verified", "is_restricted", "is_scam", "is_support", "title", "username", "first_name",
|
||||
"last_name", "photo", "description", "invite_link", "pinned_message", "sticker_set_name", "can_set_sticker_set",
|
||||
"members_count", "restriction_reason", "permissions"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -54,8 +54,6 @@ class ChatMember(Object):
|
||||
Information about the member permissions.
|
||||
"""
|
||||
|
||||
__slots__ = ["user", "status", "date", "is_member", "invited_by", "promoted_by", "restricted_by", "permissions"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -94,13 +94,6 @@ class ChatPermissions(Object):
|
||||
True, if polls can be sent, implies can_send_media_messages.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
"until_date", "can_be_edited", "can_change_info", "can_post_messages", "can_edit_messages",
|
||||
"can_delete_messages", "can_restrict_members", "can_invite_users", "can_pin_messages", "can_promote_members",
|
||||
"can_send_messages", "can_send_media_messages", "can_send_other_messages", "can_add_web_page_previews",
|
||||
"can_send_polls"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -35,8 +35,6 @@ class ChatPhoto(Object):
|
||||
Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download.
|
||||
"""
|
||||
|
||||
__slots__ = ["small_file_id", "big_file_id"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -45,8 +45,6 @@ class ChatPreview(Object):
|
||||
Preview of some of the chat members.
|
||||
"""
|
||||
|
||||
__slots__ = ["title", "type", "members_count", "photo", "members"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -47,8 +47,6 @@ class Dialog(Object):
|
||||
True, if the dialog is pinned.
|
||||
"""
|
||||
|
||||
__slots__ = ["chat", "top_message", "unread_messages_count", "unread_mentions_count", "unread_mark", "is_pinned"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
@ -106,12 +106,6 @@ class User(Object, Update):
|
||||
This field is available only in case *is_restricted* is True.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
"id", "is_self", "is_contact", "is_mutual_contact", "is_deleted", "is_bot", "is_verified", "is_restricted",
|
||||
"is_scam", "is_support", "first_name", "last_name", "status", "last_online_date", "next_offline_date",
|
||||
"username", "language_code", "dc_id", "phone_number", "photo", "restriction_reason"
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
|
Loading…
Reference in New Issue
Block a user