2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-25 11:28:05 +00:00

Revert to the old style

This commit is contained in:
Dan 2018-12-19 10:59:24 +01:00
parent a13707a3b5
commit 26ef8ea953
38 changed files with 338 additions and 74 deletions

View File

@ -56,8 +56,16 @@ class CallbackQuery(PyrogramType):
""" """
def __init__(self, *, client, id: str, from_user, chat_instance: str, message=None, def __init__(self,
inline_message_id: str = None, data: bytes = None, game_short_name: str = None): *,
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) super().__init__(client)
self.id = id self.id = id

View File

@ -33,7 +33,8 @@ class ForceReply(PyrogramType):
2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
""" """
def __init__(self, selective: bool = None): def __init__(self,
selective: bool = None):
super().__init__(None) super().__init__(None)
self.selective = selective self.selective = selective

View File

@ -53,8 +53,12 @@ class InlineKeyboardButton(PyrogramType):
# TODO: Add callback_game and pay fields # TODO: Add callback_game and pay fields
def __init__(self, text: str, callback_data: bytes = None, url: str = None, def __init__(self,
switch_inline_query: str = None, switch_inline_query_current_chat: str = None): text: str,
callback_data: bytes = None,
url: str = None,
switch_inline_query: str = None,
switch_inline_query_current_chat: str = None):
super().__init__(None) super().__init__(None)
self.text = text self.text = text

View File

@ -29,7 +29,8 @@ class InlineKeyboardMarkup(PyrogramType):
List of button rows, each represented by a List of InlineKeyboardButton objects. List of button rows, each represented by a List of InlineKeyboardButton objects.
""" """
def __init__(self, inline_keyboard: list): def __init__(self,
inline_keyboard: list):
super().__init__(None) super().__init__(None)
self.inline_keyboard = inline_keyboard self.inline_keyboard = inline_keyboard

View File

@ -40,7 +40,10 @@ class KeyboardButton(PyrogramType):
Available in private chats only. Available in private chats only.
""" """
def __init__(self, text: str, request_contact: bool = None, request_location: bool = None): def __init__(self,
text: str,
request_contact: bool = None,
request_location: bool = None):
super().__init__(None) super().__init__(None)
self.text = text self.text = text

View File

@ -47,7 +47,10 @@ class ReplyKeyboardMarkup(PyrogramType):
select the new language. Other users in the group don't see the keyboard. select the new language. Other users in the group don't see the keyboard.
""" """
def __init__(self, keyboard: list, resize_keyboard: bool = None, one_time_keyboard: bool = None, def __init__(self,
keyboard: list,
resize_keyboard: bool = None,
one_time_keyboard: bool = None,
selective: bool = None): selective: bool = None):
super().__init__(None) super().__init__(None)

View File

@ -35,7 +35,8 @@ class ReplyKeyboardRemove(PyrogramType):
keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet. keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.
""" """
def __init__(self, selective: bool = None): def __init__(self,
selective: bool = None):
super().__init__(None) super().__init__(None)
self.selective = selective self.selective = selective

View File

@ -18,7 +18,10 @@
class InputMedia: class InputMedia:
def __init__(self, media: str, caption: str, parse_mode: str): def __init__(self,
media: str,
caption: str,
parse_mode: str):
self.media = media self.media = media
self.caption = caption self.caption = caption
self.parse_mode = parse_mode self.parse_mode = parse_mode

View File

@ -52,8 +52,14 @@ class InputMediaAnimation(InputMedia):
Animation duration. Animation duration.
""" """
def __init__(self, media: str, thumb: str = None, caption: str = "", parse_mode: str = "", width: int = 0, def __init__(self,
height: int = 0, duration: int = 0): media: str,
thumb: str = None,
caption: str = "",
parse_mode: str = "",
width: int = 0,
height: int = 0,
duration: int = 0):
super().__init__(media, caption, parse_mode) super().__init__(media, caption, parse_mode)
self.thumb = thumb self.thumb = thumb

View File

