From c6a0bf0791697b08b193d2664630ad45be72a4fa Mon Sep 17 00:00:00 2001
From: Dan <14043624+delivrance@users.noreply.github.com>
Date: Sun, 16 Dec 2018 22:34:23 +0100
Subject: [PATCH] Force named arguments on Pyrogram types
---
.../types/messages_and_media/animation.py | 10 +++---
.../client/types/messages_and_media/audio.py | 12 +++----
.../types/messages_and_media/contact.py | 10 +++---
.../types/messages_and_media/document.py | 10 +++---
.../types/messages_and_media/location.py | 8 ++---
.../types/messages_and_media/message.py | 31 +++++++++----------
.../messages_and_media/message_entity.py | 13 ++++----
.../types/messages_and_media/messages.py | 4 ++-
.../client/types/messages_and_media/photo.py | 8 ++---
.../types/messages_and_media/photo_size.py | 8 ++---
.../types/messages_and_media/sticker.py | 12 +++----
.../messages_and_media/user_profile_photos.py | 4 ++-
.../client/types/messages_and_media/venue.py | 10 +++---
.../client/types/messages_and_media/video.py | 10 +++---
.../types/messages_and_media/video_note.py | 10 +++---
.../client/types/messages_and_media/voice.py | 10 +++---
pyrogram/client/types/pyrogram_type.py | 4 +++
pyrogram/client/types/user_and_chats/chat.py | 16 ++++------
.../types/user_and_chats/chat_member.py | 9 +++---
.../types/user_and_chats/chat_members.py | 10 +++---
.../client/types/user_and_chats/chat_photo.py | 6 +---
.../client/types/user_and_chats/dialog.py | 18 +++++------
.../client/types/user_and_chats/dialogs.py | 9 +++---
pyrogram/client/types/user_and_chats/user.py | 18 +++++------
.../types/user_and_chats/user_status.py | 13 +++-----
25 files changed, 118 insertions(+), 155 deletions(-)
diff --git a/pyrogram/client/types/messages_and_media/animation.py b/pyrogram/client/types/messages_and_media/animation.py
index 7447f4ab..c270dfa9 100644
--- a/pyrogram/client/types/messages_and_media/animation.py
+++ b/pyrogram/client/types/messages_and_media/animation.py
@@ -56,9 +56,10 @@ class Animation(PyrogramType):
Date the animation was sent in Unix time.
"""
- def __init__(self, file_id: str, width: int, height: int, duration: int, *,
- thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, file_id: str, width: int, height: int, duration: int, thumb=None,
+ file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None):
+ super().__init__(client, raw)
+
self.file_id = file_id
self.thumb = thumb
self.file_name = file_name
@@ -69,9 +70,6 @@ class Animation(PyrogramType):
self.height = height
self.duration = duration
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, animation: types.Document, video_attributes: types.DocumentAttributeVideo,
file_name: str) -> "Animation":
diff --git a/pyrogram/client/types/messages_and_media/audio.py b/pyrogram/client/types/messages_and_media/audio.py
index 2cd3a1bd..bc5cf166 100644
--- a/pyrogram/client/types/messages_and_media/audio.py
+++ b/pyrogram/client/types/messages_and_media/audio.py
@@ -56,10 +56,11 @@ class Audio(PyrogramType):
Title of the audio as defined by sender or by audio tags.
"""
- def __init__(self, file_id: str, duration: int, *,
- thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None,
- performer: str = None, title: str = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, file_id: str, duration: int, thumb=None, file_name: str = None,
+ mime_type: str = None, file_size: int = None, date: int = None, performer: str = None,
+ title: str = None):
+ super().__init__(client, raw)
+
self.file_id = file_id
self.thumb = thumb
self.file_name = file_name
@@ -70,9 +71,6 @@ class Audio(PyrogramType):
self.performer = performer
self.title = title
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio, file_name: str) -> "Audio":
return Audio(
diff --git a/pyrogram/client/types/messages_and_media/contact.py b/pyrogram/client/types/messages_and_media/contact.py
index 2a3f8a21..0525c463 100644
--- a/pyrogram/client/types/messages_and_media/contact.py
+++ b/pyrogram/client/types/messages_and_media/contact.py
@@ -40,18 +40,16 @@ class Contact(PyrogramType):
Additional data about the contact in the form of a vCard.
"""
- def __init__(self, phone_number: str, first_name: str, *,
- last_name: str = None, user_id: int = None, vcard: str = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, phone_number: str, first_name: str, last_name: str = None, user_id: int = None,
+ vcard: str = None):
+ super().__init__(client, raw)
+
self.phone_number = phone_number
self.first_name = first_name
self.last_name = last_name
self.user_id = user_id
self.vcard = vcard
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, contact: types.MessageMediaContact) -> "Contact":
return Contact(
diff --git a/pyrogram/client/types/messages_and_media/document.py b/pyrogram/client/types/messages_and_media/document.py
index 412954ef..0526a190 100644
--- a/pyrogram/client/types/messages_and_media/document.py
+++ b/pyrogram/client/types/messages_and_media/document.py
@@ -47,9 +47,10 @@ class Document(PyrogramType):
Date the document was sent in Unix time.
"""
- def __init__(self, file_id: str, *,
- thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, file_id: str, thumb=None, file_name: str = None, mime_type: str = None,
+ file_size: int = None, date: int = None):
+ super().__init__(client, raw)
+
self.file_id = file_id
self.thumb = thumb
self.file_name = file_name
@@ -57,9 +58,6 @@ class Document(PyrogramType):
self.file_size = file_size
self.date = date
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, document: types.Document, file_name: str) -> "Document":
return Document(
diff --git a/pyrogram/client/types/messages_and_media/location.py b/pyrogram/client/types/messages_and_media/location.py
index 1276a783..853a4c90 100644
--- a/pyrogram/client/types/messages_and_media/location.py
+++ b/pyrogram/client/types/messages_and_media/location.py
@@ -31,14 +31,12 @@ class Location(PyrogramType):
Latitude as defined by sender.
"""
- def __init__(self, longitude: float, latitude: float, *,
- client=None, raw=None):
+ def __init__(self, *, client, raw, longitude: float, latitude: float, ):
+ super().__init__(client, raw)
+
self.longitude = longitude
self.latitude = latitude
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, geo_point: types.GeoPoint) -> "Location":
if isinstance(geo_point, types.GeoPoint):
diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py
index 8d84a513..f50dd30b 100644
--- a/pyrogram/client/types/messages_and_media/message.py
+++ b/pyrogram/client/types/messages_and_media/message.py
@@ -225,20 +225,20 @@ class Message(PyrogramType):
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
- def __init__(self, message_id: int, *,
- date: int = None, chat=None, from_user=None, forward_from=None, forward_from_chat=None,
- forward_from_message_id: int = None, forward_signature: str = None, forward_date: int = None,
- reply_to_message=None, mentioned=None, empty=None, service=None, media=None, edit_date: int = None,
- media_group_id: str = None, author_signature: str = None, text: str = None, entities: list = None,
- caption_entities: list = None, audio=None, document=None, photo=None, sticker=None, animation=None,
- video=None, voice=None, video_note=None, caption: str = None, contact=None, location=None, venue=None,
- web_page=None, new_chat_members: list = None, left_chat_member=None, new_chat_title: str = None,
- new_chat_photo=None, delete_chat_photo: bool = None, group_chat_created: bool = None,
- supergroup_chat_created: bool = None, channel_chat_created: bool = None,
- migrate_to_chat_id: int = None, migrate_from_chat_id: int = None, pinned_message=None,
- views: int = None, via_bot=None, outgoing: bool = None, matches: list = None, command: list = None,
- reply_markup=None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, message_id: int, date: int = None, chat=None, from_user=None, forward_from=None,
+ forward_from_chat=None, forward_from_message_id: int = None, forward_signature: str = None,
+ forward_date: int = None, reply_to_message=None, mentioned=None, empty=None, service=None, media=None,
+ edit_date: int = None, media_group_id: str = None, author_signature: str = None, text: str = None,
+ entities: list = None, caption_entities: list = None, audio=None, document=None, photo=None,
+ sticker=None, animation=None, video=None, voice=None, video_note=None, caption: str = None,
+ contact=None, location=None, venue=None, web_page=None, new_chat_members: list = None,
+ left_chat_member=None, new_chat_title: str = None, new_chat_photo=None, delete_chat_photo: bool = None,
+ group_chat_created: bool = None, supergroup_chat_created: bool = None,
+ channel_chat_created: bool = None, migrate_to_chat_id: int = None, migrate_from_chat_id: int = None,
+ pinned_message=None, views: int = None, via_bot=None, outgoing: bool = None, matches: list = None,
+ command: list = None, reply_markup=None):
+ super().__init__(client, raw)
+
self.message_id = message_id
self.date = date
self.chat = chat
@@ -290,9 +290,6 @@ class Message(PyrogramType):
self.command = command
self.reply_markup = reply_markup
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, message: types.Message or types.MessageService or types.MessageEmpty, users: dict, chats: dict,
replies: int = 1):
diff --git a/pyrogram/client/types/messages_and_media/message_entity.py b/pyrogram/client/types/messages_and_media/message_entity.py
index 67f32806..c72df95d 100644
--- a/pyrogram/client/types/messages_and_media/message_entity.py
+++ b/pyrogram/client/types/messages_and_media/message_entity.py
@@ -61,18 +61,15 @@ class MessageEntity(PyrogramType):
types.MessageEntityPhone.ID: "phone_number"
}
- def __init__(self, type: str, offset: int, length: int, *,
- url: str = None, user=None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, type: str, offset: int, length: int, url: str = None, user=None):
+ super().__init__(client, raw)
+
self.type = type
self.offset = offset
self.length = length
self.url = url
self.user = user
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, entity, users: dict) -> "MessageEntity" or None:
type = MessageEntity.ENTITIES.get(entity.ID, None)
@@ -85,5 +82,7 @@ class MessageEntity(PyrogramType):
offset=entity.offset,
length=entity.length,
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
)
diff --git a/pyrogram/client/types/messages_and_media/messages.py b/pyrogram/client/types/messages_and_media/messages.py
index ef32f0b2..48907940 100644
--- a/pyrogram/client/types/messages_and_media/messages.py
+++ b/pyrogram/client/types/messages_and_media/messages.py
@@ -30,6 +30,8 @@ class Messages(PyrogramType):
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.messages = messages
diff --git a/pyrogram/client/types/messages_and_media/photo.py b/pyrogram/client/types/messages_and_media/photo.py
index 970579af..96a1e19a 100644
--- a/pyrogram/client/types/messages_and_media/photo.py
+++ b/pyrogram/client/types/messages_and_media/photo.py
@@ -39,15 +39,13 @@ class Photo(PyrogramType):
Available sizes of this photo.
"""
- def __init__(self, id: str, date: int, sizes: list, *,
- client=None, raw=None):
+ def __init__(self, *, client, raw, id: str, date: int, sizes: list):
+ super().__init__(client, raw)
+
self.id = id
self.date = date
self.sizes = sizes
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, photo: types.Photo):
if isinstance(photo, types.Photo):
diff --git a/pyrogram/client/types/messages_and_media/photo_size.py b/pyrogram/client/types/messages_and_media/photo_size.py
index cb94a6e6..1e37399c 100644
--- a/pyrogram/client/types/messages_and_media/photo_size.py
+++ b/pyrogram/client/types/messages_and_media/photo_size.py
@@ -40,16 +40,14 @@ class PhotoSize(PyrogramType):
File size.
"""
- def __init__(self, file_id: str, width: int, height: int, file_size: int, *,
- client=None, raw=None):
+ def __init__(self, *, client, raw, file_id: str, width: int, height: int, file_size: int):
+ super().__init__(client, raw)
+
self.file_id = file_id
self.width = width
self.height = height
self.file_size = file_size
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, photo_size: types.PhotoSize or types.PhotoCachedSize):
if isinstance(photo_size, (types.PhotoSize, types.PhotoCachedSize)):
diff --git a/pyrogram/client/types/messages_and_media/sticker.py b/pyrogram/client/types/messages_and_media/sticker.py
index 7b5bfa70..e6285895 100644
--- a/pyrogram/client/types/messages_and_media/sticker.py
+++ b/pyrogram/client/types/messages_and_media/sticker.py
@@ -61,10 +61,11 @@ class Sticker(PyrogramType):
# TODO: Add mask position
- def __init__(self, file_id: str, width: int, height: int, *,
- thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None,
- emoji: str = None, set_name: str = None, mask_position=None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, file_id: str, width: int, height: int, thumb=None, file_name: str = None,
+ mime_type: str = None, file_size: int = None, date: int = None, emoji: str = None,
+ set_name: str = None, mask_position=None):
+ super().__init__(client, raw)
+
self.file_id = file_id
self.thumb = thumb
self.file_name = file_name
@@ -77,9 +78,6 @@ class Sticker(PyrogramType):
self.set_name = set_name
self.mask_position = mask_position
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, sticker: types.Document, image_size_attributes: types.DocumentAttributeImageSize, set_name: str,
sticker_attributes: types.DocumentAttributeSticker, file_name: str) -> "Sticker":
diff --git a/pyrogram/client/types/messages_and_media/user_profile_photos.py b/pyrogram/client/types/messages_and_media/user_profile_photos.py
index bf53b13e..8133cae4 100644
--- a/pyrogram/client/types/messages_and_media/user_profile_photos.py
+++ b/pyrogram/client/types/messages_and_media/user_profile_photos.py
@@ -30,6 +30,8 @@ class UserProfilePhotos(PyrogramType):
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.photos = photos
diff --git a/pyrogram/client/types/messages_and_media/venue.py b/pyrogram/client/types/messages_and_media/venue.py
index 662a416f..ee533d59 100644
--- a/pyrogram/client/types/messages_and_media/venue.py
+++ b/pyrogram/client/types/messages_and_media/venue.py
@@ -43,18 +43,16 @@ class Venue(PyrogramType):
"""
- def __init__(self, location, title: str, address: str, *,
- foursquare_id: str = None, foursquare_type: str = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, location, title: str, address: str, foursquare_id: str = None,
+ foursquare_type: str = None):
+ super().__init__(client, raw)
+
self.location = location
self.title = title
self.address = address
self.foursquare_id = foursquare_id
self.foursquare_type = foursquare_type
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, venue: types.MessageMediaVenue):
return Venue(
diff --git a/pyrogram/client/types/messages_and_media/video.py b/pyrogram/client/types/messages_and_media/video.py
index 05d28f45..5115e651 100644
--- a/pyrogram/client/types/messages_and_media/video.py
+++ b/pyrogram/client/types/messages_and_media/video.py
@@ -56,9 +56,10 @@ class Video(PyrogramType):
Date the video was sent in Unix time.
"""
- def __init__(self, file_id: str, width: int, height: int, duration: int, *,
- thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, file_id: str, width: int, height: int, duration: int, thumb=None,
+ file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None):
+ super().__init__(client, raw)
+
self.file_id = file_id
self.thumb = thumb
self.file_name = file_name
@@ -69,9 +70,6 @@ class Video(PyrogramType):
self.height = height
self.duration = duration
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, video: types.Document, video_attributes: types.DocumentAttributeVideo, file_name: str) -> "Video":
return Video(
diff --git a/pyrogram/client/types/messages_and_media/video_note.py b/pyrogram/client/types/messages_and_media/video_note.py
index ddcd74f3..61a86454 100644
--- a/pyrogram/client/types/messages_and_media/video_note.py
+++ b/pyrogram/client/types/messages_and_media/video_note.py
@@ -50,9 +50,10 @@ class VideoNote(PyrogramType):
Date the video note was sent in Unix time.
"""
- def __init__(self, file_id: str, length: int, duration: int, *,
- thumb=None, mime_type: str = None, file_size: int = None, date: int = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, file_id: str, length: int, duration: int, thumb=None, mime_type: str = None,
+ file_size: int = None, date: int = None):
+ super().__init__(client, raw)
+
self.file_id = file_id
self.thumb = thumb
self.mime_type = mime_type
@@ -61,9 +62,6 @@ class VideoNote(PyrogramType):
self.length = length
self.duration = duration
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, video_note: types.Document, video_attributes: types.DocumentAttributeVideo) -> "VideoNote":
return VideoNote(
diff --git a/pyrogram/client/types/messages_and_media/voice.py b/pyrogram/client/types/messages_and_media/voice.py
index c993ea5c..88cc269e 100644
--- a/pyrogram/client/types/messages_and_media/voice.py
+++ b/pyrogram/client/types/messages_and_media/voice.py
@@ -46,9 +46,10 @@ class Voice(PyrogramType):
Date the voice was sent in Unix time.
"""
- def __init__(self, file_id: str, duration: int, *,
- waveform: bytes = None, mime_type: str = None, file_size: int = None, date: int = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, file_id: str, duration: int, waveform: bytes = None, mime_type: str = None,
+ file_size: int = None, date: int = None):
+ super().__init__(client, raw)
+
self.file_id = file_id
self.duration = duration
self.waveform = waveform
@@ -56,9 +57,6 @@ class Voice(PyrogramType):
self.file_size = file_size
self.date = date
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, voice: types.Document, attributes: types.DocumentAttributeAudio) -> "Voice":
return Voice(
diff --git a/pyrogram/client/types/pyrogram_type.py b/pyrogram/client/types/pyrogram_type.py
index ee0cfea4..f438a4ba 100644
--- a/pyrogram/client/types/pyrogram_type.py
+++ b/pyrogram/client/types/pyrogram_type.py
@@ -21,6 +21,10 @@ from json import dumps, JSONEncoder
class PyrogramType:
+ def __init__(self, client, raw):
+ self._client = client
+ self._raw = raw
+
def __str__(self):
return dumps(self, cls=Encoder, indent=4)
diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py
index 2169f1d7..d98d57aa 100644
--- a/pyrogram/client/types/user_and_chats/chat.py
+++ b/pyrogram/client/types/user_and_chats/chat.py
@@ -76,15 +76,14 @@ class Chat(PyrogramType):
The reason why this chat might be unavailable to some users.
"""
- def __init__(self, id: int, type: str, *,
- title: str = None, username: str = None, first_name: str = None, last_name: str = None,
- all_members_are_administrators: bool = None, photo=None, description: 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,
- client=None, raw=None):
+ def __init__(self, *, client, raw, id: int, type: str, title: str = None, username: str = None,
+ first_name: str = None, last_name: str = None, all_members_are_administrators: bool = None, photo=None,
+ description: 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):
+ super().__init__(client, raw)
+
self.id = id
self.type = type
-
self.title = title
self.username = username
self.first_name = first_name
@@ -99,9 +98,6 @@ class Chat(PyrogramType):
self.members_count = members_count
self.restriction_reason = restriction_reason
- self._client = client
- self._raw = raw
-
@staticmethod
def parse_user_chat(client, user: types.User) -> "Chat":
return Chat(
diff --git a/pyrogram/client/types/user_and_chats/chat_member.py b/pyrogram/client/types/user_and_chats/chat_member.py
index b3e2916b..11b2c9a0 100644
--- a/pyrogram/client/types/user_and_chats/chat_member.py
+++ b/pyrogram/client/types/user_and_chats/chat_member.py
@@ -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.
"""
- 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_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_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.status = status
self.until_date = until_date
@@ -102,9 +104,6 @@ class ChatMember(PyrogramType):
self.can_send_other_messages = can_send_other_messages
self.can_add_web_page_previews = can_add_web_page_previews
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, member, user) -> "ChatMember":
if isinstance(member, (types.ChannelParticipant, types.ChannelParticipantSelf, types.ChatParticipant)):
diff --git a/pyrogram/client/types/user_and_chats/chat_members.py b/pyrogram/client/types/user_and_chats/chat_members.py
index 4f057309..5fa8275d 100644
--- a/pyrogram/client/types/user_and_chats/chat_members.py
+++ b/pyrogram/client/types/user_and_chats/chat_members.py
@@ -33,13 +33,12 @@ class ChatMembers(PyrogramType):
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.chat_members = chat_members
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, members):
users = {i.id: i for i in members.users}
@@ -59,5 +58,6 @@ class ChatMembers(PyrogramType):
return ChatMembers(
total_count=total_count,
chat_members=chat_members,
- client=client, raw=members
+ client=client,
+ raw=members
)
diff --git a/pyrogram/client/types/user_and_chats/chat_photo.py b/pyrogram/client/types/user_and_chats/chat_photo.py
index c7ef4c80..b998cf90 100644
--- a/pyrogram/client/types/user_and_chats/chat_photo.py
+++ b/pyrogram/client/types/user_and_chats/chat_photo.py
@@ -36,14 +36,10 @@ class ChatPhoto(Object):
ID = 0xb0700015
- def __init__(self, small_file_id: str, big_file_id: str, *,
- client=None, raw=None):
+ def __init__(self, *, client, raw, small_file_id: str, big_file_id: str):
self.small_file_id = small_file_id
self.big_file_id = big_file_id
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, chat_photo: types.UserProfilePhoto or types.ChatPhoto):
if not isinstance(chat_photo, (types.UserProfilePhoto, types.ChatPhoto)):
diff --git a/pyrogram/client/types/user_and_chats/dialog.py b/pyrogram/client/types/user_and_chats/dialog.py
index 8107d363..3d4d0faf 100644
--- a/pyrogram/client/types/user_and_chats/dialog.py
+++ b/pyrogram/client/types/user_and_chats/dialog.py
@@ -16,10 +16,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from pyrogram.api.core import Object
+from ..pyrogram_type import PyrogramType
-class Dialog(Object):
+class Dialog(PyrogramType):
"""This object represents a dialog.
Args:
@@ -41,18 +41,14 @@ class Dialog(Object):
is_pinned (``bool``):
True, if the dialog is pinned.
"""
- ID = 0xb0700028
- def __init__(self,
- chat,
- top_message,
- unread_messages_count: int,
- unread_mentions_count: int,
- unread_mark: bool,
- is_pinned: bool):
+ def __init__(self, *, client, raw, chat, top_message, unread_messages_count: int, unread_mentions_count: int,
+ unread_mark: bool, is_pinned: bool):
+ super().__init__(client, raw)
+
self.chat = chat
self.top_message = top_message
self.unread_messages_count = unread_messages_count
self.unread_mentions_count = unread_mentions_count
self.unread_mark = unread_mark
- self.is_pinned = is_pinned
+ self.is_pinned = is_pinned
\ No newline at end of file
diff --git a/pyrogram/client/types/user_and_chats/dialogs.py b/pyrogram/client/types/user_and_chats/dialogs.py
index cdf1d951..030018e4 100644
--- a/pyrogram/client/types/user_and_chats/dialogs.py
+++ b/pyrogram/client/types/user_and_chats/dialogs.py
@@ -16,10 +16,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-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
Args:
@@ -29,8 +29,9 @@ class Dialogs(Object):
dialogs (List of :obj:`Dialog `):
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.dialogs = dialogs
diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py
index 80660bcc..1c1d41fe 100644
--- a/pyrogram/client/types/user_and_chats/user.py
+++ b/pyrogram/client/types/user_and_chats/user.py
@@ -69,11 +69,12 @@ class User(PyrogramType):
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,
- is_bot: bool, first_name: str, *,
- last_name: str = None, status=None, username: str = None, language_code: str = None,
- phone_number: str = None, photo=None, restriction_reason: str = None,
- client=None, raw=None):
+ def __init__(self, *, client, raw, id: int, is_self: bool, is_contact: bool, is_mutual_contact: bool,
+ is_deleted: bool, is_bot: bool, first_name: str, last_name: str = None, status=None,
+ username: str = None, language_code: str = None, phone_number: str = None, photo=None,
+ restriction_reason: str = None):
+ super().__init__(client, raw)
+
self.id = id
self.is_self = is_self
self.is_contact = is_contact
@@ -81,7 +82,6 @@ class User(PyrogramType):
self.is_deleted = is_deleted
self.is_bot = is_bot
self.first_name = first_name
-
self.last_name = last_name
self.status = status
self.username = username
@@ -90,9 +90,6 @@ class User(PyrogramType):
self.photo = photo
self.restriction_reason = restriction_reason
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, user: types.User) -> "User" or None:
if user is None:
@@ -113,5 +110,6 @@ class User(PyrogramType):
phone_number=user.phone,
photo=ChatPhoto.parse(client, user.photo),
restriction_reason=user.restriction_reason,
- client=client, raw=user
+ client=client,
+ raw=user
)
diff --git a/pyrogram/client/types/user_and_chats/user_status.py b/pyrogram/client/types/user_and_chats/user_status.py
index f99d356d..d6bfa13d 100644
--- a/pyrogram/client/types/user_and_chats/user_status.py
+++ b/pyrogram/client/types/user_and_chats/user_status.py
@@ -62,12 +62,12 @@ class UserStatus(PyrogramType):
always shown to blocked users), None otherwise.
"""
- def __init__(self, user_id: int, *,
- online: bool = None, offline: bool = None, date: int = None, recently: bool = None,
- within_week: bool = None, within_month: bool = None, long_time_ago: bool = None,
- client=None, raw=None):
- self.user_id = user_id
+ def __init__(self, *, client, raw, user_id: int, online: bool = None, offline: bool = None, date: int = None,
+ recently: bool = None, within_week: bool = None, within_month: bool = None,
+ long_time_ago: bool = None):
+ super().__init__(client, raw)
+ self.user_id = user_id
self.online = online
self.offline = offline
self.date = date
@@ -76,9 +76,6 @@ class UserStatus(PyrogramType):
self.within_month = within_month
self.long_time_ago = long_time_ago
- self._client = client
- self._raw = raw
-
@staticmethod
def parse(client, user: types.User):
if user.bot: