mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Ditch raw attribute. There's no use for it now
This commit is contained in:
parent
761a07bda8
commit
dc2792fbea
@ -56,9 +56,9 @@ class CallbackQuery(PyrogramType):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, id: str, from_user, chat_instance: str, message=None,
|
||||
def __init__(self, *, client, id: str, from_user, chat_instance: str, message=None,
|
||||
inline_message_id: str = None, data: bytes = None, game_short_name: str = None):
|
||||
super().__init__(client, raw)
|
||||
super().__init__(client)
|
||||
|
||||
self.id = id
|
||||
self.from_user = from_user
|
||||
@ -103,8 +103,7 @@ class CallbackQuery(PyrogramType):
|
||||
chat_instance=str(callback_query.chat_instance),
|
||||
data=callback_query.data,
|
||||
game_short_name=callback_query.game_short_name,
|
||||
client=client,
|
||||
raw=callback_query
|
||||
client=client
|
||||
)
|
||||
|
||||
def answer(self, text: str = None, show_alert: bool = None, url: str = None, cache_time: int = 0):
|
||||
|
@ -34,12 +34,12 @@ class ForceReply(PyrogramType):
|
||||
"""
|
||||
|
||||
def __init__(self, selective: bool = None):
|
||||
super().__init__(None, None)
|
||||
super().__init__(None)
|
||||
|
||||
self.selective = selective
|
||||
|
||||
@staticmethod
|
||||
def read(o, *args):
|
||||
def read(o):
|
||||
return ForceReply(
|
||||
selective=o.selective
|
||||
)
|
||||
|
@ -55,7 +55,7 @@ class InlineKeyboardButton(PyrogramType):
|
||||
|
||||
def __init__(self, text: str, callback_data: bytes = None, url: str = None,
|
||||
switch_inline_query: str = None, switch_inline_query_current_chat: str = None):
|
||||
super().__init__(None, None)
|
||||
super().__init__(None)
|
||||
|
||||
self.text = text
|
||||
self.url = url
|
||||
@ -66,29 +66,29 @@ class InlineKeyboardButton(PyrogramType):
|
||||
# self.pay = pay
|
||||
|
||||
@staticmethod
|
||||
def read(b, *args):
|
||||
if isinstance(b, KeyboardButtonUrl):
|
||||
def read(o):
|
||||
if isinstance(o, KeyboardButtonUrl):
|
||||
return InlineKeyboardButton(
|
||||
text=b.text,
|
||||
url=b.url
|
||||
text=o.text,
|
||||
url=o.url
|
||||
)
|
||||
|
||||
if isinstance(b, KeyboardButtonCallback):
|
||||
if isinstance(o, KeyboardButtonCallback):
|
||||
return InlineKeyboardButton(
|
||||
text=b.text,
|
||||
callback_data=b.data
|
||||
text=o.text,
|
||||
callback_data=o.data
|
||||
)
|
||||
|
||||
if isinstance(b, KeyboardButtonSwitchInline):
|
||||
if b.same_peer:
|
||||
if isinstance(o, KeyboardButtonSwitchInline):
|
||||
if o.same_peer:
|
||||
return InlineKeyboardButton(
|
||||
text=b.text,
|
||||
switch_inline_query_current_chat=b.query
|
||||
text=o.text,
|
||||
switch_inline_query_current_chat=o.query
|
||||
)
|
||||
else:
|
||||
return InlineKeyboardButton(
|
||||
text=b.text,
|
||||
switch_inline_query=b.query
|
||||
text=o.text,
|
||||
switch_inline_query=o.query
|
||||
)
|
||||
|
||||
def write(self):
|
||||
|
@ -30,15 +30,15 @@ class InlineKeyboardMarkup(PyrogramType):
|
||||
"""
|
||||
|
||||
def __init__(self, inline_keyboard: list):
|
||||
super().__init__(None, None)
|
||||
super().__init__(None)
|
||||
|
||||
self.inline_keyboard = inline_keyboard
|
||||
|
||||
@staticmethod
|
||||
def read(kb, *args):
|
||||
def read(o):
|
||||
inline_keyboard = []
|
||||
|
||||
for i in kb.rows:
|
||||
for i in o.rows:
|
||||
row = []
|
||||
|
||||
for j in i.buttons:
|
||||
|
@ -41,26 +41,26 @@ class KeyboardButton(PyrogramType):
|
||||
"""
|
||||
|
||||
def __init__(self, text: str, request_contact: bool = None, request_location: bool = None):
|
||||
super().__init__(None, None)
|
||||
super().__init__(None)
|
||||
|
||||
self.text = text
|
||||
self.request_contact = request_contact
|
||||
self.request_location = request_location
|
||||
|
||||
@staticmethod
|
||||
def read(b, *args):
|
||||
if isinstance(b, RawKeyboardButton):
|
||||
return b.text
|
||||
def read(o):
|
||||
if isinstance(o, RawKeyboardButton):
|
||||
return o.text
|
||||
|
||||
if isinstance(b, KeyboardButtonRequestPhone):
|
||||
if isinstance(o, KeyboardButtonRequestPhone):
|
||||
return KeyboardButton(
|
||||
text=b.text,
|
||||
text=o.text,
|
||||
request_contact=True
|
||||
)
|
||||
|
||||
if isinstance(b, KeyboardButtonRequestGeoLocation):
|
||||
if isinstance(o, KeyboardButtonRequestGeoLocation):
|
||||
return KeyboardButton(
|
||||
text=b.text,
|
||||
text=o.text,
|
||||
request_location=True
|
||||
)
|
||||
|
||||
|
@ -49,7 +49,7 @@ class ReplyKeyboardMarkup(PyrogramType):
|
||||
|
||||
def __init__(self, keyboard: list, resize_keyboard: bool = None, one_time_keyboard: bool = None,
|
||||
selective: bool = None):
|
||||
super().__init__(None, None)
|
||||
super().__init__(None)
|
||||
|
||||
self.keyboard = keyboard
|
||||
self.resize_keyboard = resize_keyboard
|
||||
@ -57,7 +57,7 @@ class ReplyKeyboardMarkup(PyrogramType):
|
||||
self.selective = selective
|
||||
|
||||
@staticmethod
|
||||
def read(kb, *args):
|
||||
def read(kb):
|
||||
keyboard = []
|
||||
|
||||
for i in kb.rows:
|
||||
|
@ -36,12 +36,12 @@ class ReplyKeyboardRemove(PyrogramType):
|
||||
"""
|
||||
|
||||
def __init__(self, selective: bool = None):
|
||||
super().__init__(None, None)
|
||||
super().__init__(None)
|
||||
|
||||
self.selective = selective
|
||||
|
||||
@staticmethod
|
||||
def read(o, *args):
|
||||
def read(o):
|
||||
return ReplyKeyboardRemove(
|
||||
selective=o.selective
|
||||
)
|
||||
|
@ -56,9 +56,9 @@ class Animation(PyrogramType):
|
||||
Date the animation was sent in Unix time.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, file_id: str, width: int, height: int, duration: int, thumb=None,
|
||||
def __init__(self, *, client, 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)
|
||||
super().__init__(client)
|
||||
|
||||
self.file_id = file_id
|
||||
self.thumb = thumb
|
||||
@ -91,6 +91,5 @@ class Animation(PyrogramType):
|
||||
file_size=animation.size,
|
||||
file_name=file_name,
|
||||
date=animation.date,
|
||||
client=client,
|
||||
raw=animation
|
||||
client=client
|
||||
)
|
||||
|
@ -56,10 +56,10 @@ class Audio(PyrogramType):
|
||||
Title of the audio as defined by sender or by audio tags.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, file_id: str, duration: int, thumb=None, file_name: str = None,
|
||||
def __init__(self, *, client, 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)
|
||||
super().__init__(client)
|
||||
|
||||
self.file_id = file_id
|
||||
self.thumb = thumb
|
||||
@ -91,6 +91,5 @@ class Audio(PyrogramType):
|
||||
thumb=PhotoSize.parse(client, audio.thumb),
|
||||
file_name=file_name,
|
||||
date=audio.date,
|
||||
client=client,
|
||||
raw=audio
|
||||
client=client
|
||||
)
|
||||
|
@ -40,9 +40,9 @@ class Contact(PyrogramType):
|
||||
Additional data about the contact in the form of a vCard.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, phone_number: str, first_name: str, last_name: str = None, user_id: int = None,
|
||||
def __init__(self, *, client, phone_number: str, first_name: str, last_name: str = None, user_id: int = None,
|
||||
vcard: str = None):
|
||||
super().__init__(client, raw)
|
||||
super().__init__(client)
|
||||
|
||||
self.phone_number = phone_number
|
||||
self.first_name = first_name
|
||||
@ -58,6 +58,5 @@ class Contact(PyrogramType):
|
||||
last_name=contact.last_name or None,
|
||||
vcard=contact.vcard or None,
|
||||
user_id=contact.user_id or None,
|
||||
client=client,
|
||||
raw=contact
|
||||
client=client
|
||||
)
|
||||
|
@ -47,9 +47,9 @@ class Document(PyrogramType):
|
||||
Date the document was sent in Unix time.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, file_id: str, thumb=None, file_name: str = None, mime_type: str = None,
|
||||
def __init__(self, *, client, file_id: str, thumb=None, file_name: str = None, mime_type: str = None,
|
||||
file_size: int = None, date: int = None):
|
||||
super().__init__(client, raw)
|
||||
super().__init__(client)
|
||||
|
||||
self.file_id = file_id
|
||||
self.thumb = thumb
|
||||
@ -75,6 +75,5 @@ class Document(PyrogramType):
|
||||
mime_type=document.mime_type,
|
||||
file_size=document.size,
|
||||
date=document.date,
|
||||
client=client,
|
||||
raw=document
|
||||
client=client
|
||||
)
|
||||
|
@ -31,8 +31,8 @@ class Location(PyrogramType):
|
||||
Latitude as defined by sender.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, longitude: float, latitude: float, ):
|
||||
super().__init__(client, raw)
|
||||
def __init__(self, *, client, longitude: float, latitude: float, ):
|
||||
super().__init__(client)
|
||||
|
||||
self.longitude = longitude
|
||||
self.latitude = latitude
|
||||
@ -43,6 +43,5 @@ class Location(PyrogramType):
|
||||
return Location(
|
||||
longitude=geo_point.long,
|
||||
latitude=geo_point.lat,
|
||||
client=client,
|
||||
raw=geo_point
|
||||
client=client
|
||||
)
|
||||
|
@ -224,7 +224,7 @@ class Message(PyrogramType):
|
||||
|
||||
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
|
||||
|
||||
def __init__(self, *, client, raw, message_id: int, date: int = None, chat=None, from_user=None, forward_from=None,
|
||||
def __init__(self, *, client, 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,
|
||||
@ -236,7 +236,7 @@ class Message(PyrogramType):
|
||||
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)
|
||||
super().__init__(client)
|
||||
|
||||
self.message_id = message_id
|
||||
self.date = date
|
||||
@ -293,11 +293,7 @@ class Message(PyrogramType):
|
||||
def parse(client, message: types.Message or types.MessageService or types.MessageEmpty, users: dict, chats: dict,
|
||||
replies: int = 1):
|
||||
if isinstance(message, types.MessageEmpty):
|
||||
return Message(
|
||||
message_id=message.id,
|
||||
client=client,
|
||||
raw=message
|
||||
)
|
||||
return Message(message_id=message.id, empty=True, client=client)
|
||||
|
||||
if isinstance(message, types.MessageService):
|
||||
action = message.action
|
||||
@ -348,8 +344,7 @@ class Message(PyrogramType):
|
||||
migrate_from_chat_id=-migrate_from_chat_id if migrate_from_chat_id else None,
|
||||
group_chat_created=group_chat_created,
|
||||
channel_chat_created=channel_chat_created,
|
||||
client=client,
|
||||
raw=message
|
||||
client=client
|
||||
# TODO: supergroup_chat_created
|
||||
)
|
||||
|
||||
@ -504,8 +499,7 @@ class Message(PyrogramType):
|
||||
via_bot=User.parse(client, users.get(message.via_bot_id, None)),
|
||||
outgoing=message.out,
|
||||
reply_markup=reply_markup,
|
||||
client=client,
|
||||
raw=message
|
||||
client=client
|
||||
)
|
||||
|
||||
if message.reply_to_msg_id and replies:
|
||||
|
@ -61,8 +61,8 @@ class MessageEntity(PyrogramType):
|
||||
types.MessageEntityPhone.ID: "phone_number"
|
||||
}
|
||||
|
||||
def __init__(self, *, client, raw, type: str, offset: int, length: int, url: str = None, user=None):
|
||||
super().__init__(client, raw)
|
||||
def __init__(self, *, client, type: str, offset: int, length: int, url: str = None, user=None):
|
||||
super().__init__(client)
|
||||
|
||||
self.type = type
|
||||
self.offset = offset
|
||||
@ -83,6 +83,5 @@ class MessageEntity(PyrogramType):
|
||||
length=entity.length,
|
||||
url=getattr(entity, "url", None),
|
||||
user=User.parse(client, users.get(getattr(entity, "user_id", None), None)),
|
||||
client=client,
|
||||
raw=entity
|
||||
client=client
|
||||
)
|
||||
|
@ -33,8 +33,8 @@ class Messages(PyrogramType):
|
||||
Requested messages.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, total_count: int, messages: list):
|
||||
super().__init__(client, raw)
|
||||
def __init__(self, *, client, total_count: int, messages: list):
|
||||
super().__init__(client)
|
||||
|
||||
self.total_count = total_count
|
||||
self.messages = messages
|
||||
@ -47,8 +47,7 @@ class Messages(PyrogramType):
|
||||
return Messages(
|
||||
total_count=getattr(messages, "count", len(messages.messages)),
|
||||
messages=[Message.parse(client, message, users, chats) for message in messages.messages],
|
||||
client=client,
|
||||
raw=messages
|
||||
client=client
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@ -65,17 +64,14 @@ class Messages(PyrogramType):
|
||||
chat=Chat(
|
||||
id=int("-100" + str(channel_id)),
|
||||
type="channel",
|
||||
client=client,
|
||||
raw=None
|
||||
client=client
|
||||
) if channel_id is not None else None,
|
||||
client=client,
|
||||
raw=None
|
||||
client=client
|
||||
)
|
||||
)
|
||||
|
||||
return Messages(
|
||||
total_count=len(parsed_messages),
|
||||
messages=parsed_messages,
|
||||
client=client,
|
||||
raw=update
|
||||
client=client
|
||||
)
|
||||
|
@ -39,8 +39,8 @@ class Photo(PyrogramType):
|
||||
Available sizes of this photo.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, id: str, date: int, sizes: list):
|
||||
super().__init__(client, raw)
|
||||
def __init__(self, *, client, id: str, date: int, sizes: list):
|
||||
super().__init__(client)
|
||||
|
||||
self.id = id
|
||||
self.date = date
|
||||
@ -74,8 +74,7 @@ class Photo(PyrogramType):
|
||||
width=raw_size.w,
|
||||
height=raw_size.h,
|
||||
file_size=file_size,
|
||||
client=client,
|
||||
raw=raw_size
|
||||
client=client
|
||||
)
|
||||
|
||||
sizes.append(size)
|
||||
@ -91,6 +90,5 @@ class Photo(PyrogramType):
|
||||
).decode().rstrip("="),
|
||||
date=photo.date,
|
||||
sizes=sizes,
|
||||
client=client,
|
||||
raw=photo
|
||||
client=client
|
||||
)
|
||||
|
@ -40,8 +40,8 @@ class PhotoSize(PyrogramType):
|
||||
File size.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, file_id: str, width: int, height: int, file_size: int):
|
||||
super().__init__(client, raw)
|
||||
def __init__(self, *, client, file_id: str, width: int, height: int, file_size: int):
|
||||
super().__init__(client)
|
||||
|
||||
self.file_id = file_id
|
||||
self.width = width
|
||||
@ -71,6 +71,5 @@ class PhotoSize(PyrogramType):
|
||||
width=photo_size.w,
|
||||
height=photo_size.h,
|
||||
file_size=file_size,
|
||||
client=client,
|
||||
raw=photo_size
|
||||
client=client
|
||||
)
|
||||
|
@ -63,10 +63,10 @@ class Sticker(PyrogramType):
|
||||
|
||||
# TODO: Add mask position
|
||||
|
||||
def __init__(self, *, client, raw, file_id: str, width: int, height: int, thumb=None, file_name: str = None,
|
||||
def __init__(self, *, client, 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)
|
||||
super().__init__(client)
|
||||
|
||||
self.file_id = file_id
|
||||
self.thumb = thumb
|
||||
@ -123,6 +123,5 @@ class Sticker(PyrogramType):
|
||||
mime_type=sticker.mime_type,
|
||||
file_name=file_name,
|
||||
date=sticker.date,
|
||||
client=client,
|
||||
raw=sticker
|
||||
client=client
|
||||
)
|
||||
|
@ -31,8 +31,8 @@ class UserProfilePhotos(PyrogramType):
|
||||
Requested profile pictures.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, total_count: int, photos: list):
|
||||
super().__init__(client, raw)
|
||||
def __init__(self, *, client, total_count: int, photos: list):
|
||||
super().__init__(client)
|
||||
|
||||
self.total_count = total_count
|
||||
self.photos = photos
|
||||
@ -42,6 +42,5 @@ class UserProfilePhotos(PyrogramType):
|
||||
return UserProfilePhotos(
|
||||
total_count=getattr(photos, "count", len(photos.photos)),
|
||||
photos=[Photo.parse(client, photo) for photo in photos.photos],
|
||||
client=client,
|
||||
raw=photos
|
||||
client=client
|
||||
)
|
||||
|
@ -43,9 +43,9 @@ class Venue(PyrogramType):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, location, title: str, address: str, foursquare_id: str = None,
|
||||
def __init__(self, *, client, location, title: str, address: str, foursquare_id: str = None,
|
||||
foursquare_type: str = None):
|
||||
super().__init__(client, raw)
|
||||
super().__init__(client)
|
||||
|
||||
self.location = location
|
||||
self.title = title
|
||||
@ -61,6 +61,5 @@ class Venue(PyrogramType):
|
||||
address=venue.address,
|
||||
foursquare_id=venue.venue_id or None,
|
||||
foursquare_type=venue.venue_type,
|
||||
client=client,
|
||||
raw=venue
|
||||
client=client
|
||||
)
|
||||
|
@ -56,9 +56,9 @@ class Video(PyrogramType):
|
||||
Date the video was sent in Unix time.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, file_id: str, width: int, height: int, duration: int, thumb=None,
|
||||
def __init__(self, *, client, 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)
|
||||
super().__init__(client)
|
||||
|
||||
self.file_id = file_id
|
||||
self.thumb = thumb
|
||||
@ -90,6 +90,5 @@ class Video(PyrogramType):
|
||||
file_size=video.size,
|
||||
file_name=file_name,
|
||||
date=video.date,
|
||||
client=client,
|
||||
raw=video
|
||||
client=client
|
||||
)
|
||||
|
@ -50,9 +50,9 @@ class VideoNote(PyrogramType):
|
||||
Date the video note was sent in Unix time.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, file_id: str, length: int, duration: int, thumb=None, mime_type: str = None,
|
||||
def __init__(self, *, client, file_id: str, length: int, duration: int, thumb=None, mime_type: str = None,
|
||||
file_size: int = None, date: int = None):
|
||||
super().__init__(client, raw)
|
||||
super().__init__(client)
|
||||
|
||||
self.file_id = file_id
|
||||
self.thumb = thumb
|
||||
@ -79,5 +79,6 @@ class VideoNote(PyrogramType):
|
||||
thumb=PhotoSize.parse(client, video_note.thumb),
|
||||
file_size=video_note.size,
|
||||
mime_type=video_note.mime_type,
|
||||
date=video_note.date
|
||||
date=video_note.date,
|
||||
client=client
|
||||
)
|
||||
|
@ -46,9 +46,9 @@ class Voice(PyrogramType):
|
||||
Date the voice was sent in Unix time.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, file_id: str, duration: int, waveform: bytes = None, mime_type: str = None,
|
||||
def __init__(self, *, client, file_id: str, duration: int, waveform: bytes = None, mime_type: str = None,
|
||||
file_size: int = None, date: int = None):
|
||||
super().__init__(client, raw)
|
||||
super().__init__(client)
|
||||
|
||||
self.file_id = file_id
|
||||
self.duration = duration
|
||||
@ -74,6 +74,5 @@ class Voice(PyrogramType):
|
||||
file_size=voice.size,
|
||||
waveform=attributes.waveform,
|
||||
date=voice.date,
|
||||
client=client,
|
||||
raw=voice
|
||||
client=client
|
||||
)
|
||||
|
@ -21,9 +21,8 @@ from json import dumps, JSONEncoder
|
||||
|
||||
|
||||
class PyrogramType:
|
||||
def __init__(self, client, raw):
|
||||
def __init__(self, client):
|
||||
self._client = client
|
||||
self._raw = raw
|
||||
|
||||
def __str__(self):
|
||||
return dumps(self, cls=Encoder, indent=4)
|
||||
|
@ -76,11 +76,11 @@ class Chat(PyrogramType):
|
||||
The reason why this chat might be unavailable to some users.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, id: int, type: str, title: str = None, username: str = None,
|
||||
def __init__(self, *, client, 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)
|
||||
super().__init__(client)
|
||||
|
||||
self.id = id
|
||||
self.type = type
|
||||
@ -108,7 +108,7 @@ class Chat(PyrogramType):
|
||||
last_name=user.last_name,
|
||||
photo=ChatPhoto.parse(client, user.photo),
|
||||
restriction_reason=user.restriction_reason,
|
||||
client=client, raw=user
|
||||
client=client
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@ -124,7 +124,7 @@ class Chat(PyrogramType):
|
||||
title=chat.title,
|
||||
all_members_are_administrators=admins_enabled,
|
||||
photo=ChatPhoto.parse(client, getattr(chat, "photo", None)),
|
||||
client=client, raw=chat
|
||||
client=client
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@ -136,7 +136,7 @@ class Chat(PyrogramType):
|
||||
username=getattr(channel, "username", None),
|
||||
photo=ChatPhoto.parse(client, getattr(channel, "photo", None)),
|
||||
restriction_reason=getattr(channel, "restriction_reason", None),
|
||||
client=client, raw=channel
|
||||
client=client
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
@ -79,13 +79,13 @@ class ChatMember(PyrogramType):
|
||||
Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, user, status: str, until_date: int = None, can_be_edited: bool = None,
|
||||
def __init__(self, *, client, 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):
|
||||
super().__init__(client, raw)
|
||||
super().__init__(client)
|
||||
|
||||
self.user = user
|
||||
self.status = status
|
||||
@ -107,13 +107,13 @@ class ChatMember(PyrogramType):
|
||||
@staticmethod
|
||||
def parse(client, member, user) -> "ChatMember":
|
||||
if isinstance(member, (types.ChannelParticipant, types.ChannelParticipantSelf, types.ChatParticipant)):
|
||||
return ChatMember(user=user, status="member", client=client, raw=member)
|
||||
return ChatMember(user=user, status="member", client=client)
|
||||
|
||||
if isinstance(member, (types.ChannelParticipantCreator, types.ChatParticipantCreator)):
|
||||
return ChatMember(user=user, status="creator", client=client, raw=member)
|
||||
return ChatMember(user=user, status="creator", client=client)
|
||||
|
||||
if isinstance(member, types.ChatParticipantAdmin):
|
||||
return ChatMember(user=user, status="administrator", client=client, raw=member)
|
||||
return ChatMember(user=user, status="administrator", client=client)
|
||||
|
||||
if isinstance(member, types.ChannelParticipantAdmin):
|
||||
rights = member.admin_rights
|
||||
@ -130,7 +130,7 @@ class ChatMember(PyrogramType):
|
||||
can_restrict_members=rights.ban_users,
|
||||
can_pin_messages=rights.pin_messages,
|
||||
can_promote_members=rights.add_admins,
|
||||
client=client, raw=member
|
||||
client=client
|
||||
)
|
||||
|
||||
if isinstance(member, types.ChannelParticipantBanned):
|
||||
@ -140,7 +140,7 @@ class ChatMember(PyrogramType):
|
||||
user=user,
|
||||
status="kicked" if rights.view_messages else "restricted",
|
||||
until_date=0 if rights.until_date == (1 << 31) - 1 else rights.until_date,
|
||||
client=client, raw=member
|
||||
client=client
|
||||
)
|
||||
|
||||
if chat_member.status == "restricted":
|
||||
|
@ -33,8 +33,8 @@ class ChatMembers(PyrogramType):
|
||||
Requested chat members.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, total_count: int, chat_members: list):
|
||||
super().__init__(client, raw)
|
||||
def __init__(self, *, client, total_count: int, chat_members: list):
|
||||
super().__init__(client)
|
||||
|
||||
self.total_count = total_count
|
||||
self.chat_members = chat_members
|
||||
@ -58,6 +58,5 @@ class ChatMembers(PyrogramType):
|
||||
return ChatMembers(
|
||||
total_count=total_count,
|
||||
chat_members=chat_members,
|
||||
client=client,
|
||||
raw=members
|
||||
client=client
|
||||
)
|
||||
|
@ -19,11 +19,11 @@
|
||||
from struct import pack
|
||||
|
||||
from pyrogram.api import types
|
||||
from pyrogram.api.core import Object
|
||||
from ..pyrogram_type import PyrogramType
|
||||
from ...ext.utils import encode
|
||||
|
||||
|
||||
class ChatPhoto(Object):
|
||||
class ChatPhoto(PyrogramType):
|
||||
"""This object represents a chat photo.
|
||||
|
||||
Args:
|
||||
@ -34,9 +34,9 @@ class ChatPhoto(Object):
|
||||
Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download.
|
||||
"""
|
||||
|
||||
ID = 0xb0700015
|
||||
def __init__(self, *, client, small_file_id: str, big_file_id: str):
|
||||
super().__init__(client)
|
||||
|
||||
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
|
||||
|
||||
@ -68,6 +68,5 @@ class ChatPhoto(Object):
|
||||
1, loc_big.dc_id, photo_id, 0, loc_big.volume_id, loc_big.secret, loc_big.local_id
|
||||
)
|
||||
),
|
||||
client=client,
|
||||
raw=chat_photo
|
||||
client=client
|
||||
)
|
||||
|
@ -44,9 +44,9 @@ class Dialog(PyrogramType):
|
||||
True, if the dialog is pinned.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, chat, top_message, unread_messages_count: int, unread_mentions_count: int,
|
||||
def __init__(self, *, client, chat, top_message, unread_messages_count: int, unread_mentions_count: int,
|
||||
unread_mark: bool, is_pinned: bool):
|
||||
super().__init__(client, raw)
|
||||
super().__init__(client)
|
||||
|
||||
self.chat = chat
|
||||
self.top_message = top_message
|
||||
@ -73,6 +73,5 @@ class Dialog(PyrogramType):
|
||||
unread_mentions_count=dialog.unread_mentions_count,
|
||||
unread_mark=dialog.unread_mark,
|
||||
is_pinned=dialog.pinned,
|
||||
client=client,
|
||||
raw=dialog
|
||||
client=client
|
||||
)
|
||||
|
@ -33,8 +33,8 @@ class Dialogs(PyrogramType):
|
||||
Requested dialogs.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, total_count: int, dialogs: list):
|
||||
super().__init__(client, raw)
|
||||
def __init__(self, *, client, total_count: int, dialogs: list):
|
||||
super().__init__(client)
|
||||
|
||||
self.total_count = total_count
|
||||
self.dialogs = dialogs
|
||||
@ -64,6 +64,5 @@ class Dialogs(PyrogramType):
|
||||
return Dialogs(
|
||||
total_count=getattr(dialogs, "count", len(dialogs.dialogs)),
|
||||
dialogs=[Dialog.parse(client, dialog, messages, users, chats) for dialog in dialogs.dialogs],
|
||||
client=client,
|
||||
raw=dialogs
|
||||
client=client
|
||||
)
|
||||
|
@ -69,11 +69,11 @@ class User(PyrogramType):
|
||||
The reason why this bot might be unavailable to some users.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, id: int, is_self: bool, is_contact: bool, is_mutual_contact: bool,
|
||||
def __init__(self, *, client, 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)
|
||||
super().__init__(client)
|
||||
|
||||
self.id = id
|
||||
self.is_self = is_self
|
||||
@ -110,6 +110,5 @@ class User(PyrogramType):
|
||||
phone_number=user.phone,
|
||||
photo=ChatPhoto.parse(client, user.photo),
|
||||
restriction_reason=user.restriction_reason,
|
||||
client=client,
|
||||
raw=user
|
||||
client=client
|
||||
)
|
||||
|
@ -62,10 +62,10 @@ class UserStatus(PyrogramType):
|
||||
always shown to blocked users), None otherwise.
|
||||
"""
|
||||
|
||||
def __init__(self, *, client, raw, user_id: int, online: bool = None, offline: bool = None, date: int = None,
|
||||
def __init__(self, *, client, 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)
|
||||
super().__init__(client)
|
||||
|
||||
self.user_id = user_id
|
||||
self.online = online
|
||||
@ -81,7 +81,7 @@ class UserStatus(PyrogramType):
|
||||
if is_bot:
|
||||
return None
|
||||
|
||||
status = UserStatus(user_id=user_id, client=client, raw=user_status)
|
||||
status = UserStatus(user_id=user_id, client=client)
|
||||
|
||||
if isinstance(user_status, types.UserStatusOnline):
|
||||
status.online = True
|
||||
|
Loading…
Reference in New Issue
Block a user