@ -53,8 +53,14 @@ class InputMediaAudio(InputMedia):
Title of the audio Title of the audio
""" """
def __init__(self, media: str, thumb: str = None, caption: str = "", parse_mode: str = "", duration: int = 0, def __init__(self,
performer: int = "", title: str = ""): media: str,
thumb: str = None,
caption: str = "",
parse_mode: str = "",
duration: int = 0,
performer: int = "",
title: str = ""):
super().__init__(media, caption, parse_mode) super().__init__(media, caption, parse_mode)
self.thumb = thumb self.thumb = thumb

View File

@ -43,7 +43,11 @@ class InputMediaDocument(InputMedia):
Defaults to Markdown. Defaults to Markdown.
""" """
def __init__(self, media: str, thumb: str = None, caption: str = "", parse_mode: str = ""): def __init__(self,
media: str,
thumb: str = None,
caption: str = "",
parse_mode: str = ""):
super().__init__(media, caption, parse_mode) super().__init__(media, caption, parse_mode)
self.thumb = thumb self.thumb = thumb

View File

@ -39,5 +39,8 @@ class InputMediaPhoto(InputMedia):
Defaults to Markdown. Defaults to Markdown.
""" """
def __init__(self, media: str, caption: str = "", parse_mode: str = ""): def __init__(self,
media: str,
caption: str = "",
parse_mode: str = ""):
super().__init__(media, caption, parse_mode) super().__init__(media, caption, parse_mode)

View File

@ -57,8 +57,15 @@ class InputMediaVideo(InputMedia):
Pass True, if the uploaded video is suitable for streaming. Pass True, if the uploaded video is suitable for streaming.
""" """
def __init__(self, media: str, thumb: str = None, caption: str = "", parse_mode: str = "", width: int = 0, def __init__(self,
height: int = 0, duration: int = 0, supports_streaming: bool = True): media: str,
thumb: str = None,
caption: str = "",
parse_mode: str = "",
width: int = 0,
height: int = 0,
duration: int = 0,
supports_streaming: bool = True):
super().__init__(media, caption, parse_mode) super().__init__(media, caption, parse_mode)
self.thumb = thumb self.thumb = thumb

View File

@ -35,10 +35,16 @@ class InputPhoneContact:
Contact's last name Contact's last name
""" """
def __init__(self, phone: str, first_name: str, last_name: str = ""): def __init__(self,
phone: str,
first_name: str,
last_name: str = ""):
pass pass
def __new__(cls, phone: str, first_name: str, last_name: str = ""): def __new__(cls,
phone: str,
first_name: str,
last_name: str = ""):
return RawInputPhoneContact( return RawInputPhoneContact(
client_id=MsgId(), client_id=MsgId(),
phone="+" + phone.strip("+"), phone="+" + phone.strip("+"),

View File

@ -56,8 +56,18 @@ class Animation(PyrogramType):
Date the animation was sent in Unix time. Date the animation was sent in Unix time.
""" """
def __init__(self, *, client, file_id: str, width: int, height: int, duration: int, thumb=None, def __init__(self,
file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None): *,
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) super().__init__(client)
self.file_id = file_id self.file_id = file_id

View File

@ -56,8 +56,17 @@ 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, *, client, file_id: str, duration: int, thumb=None, file_name: str = None, def __init__(self,
mime_type: str = None, file_size: int = None, date: int = None, performer: str = None, *,
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): title: str = None):
super().__init__(client) super().__init__(client)

View File

@ -40,7 +40,13 @@ 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, *, client, 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): vcard: str = None):
super().__init__(client) super().__init__(client)

View File

@ -47,8 +47,15 @@ class Document(PyrogramType):
Date the document was sent in Unix time. Date the document was sent in Unix time.
""" """
def __init__(self, *, client, file_id: str, thumb=None, file_name: str = None, mime_type: str = None, def __init__(self,
file_size: int = None, date: int = None): *,
client,
file_id: str,
thumb=None,
file_name: str = None,
mime_type: str = None,
file_size: int = None,
date: int = None):
super().__init__(client) super().__init__(client)
self.file_id = file_id self.file_id = file_id

View File

@ -31,7 +31,7 @@ class Location(PyrogramType):
Latitude as defined by sender. Latitude as defined by sender.
""" """
def __init__(self, *, client, longitude: float, latitude: float, ): def __init__(self, *, client, longitude: float, latitude: float):
super().__init__(client) super().__init__(client)
self.longitude = longitude self.longitude = longitude

