2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-30 13:57:54 +00:00

Force named arguments on Pyrogram types

This commit is contained in:
Dan
2018-12-16 22:34:23 +01:00
parent 7430529646
commit c6a0bf0791
25 changed files with 118 additions and 155 deletions

View File

@@ -56,9 +56,10 @@ class Animation(PyrogramType):
Date the animation was sent in Unix time. Date the animation was sent in Unix time.
""" """
def __init__(self, file_id: str, width: int, height: int, duration: int, *, def __init__(self, *, client, raw, file_id: str, width: int, height: int, duration: int, thumb=None,
thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None):
client=None, raw=None): super().__init__(client, raw)
self.file_id = file_id self.file_id = file_id
self.thumb = thumb self.thumb = thumb
self.file_name = file_name self.file_name = file_name
@@ -69,9 +70,6 @@ class Animation(PyrogramType):
self.height = height self.height = height
self.duration = duration self.duration = duration
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, animation: types.Document, video_attributes: types.DocumentAttributeVideo, def parse(client, animation: types.Document, video_attributes: types.DocumentAttributeVideo,
file_name: str) -> "Animation": file_name: str) -> "Animation":

View File

@@ -56,10 +56,11 @@ class Audio(PyrogramType):
Title of the audio as defined by sender or by audio tags. Title of the audio as defined by sender or by audio tags.
""" """
def __init__(self, file_id: str, duration: int, *, def __init__(self, *, client, raw, file_id: str, duration: int, thumb=None, file_name: str = None,
thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None, mime_type: str = None, file_size: int = None, date: int = None, performer: str = None,
performer: str = None, title: str = None, title: str = None):
client=None, raw=None): super().__init__(client, raw)
self.file_id = file_id self.file_id = file_id
self.thumb = thumb self.thumb = thumb
self.file_name = file_name self.file_name = file_name
@@ -70,9 +71,6 @@ class Audio(PyrogramType):
self.performer = performer self.performer = performer
self.title = title self.title = title
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio, file_name: str) -> "Audio": def parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio, file_name: str) -> "Audio":
return Audio( return Audio(

View File

@@ -40,18 +40,16 @@ class Contact(PyrogramType):
Additional data about the contact in the form of a vCard. Additional data about the contact in the form of a vCard.
""" """
def __init__(self, phone_number: str, first_name: str, *, def __init__(self, *, client, raw, phone_number: str, first_name: str, last_name: str = None, user_id: int = None,
last_name: str = None, user_id: int = None, vcard: str = None, vcard: str = None):
client=None, raw=None): super().__init__(client, raw)
self.phone_number = phone_number self.phone_number = phone_number
self.first_name = first_name self.first_name = first_name
self.last_name = last_name self.last_name = last_name
self.user_id = user_id self.user_id = user_id
self.vcard = vcard self.vcard = vcard
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, contact: types.MessageMediaContact) -> "Contact": def parse(client, contact: types.MessageMediaContact) -> "Contact":
return Contact( return Contact(

View File

@@ -47,9 +47,10 @@ class Document(PyrogramType):
Date the document was sent in Unix time. Date the document was sent in Unix time.
""" """
def __init__(self, file_id: str, *, def __init__(self, *, client, raw, file_id: str, thumb=None, file_name: str = None, mime_type: str = None,
thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None, file_size: int = None, date: int = None):
client=None, raw=None): super().__init__(client, raw)
self.file_id = file_id self.file_id = file_id
self.thumb = thumb self.thumb = thumb
self.file_name = file_name self.file_name = file_name
@@ -57,9 +58,6 @@ class Document(PyrogramType):
self.file_size = file_size self.file_size = file_size
self.date = date self.date = date
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, document: types.Document, file_name: str) -> "Document": def parse(client, document: types.Document, file_name: str) -> "Document":
return Document( return Document(

View File

@@ -31,14 +31,12 @@ class Location(PyrogramType):
Latitude as defined by sender. Latitude as defined by sender.
""" """
def __init__(self, longitude: float, latitude: float, *, def __init__(self, *, client, raw, longitude: float, latitude: float, ):
client=None, raw=None): super().__init__(client, raw)
self.longitude = longitude self.longitude = longitude
self.latitude = latitude self.latitude = latitude
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, geo_point: types.GeoPoint) -> "Location": def parse(client, geo_point: types.GeoPoint) -> "Location":
if isinstance(geo_point, types.GeoPoint): if isinstance(geo_point, types.GeoPoint):

View File

@@ -225,20 +225,20 @@ class Message(PyrogramType):
# TODO: Add game missing field. Also invoice, successful_payment, connected_website # TODO: Add game missing field. Also invoice, successful_payment, connected_website
def __init__(self, message_id: int, *, def __init__(self, *, client, raw, message_id: int, date: int = None, chat=None, from_user=None, forward_from=None,
date: int = None, chat=None, from_user=None, forward_from=None, forward_from_chat=None, forward_from_chat=None, forward_from_message_id: int = None, forward_signature: str = None,
forward_from_message_id: int = None, forward_signature: str = None, forward_date: int = None, forward_date: int = None, reply_to_message=None, mentioned=None, empty=None, service=None, media=None,
reply_to_message=None, mentioned=None, empty=None, service=None, media=None, edit_date: int = None, edit_date: int = None, media_group_id: str = None, author_signature: str = None, text: str = None,
media_group_id: str = None, author_signature: str = None, text: str = None, entities: list = None, entities: list = None, caption_entities: list = None, audio=None, document=None, photo=None,
caption_entities: list = None, audio=None, document=None, photo=None, sticker=None, animation=None, sticker=None, animation=None, video=None, voice=None, video_note=None, caption: str = None,
video=None, voice=None, video_note=None, caption: str = None, contact=None, location=None, venue=None, contact=None, location=None, venue=None, web_page=None, new_chat_members: list = None,
web_page=None, new_chat_members: list = None, left_chat_member=None, new_chat_title: str = None, left_chat_member=None, new_chat_title: str = None, new_chat_photo=None, delete_chat_photo: bool = None,
new_chat_photo=None, delete_chat_photo: bool = None, group_chat_created: bool = None, group_chat_created: bool = None, supergroup_chat_created: bool = None,
supergroup_chat_created: bool = None, channel_chat_created: bool = None, channel_chat_created: bool = None, migrate_to_chat_id: int = None, migrate_from_chat_id: int = None,
migrate_to_chat_id: int = None, migrate_from_chat_id: int = None, pinned_message=None, pinned_message=None, views: int = None, via_bot=None, outgoing: bool = None, matches: list = None,
views: int = None, via_bot=None, outgoing: bool = None, matches: list = None, command: list = None, command: list = None, reply_markup=None):
reply_markup=None, super().__init__(client, raw)
client=None, raw=None):
self.message_id = message_id self.message_id = message_id
self.date = date self.date = date
self.chat = chat self.chat = chat
@@ -290,9 +290,6 @@ class Message(PyrogramType):
self.command = command self.command = command
self.reply_markup = reply_markup self.reply_markup = reply_markup
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, message: types.Message or types.MessageService or types.MessageEmpty, users: dict, chats: dict, def parse(client, message: types.Message or types.MessageService or types.MessageEmpty, users: dict, chats: dict,
replies: int = 1): replies: int = 1):

View File

@@ -61,18 +61,15 @@ class MessageEntity(PyrogramType):
types.MessageEntityPhone.ID: "phone_number" types.MessageEntityPhone.ID: "phone_number"
} }
def __init__(self, type: str, offset: int, length: int, *, def __init__(self, *, client, raw, type: str, offset: int, length: int, url: str = None, user=None):
url: str = None, user=None, super().__init__(client, raw)
client=None, raw=None):
self.type = type self.type = type
self.offset = offset self.offset = offset
self.length = length self.length = length
self.url = url self.url = url
self.user = user self.user = user
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, entity, users: dict) -> "MessageEntity" or None: def parse(client, entity, users: dict) -> "MessageEntity" or None:
type = MessageEntity.ENTITIES.get(entity.ID, None) type = MessageEntity.ENTITIES.get(entity.ID, None)
@@ -85,5 +82,7 @@ class MessageEntity(PyrogramType):
offset=entity.offset, offset=entity.offset,
length=entity.length, length=entity.length,
url=getattr(entity, "url", None), url=getattr(entity, "url", None),
user=User.parse(client, users.get(getattr(entity, "user_id", None), None)) user=User.parse(client, users.get(getattr(entity, "user_id", None), None)),
client=client,
raw=entity
) )

