mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Force named arguments on Pyrogram types
This commit is contained in:
parent
7430529646
commit
c6a0bf0791
@ -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":
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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)):
|
||||
|
@ -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":
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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)):
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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)):
|
||||
|
@ -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.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
|
@ -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.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 <pyrogram.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
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user