View File

@ -224,18 +224,59 @@ 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, *, client, message_id: int, date: int = None, chat=None, from_user=None, forward_from=None, def __init__(self,
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, client,
edit_date: int = None, media_group_id: str = None, author_signature: str = None, text: str = None, message_id: int,
entities: list = None, caption_entities: list = None, audio=None, document=None, photo=None, date: int = None,
sticker=None, animation=None, video=None, voice=None, video_note=None, caption: str = None, chat=None,
contact=None, location=None, venue=None, web_page=None, new_chat_members: list = None, from_user=None,
left_chat_member=None, new_chat_title: str = None, new_chat_photo=None, delete_chat_photo: bool = None, forward_from=None,
group_chat_created: bool = None, supergroup_chat_created: bool = None, forward_from_chat=None,
channel_chat_created: bool = None, migrate_to_chat_id: int = None, migrate_from_chat_id: int = None, forward_from_message_id: int = None,
pinned_message=None, views: int = None, via_bot=None, outgoing: bool = None, matches: list = None, forward_signature: str = None,
command: list = None, reply_markup=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) super().__init__(client)
self.message_id = message_id self.message_id = message_id

View File

@ -61,7 +61,14 @@ class MessageEntity(PyrogramType):
types.MessageEntityPhone.ID: "phone_number" types.MessageEntityPhone.ID: "phone_number"
} }
def __init__(self, *, client, type: str, offset: int, length: int, url: str = None, user=None): def __init__(self,
*,
client,
type: str,
offset: int,
length: int,
url: str = None,
user=None):
super().__init__(client) super().__init__(client)
self.type = type self.type = type

View File

@ -33,7 +33,11 @@ class Messages(PyrogramType):
Requested messages. Requested messages.
""" """
def __init__(self, *, client, total_count: int, messages: list): def __init__(self,
*,
client,
total_count: int,
messages: list):
super().__init__(client) super().__init__(client)
self.total_count = total_count self.total_count = total_count

View File

@ -39,7 +39,12 @@ class Photo(PyrogramType):
Available sizes of this photo. Available sizes of this photo.
""" """
def __init__(self, *, client, id: str, date: int, sizes: list): def __init__(self,
*,
client,
id: str,
date: int,
sizes: list):
super().__init__(client) super().__init__(client)
self.id = id self.id = id

View File

@ -40,7 +40,13 @@ class PhotoSize(PyrogramType):
File size. File size.
""" """
def __init__(self, *, client, file_id: str, width: int, height: int, file_size: int): def __init__(self,
*,
client,
file_id: str,
width: int,
height: int,
file_size: int):
super().__init__(client) super().__init__(client)
self.file_id = file_id self.file_id = file_id

View File

@ -63,9 +63,20 @@ class Sticker(PyrogramType):
# TODO: Add mask position # TODO: Add mask position
def __init__(self, *, client, file_id: str, width: int, height: int, thumb=None, file_name: str = None, def __init__(self,
mime_type: str = None, file_size: int = None, date: int = None, emoji: str = None, *,
set_name: str = None, mask_position=None): 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) super().__init__(client)
self.file_id = file_id self.file_id = file_id

View File

@ -31,7 +31,11 @@ class UserProfilePhotos(PyrogramType):
Requested profile pictures. Requested profile pictures.
""" """
def __init__(self, *, client, total_count: int, photos: list): def __init__(self,
*,
client,
total_count: int,
photos: list):
super().__init__(client) super().__init__(client)
self.total_count = total_count self.total_count = total_count

View File

@ -43,7 +43,13 @@ class Venue(PyrogramType):
""" """
def __init__(self, *, client, 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): foursquare_type: str = None):
super().__init__(client) super().__init__(client)

View File

@ -56,8 +56,18 @@ class Video(PyrogramType):
Date the video was sent in Unix time. Date the video was sent in Unix time.
""" """
def __init__(self, *, client, file_id: str, width: int, height: int, duration: int, thumb=None, def __init__(self,
file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None): *,
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) super().__init__(client)
self.file_id = file_id self.file_id = file_id