View File

@@ -30,6 +30,8 @@ class Messages(PyrogramType):
Requested messages. Requested messages.
""" """
def __init__(self, total_count: int, messages: list): def __init__(self, *, client, raw, total_count: int, messages: list):
super().__init__(client, raw)
self.total_count = total_count self.total_count = total_count
self.messages = messages self.messages = messages

View File

@@ -39,15 +39,13 @@ class Photo(PyrogramType):
Available sizes of this photo. Available sizes of this photo.
""" """
def __init__(self, id: str, date: int, sizes: list, *, def __init__(self, *, client, raw, id: str, date: int, sizes: list):
client=None, raw=None): super().__init__(client, raw)
self.id = id self.id = id
self.date = date self.date = date
self.sizes = sizes self.sizes = sizes
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, photo: types.Photo): def parse(client, photo: types.Photo):
if isinstance(photo, types.Photo): if isinstance(photo, types.Photo):

View File

@@ -40,16 +40,14 @@ class PhotoSize(PyrogramType):
File size. File size.
""" """
def __init__(self, file_id: str, width: int, height: int, file_size: int, *, def __init__(self, *, client, raw, file_id: str, width: int, height: int, file_size: int):
client=None, raw=None): super().__init__(client, raw)
self.file_id = file_id self.file_id = file_id
self.width = width self.width = width
self.height = height self.height = height
self.file_size = file_size self.file_size = file_size
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, photo_size: types.PhotoSize or types.PhotoCachedSize): def parse(client, photo_size: types.PhotoSize or types.PhotoCachedSize):
if isinstance(photo_size, (types.PhotoSize, types.PhotoCachedSize)): if isinstance(photo_size, (types.PhotoSize, types.PhotoCachedSize)):

View File

@@ -61,10 +61,11 @@ class Sticker(PyrogramType):
# TODO: Add mask position # TODO: Add mask position
def __init__(self, file_id: str, width: int, height: int, *, def __init__(self, *, client, raw, file_id: str, width: int, height: int, thumb=None, file_name: str = None,
thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None, mime_type: str = None, file_size: int = None, date: int = None, emoji: str = None,
emoji: str = None, set_name: str = None, mask_position=None, set_name: str = None, mask_position=None):
client=None, raw=None): super().__init__(client, raw)
self.file_id = file_id self.file_id = file_id
self.thumb = thumb self.thumb = thumb
self.file_name = file_name self.file_name = file_name
@@ -77,9 +78,6 @@ class Sticker(PyrogramType):
self.set_name = set_name self.set_name = set_name
self.mask_position = mask_position self.mask_position = mask_position
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, sticker: types.Document, image_size_attributes: types.DocumentAttributeImageSize, set_name: str, def parse(client, sticker: types.Document, image_size_attributes: types.DocumentAttributeImageSize, set_name: str,
sticker_attributes: types.DocumentAttributeSticker, file_name: str) -> "Sticker": sticker_attributes: types.DocumentAttributeSticker, file_name: str) -> "Sticker":

View File

@@ -30,6 +30,8 @@ class UserProfilePhotos(PyrogramType):
Requested profile pictures. Requested profile pictures.
""" """
def __init__(self, total_count: int, photos: list): def __init__(self, *, client, raw, total_count: int, photos: list):
super().__init__(client, raw)
self.total_count = total_count self.total_count = total_count
self.photos = photos self.photos = photos

View File