View File

@ -50,8 +50,16 @@ class VideoNote(PyrogramType):
Date the video note was sent in Unix time. Date the video note was sent in Unix time.
""" """
def __init__(self, *, client, file_id: str, length: int, duration: int, thumb=None, mime_type: str = None, def __init__(self,
file_size: int = None, date: int = None): *,
client,
file_id: str,
length: int,
duration: int,
thumb=None,
mime_type: str = None,
file_size: int = None,
date: int = None):
super().__init__(client) super().__init__(client)
self.file_id = file_id self.file_id = file_id

View File

@ -46,8 +46,15 @@ class Voice(PyrogramType):
Date the voice was sent in Unix time. Date the voice was sent in Unix time.
""" """
def __init__(self, *, client, file_id: str, duration: int, waveform: bytes = None, mime_type: str = None, def __init__(self,
file_size: int = None, date: int = None): *,
client,
file_id: str,
duration: int,
waveform: bytes = None,
mime_type: str = None,
file_size: int = None,
date: int = None):
super().__init__(client) super().__init__(client)
self.file_id = file_id self.file_id = file_id

View File

@ -76,10 +76,24 @@ 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, *, client, id: int, type: str, title: str = None, username: str = None, def __init__(self,
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, client,
can_set_sticker_set: bool = None, members_count: int = None, restriction_reason: str = None): 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) super().__init__(client)
self.id = id self.id = id

View File

@ -79,11 +79,24 @@ 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, *, client, user, status: str, until_date: int = None, can_be_edited: bool = None, def __init__(self,
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, client,
can_pin_messages: bool = None, can_promote_members: bool = None, can_send_messages: bool = None, user,
can_send_media_messages: bool = None, can_send_other_messages: bool = None, 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): can_add_web_page_previews: bool = None):
super().__init__(client) super().__init__(client)

View File

@ -33,7 +33,11 @@ class ChatMembers(PyrogramType):
Requested chat members. Requested chat members.
""" """
def __init__(self, *, client, total_count: int, chat_members: list): def __init__(self,
*,
client,
total_count: int,
chat_members: list):
super().__init__(client) super().__init__(client)
self.total_count = total_count self.total_count = total_count

View File

@ -34,7 +34,11 @@ class ChatPhoto(PyrogramType):
Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download. Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download.
""" """
def __init__(self, *, client, small_file_id: str, big_file_id: str): def __init__(self,
*,
client,
small_file_id: str,
big_file_id: str):
super().__init__(client) super().__init__(client)
self.small_file_id = small_file_id self.small_file_id = small_file_id

View File

@ -44,8 +44,15 @@ class Dialog(PyrogramType):
True, if the dialog is pinned. True, if the dialog is pinned.
""" """
def __init__(self, *, client, chat, top_message, unread_messages_count: int, unread_mentions_count: int, def __init__(self,
unread_mark: bool, is_pinned: bool): *,
client,
chat,
top_message,
unread_messages_count: int,
unread_mentions_count: int,
unread_mark: bool,
is_pinned: bool):
super().__init__(client) super().__init__(client)
self.chat = chat self.chat = chat

View File

@ -33,7 +33,11 @@ class Dialogs(PyrogramType):
Requested dialogs. Requested dialogs.
""" """
def __init__(self, *, client, total_count: int, dialogs: list): def __init__(self,
*,
client,
total_count: int,
dialogs: list):
super().__init__(client) super().__init__(client)
self.total_count = total_count self.total_count = total_count

View File

@ -69,9 +69,22 @@ 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, *, client, id: int, is_self: bool, is_contact: bool, is_mutual_contact: bool, def __init__(self,
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, 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): restriction_reason: str = None):
super().__init__(client) super().__init__(client)

View File

@ -62,8 +62,16 @@ class UserStatus(PyrogramType):
always shown to blocked users), None otherwise. always shown to blocked users), None otherwise.
""" """
def __init__(self, *, client, user_id: int, online: bool = None, offline: bool = None, date: int = None, def __init__(self,
recently: bool = None, within_week: bool = None, within_month: bool = None, *,
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): long_time_ago: bool = None):
super().__init__(client) super().__init__(client)