@@ -43,18 +43,16 @@ class Venue(PyrogramType):
""" """
def __init__(self, location, title: str, address: str, *, def __init__(self, *, client, raw, location, title: str, address: str, foursquare_id: str = None,
foursquare_id: str = None, foursquare_type: str = None, foursquare_type: str = None):
client=None, raw=None): super().__init__(client, raw)
self.location = location self.location = location
self.title = title self.title = title
self.address = address self.address = address
self.foursquare_id = foursquare_id self.foursquare_id = foursquare_id
self.foursquare_type = foursquare_type self.foursquare_type = foursquare_type
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, venue: types.MessageMediaVenue): def parse(client, venue: types.MessageMediaVenue):
return Venue( return Venue(

View File

@@ -56,9 +56,10 @@ class Video(PyrogramType):
Date the video was sent in Unix time. Date the video was sent in Unix time.
""" """
def __init__(self, file_id: str, width: int, height: int, duration: int, *, def __init__(self, *, client, raw, file_id: str, width: int, height: int, duration: int, thumb=None,
thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None):
client=None, raw=None): super().__init__(client, raw)
self.file_id = file_id self.file_id = file_id
self.thumb = thumb self.thumb = thumb
self.file_name = file_name self.file_name = file_name
@@ -69,9 +70,6 @@ class Video(PyrogramType):
self.height = height self.height = height
self.duration = duration self.duration = duration
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, video: types.Document, video_attributes: types.DocumentAttributeVideo, file_name: str) -> "Video": def parse(client, video: types.Document, video_attributes: types.DocumentAttributeVideo, file_name: str) -> "Video":
return Video( return Video(

View File

@@ -50,9 +50,10 @@ class VideoNote(PyrogramType):
Date the video note was sent in Unix time. Date the video note was sent in Unix time.
""" """
def __init__(self, file_id: str, length: int, duration: int, *, def __init__(self, *, client, raw, file_id: str, length: int, duration: int, thumb=None, mime_type: str = None,
thumb=None, mime_type: str = None, file_size: int = None, date: int = None, file_size: int = None, date: int = None):
client=None, raw=None): super().__init__(client, raw)
self.file_id = file_id self.file_id = file_id
self.thumb = thumb self.thumb = thumb
self.mime_type = mime_type self.mime_type = mime_type
@@ -61,9 +62,6 @@ class VideoNote(PyrogramType):
self.length = length self.length = length
self.duration = duration self.duration = duration
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, video_note: types.Document, video_attributes: types.DocumentAttributeVideo) -> "VideoNote": def parse(client, video_note: types.Document, video_attributes: types.DocumentAttributeVideo) -> "VideoNote":
return VideoNote( return VideoNote(

View File

@@ -46,9 +46,10 @@ class Voice(PyrogramType):
Date the voice was sent in Unix time. Date the voice was sent in Unix time.
""" """
def __init__(self, file_id: str, duration: int, *, def __init__(self, *, client, raw, file_id: str, duration: int, waveform: bytes = None, mime_type: str = None,
waveform: bytes = None, mime_type: str = None, file_size: int = None, date: int = None, file_size: int = None, date: int = None):
client=None, raw=None): super().__init__(client, raw)
self.file_id = file_id self.file_id = file_id
self.duration = duration self.duration = duration
self.waveform = waveform self.waveform = waveform
@@ -56,9 +57,6 @@ class Voice(PyrogramType):
self.file_size = file_size self.file_size = file_size
self.date = date self.date = date
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, voice: types.Document, attributes: types.DocumentAttributeAudio) -> "Voice": def parse(client, voice: types.Document, attributes: types.DocumentAttributeAudio) -> "Voice":
return Voice( return Voice(

View File

@@ -21,6 +21,10 @@ from json import dumps, JSONEncoder
class PyrogramType: class PyrogramType:
def __init__(self, client, raw):
self._client = client
self._raw = raw
def __str__(self): def __str__(self):
return dumps(self, cls=Encoder, indent=4) return dumps(self, cls=Encoder, indent=4)

View File

@@ -76,15 +76,14 @@ class Chat(PyrogramType):
The reason why this chat might be unavailable to some users. The reason why this chat might be unavailable to some users.
""" """
def __init__(self, id: int, type: str, *, def __init__(self, *, client, raw, id: int, type: str, title: str = None, username: str = None,
title: str = None, username: str = None, first_name: str = None, last_name: str = None, first_name: str = None, last_name: str = None, all_members_are_administrators: bool = None, photo=None,
all_members_are_administrators: bool = None, photo=None, description: str = None, description: str = None, invite_link: str = None, pinned_message=None, sticker_set_name: str = None,
invite_link: str = None, pinned_message=None, sticker_set_name: str = None, can_set_sticker_set: bool = None, members_count: int = None, restriction_reason: str = None):
can_set_sticker_set: bool = None, members_count: int = None, restriction_reason: str = None, super().__init__(client, raw)
client=None, raw=None):
self.id = id self.id = id
self.type = type self.type = type
self.title = title self.title = title
self.username = username self.username = username
self.first_name = first_name self.first_name = first_name
@@ -99,9 +98,6 @@ class Chat(PyrogramType):
self.members_count = members_count self.members_count = members_count
self.restriction_reason = restriction_reason self.restriction_reason = restriction_reason
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse_user_chat(client, user: types.User) -> "Chat": def parse_user_chat(client, user: types.User) -> "Chat":
return Chat( return Chat(

View File

@@ -79,12 +79,14 @@ class ChatMember(PyrogramType):
Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages. Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages.
""" """
def __init__(self, *, user, status: str, until_date: int = None, can_be_edited: bool = None, def __init__(self, *, client, raw, user, status: str, until_date: int = None, can_be_edited: bool = None,
can_change_info: bool = None, can_post_messages: bool = None, can_edit_messages: bool = None, can_change_info: bool = None, can_post_messages: bool = None, can_edit_messages: bool = None,
can_delete_messages: bool = None, can_invite_users: bool = None, can_restrict_members: bool = None, can_delete_messages: bool = None, can_invite_users: bool = None, can_restrict_members: bool = None,
can_pin_messages: bool = None, can_promote_members: bool = None, can_send_messages: bool = None, can_pin_messages: bool = None, can_promote_members: bool = None, can_send_messages: bool = None,
can_send_media_messages: bool = None, can_send_other_messages: bool = None, can_send_media_messages: bool = None, can_send_other_messages: bool = None,
can_add_web_page_previews: bool = None, client, raw): can_add_web_page_previews: bool = None):
super().__init__(client, raw)
self.user = user self.user = user
self.status = status self.status = status
self.until_date = until_date self.until_date = until_date
@@ -102,9 +104,6 @@ class ChatMember(PyrogramType):
self.can_send_other_messages = can_send_other_messages self.can_send_other_messages = can_send_other_messages
self.can_add_web_page_previews = can_add_web_page_previews self.can_add_web_page_previews = can_add_web_page_previews
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, member, user) -> "ChatMember": def parse(client, member, user) -> "ChatMember":
if isinstance(member, (types.ChannelParticipant, types.ChannelParticipantSelf, types.ChatParticipant)): if isinstance(member, (types.ChannelParticipant, types.ChannelParticipantSelf, types.ChatParticipant)):

View File

@@ -33,13 +33,12 @@ class ChatMembers(PyrogramType):
Requested chat members. Requested chat members.
""" """
def __init__(self, *, total_count: int, chat_members: list, client, raw): def __init__(self, *, client, raw, total_count: int, chat_members: list):
super().__init__(client, raw)
self.total_count = total_count self.total_count = total_count
self.chat_members = chat_members self.chat_members = chat_members
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, members): def parse(client, members):
users = {i.id: i for i in members.users} users = {i.id: i for i in members.users}
@@ -59,5 +58,6 @@ class ChatMembers(PyrogramType):
return ChatMembers( return ChatMembers(
total_count=total_count, total_count=total_count,
chat_members=chat_members, chat_members=chat_members,
client=client, raw=members client=client,
raw=members
) )

View File

@@ -36,14 +36,10 @@ class ChatPhoto(Object):
ID = 0xb0700015 ID = 0xb0700015
def __init__(self, small_file_id: str, big_file_id: str, *, def __init__(self, *, client, raw, small_file_id: str, big_file_id: str):
client=None, raw=None):
self.small_file_id = small_file_id self.small_file_id = small_file_id
self.big_file_id = big_file_id self.big_file_id = big_file_id
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, chat_photo: types.UserProfilePhoto or types.ChatPhoto): def parse(client, chat_photo: types.UserProfilePhoto or types.ChatPhoto):
if not isinstance(chat_photo, (types.UserProfilePhoto, types.ChatPhoto)): if not isinstance(chat_photo, (types.UserProfilePhoto, types.ChatPhoto)):

View File

@@ -16,10 +16,10 @@
# 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 pyrogram.api.core import Object from ..pyrogram_type import PyrogramType
class Dialog(Object): class Dialog(PyrogramType):
"""This object represents a dialog. """This object represents a dialog.
Args: Args:
@@ -41,15 +41,11 @@ class Dialog(Object):
is_pinned (``bool``): is_pinned (``bool``):
True, if the dialog is pinned. True, if the dialog is pinned.
""" """
ID = 0xb0700028
def __init__(self, def __init__(self, *, client, raw, chat, top_message, unread_messages_count: int, unread_mentions_count: int,
chat, unread_mark: bool, is_pinned: bool):
top_message, super().__init__(client, raw)
unread_messages_count: int,
unread_mentions_count: int,
unread_mark: bool,
is_pinned: bool):
self.chat = chat self.chat = chat
self.top_message = top_message self.top_message = top_message
self.unread_messages_count = unread_messages_count self.unread_messages_count = unread_messages_count

View File

@@ -16,10 +16,10 @@
# 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 pyrogram.api.core import Object from ..pyrogram_type import PyrogramType
class Dialogs(Object): class Dialogs(PyrogramType):
"""This object represents a user's dialogs chunk """This object represents a user's dialogs chunk
Args: Args:
@@ -29,8 +29,9 @@ class Dialogs(Object):
dialogs (List of :obj:`Dialog <pyrogram.Dialog>`): dialogs (List of :obj:`Dialog <pyrogram.Dialog>`):
Requested dialogs. Requested dialogs.
""" """
ID = 0xb0700029
def __init__(self, total_count: int, dialogs: list): def __init__(self, *, client, raw, total_count: int, dialogs: list):
super().__init__(client, raw)
self.total_count = total_count self.total_count = total_count
self.dialogs = dialogs self.dialogs = dialogs

View File

@@ -69,11 +69,12 @@ class User(PyrogramType):
The reason why this bot might be unavailable to some users. The reason why this bot might be unavailable to some users.
""" """
def __init__(self, id: int, is_self: bool, is_contact: bool, is_mutual_contact: bool, is_deleted: bool, def __init__(self, *, client, raw, id: int, is_self: bool, is_contact: bool, is_mutual_contact: bool,
is_bot: bool, first_name: str, *, is_deleted: bool, is_bot: bool, first_name: str, last_name: str = None, status=None,
last_name: str = None, status=None, username: str = None, language_code: str = None, username: str = None, language_code: str = None, phone_number: str = None, photo=None,
phone_number: str = None, photo=None, restriction_reason: str = None, restriction_reason: str = None):
client=None, raw=None): super().__init__(client, raw)
self.id = id self.id = id
self.is_self = is_self self.is_self = is_self
self.is_contact = is_contact self.is_contact = is_contact
@@ -81,7 +82,6 @@ class User(PyrogramType):
self.is_deleted = is_deleted self.is_deleted = is_deleted
self.is_bot = is_bot self.is_bot = is_bot
self.first_name = first_name self.first_name = first_name
self.last_name = last_name self.last_name = last_name
self.status = status self.status = status
self.username = username self.username = username
@@ -90,9 +90,6 @@ class User(PyrogramType):
self.photo = photo self.photo = photo
self.restriction_reason = restriction_reason self.restriction_reason = restriction_reason
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, user: types.User) -> "User" or None: def parse(client, user: types.User) -> "User" or None:
if user is None: if user is None:
@@ -113,5 +110,6 @@ class User(PyrogramType):
phone_number=user.phone, phone_number=user.phone,
photo=ChatPhoto.parse(client, user.photo), photo=ChatPhoto.parse(client, user.photo),
restriction_reason=user.restriction_reason, restriction_reason=user.restriction_reason,
client=client, raw=user client=client,
raw=user
) )

View File

@@ -62,12 +62,12 @@ class UserStatus(PyrogramType):
always shown to blocked users), None otherwise. always shown to blocked users), None otherwise.
""" """
def __init__(self, user_id: int, *, def __init__(self, *, client, raw, user_id: int, online: bool = None, offline: bool = None, date: int = None,
online: bool = None, offline: bool = None, date: int = None, recently: bool = None, recently: bool = None, within_week: bool = None, within_month: bool = None,
within_week: bool = None, within_month: bool = None, long_time_ago: bool = None, long_time_ago: bool = None):
client=None, raw=None): super().__init__(client, raw)
self.user_id = user_id
self.user_id = user_id
self.online = online self.online = online
self.offline = offline self.offline = offline
self.date = date self.date = date
@@ -76,9 +76,6 @@ class UserStatus(PyrogramType):
self.within_month = within_month self.within_month = within_month
self.long_time_ago = long_time_ago self.long_time_ago = long_time_ago
self._client = client
self._raw = raw
@staticmethod @staticmethod
def parse(client, user: types.User): def parse(client, user: types.User):
if user.bot: if user.bot: