2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Move pyrogram types outside and make them static

This commit is contained in:
Dan 2018-04-23 18:50:58 +02:00
parent debc459686
commit 50252caec3
19 changed files with 1192 additions and 0 deletions

View File

@ -0,0 +1,36 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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 .update import Update
from .user import User
from .chat import Chat
from .message import Message
from .message_entity import MessageEntity
from .photo_size import PhotoSize
from .audio import Audio
from .document import Document
from .video import Video
from .voice import Voice
from .video_note import VideoNote
from .contact import Contact
from .location import Location
from .venue import Venue
from .user_profile_photos import UserProfilePhotos
from .chat_photo import ChatPhoto
from .chat_member import ChatMember
from .sticker import Sticker

View File

@ -0,0 +1,56 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Audio(Object):
"""This object represents an audio file to be treated as music by the Telegram clients.
Attributes:
ID: ``0xb0700006``
Args:
file_id (``str``):
Unique identifier for this file.
duration (``int`` ``32-bit``):
Duration of the audio in seconds as defined by sender.
performer (``str``, optional):
Performer of the audio as defined by sender or by audio tags.
title (``str``, optional):
Title of the audio as defined by sender or by audio tags.
mime_type (``str``, optional):
MIME type of the file as defined by sender.
file_size (``int`` ``32-bit``, optional):
File size.
"""
ID = 0xb0700006
def __init__(self, file_id, duration, performer=None, title=None, mime_type=None, file_size=None):
self.file_id = file_id # string
self.duration = duration # int
self.performer = performer # flags.0?string
self.title = title # flags.1?string
self.mime_type = mime_type # flags.2?string
self.file_size = file_size # flags.3?int

View File

@ -0,0 +1,84 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Chat(Object):
"""This object represents a chat.
Attributes:
ID: ``0xb0700002``
Args:
id (``int`` ``32-bit``):
Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
type (``str``):
Type of chat, can be either "private", "group", "supergroup" or "channel".
title (``str``, optional):
Title, for supergroups, channels and group chats.
username (``str``, optional):
Username, for private chats, supergroups and channels if available.
first_name (``str``, optional):
First name of the other party in a private chat.
last_name (``str``, optional):
Last name of the other party in a private chat.
all_members_are_administrators (``bool``, optional):
True if a group has 'All Members Are Admins' enabled.
photo (:obj:`ChatPhoto <pyrogram.types.ChatPhoto>`, optional):
Chat photo. Returned only in getChat.
description (``str``, optional):
Description, for supergroups and channel chats. Returned only in getChat.
invite_link (``str``, optional):
Chat invite link, for supergroups and channel chats. Returned only in getChat.
pinned_message (:obj:`Message <pyrogram.types.Message>`, optional):
Pinned message, for supergroups and channel chats. Returned only in getChat.
sticker_set_name (``str``, optional):
For supergroups, name of group sticker set. Returned only in getChat.
can_set_sticker_set (``bool``, optional):
True, if the bot can change the group sticker set. Returned only in getChat.
"""
ID = 0xb0700002
def __init__(self, id, type, title=None, username=None, first_name=None, last_name=None, all_members_are_administrators=None, photo=None, description=None, invite_link=None, pinned_message=None, sticker_set_name=None, can_set_sticker_set=None):
self.id = id # int
self.type = type # string
self.title = title # flags.0?string
self.username = username # flags.1?string
self.first_name = first_name # flags.2?string
self.last_name = last_name # flags.3?string
self.all_members_are_administrators = all_members_are_administrators # flags.4?Bool
self.photo = photo # flags.5?ChatPhoto
self.description = description # flags.6?string
self.invite_link = invite_link # flags.7?string
self.pinned_message = pinned_message # flags.8?Message
self.sticker_set_name = sticker_set_name # flags.9?string
self.can_set_sticker_set = can_set_sticker_set # flags.10?Bool

View File

@ -0,0 +1,96 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class ChatMember(Object):
"""This object contains information about one member of a chat.
Attributes:
ID: ``0xb0700016``
Args:
user (:obj:`User <pyrogram.types.User>`):
Information about the user.
status (``str``):
The member's status in the chat. Can be "creator", "administrator", "member", "restricted", "left" or "kicked".
until_date (``int`` ``32-bit``, optional):
Restricted and kicked only. Date when restrictions will be lifted for this user, unix time.
can_be_edited (``bool``, optional):
Administrators only. True, if the bot is allowed to edit administrator privileges of that user.
can_change_info (``bool``, optional):
Administrators only. True, if the administrator can change the chat title, photo and other settings.
can_post_messages (``bool``, optional):
Administrators only. True, if the administrator can post in the channel, channels only.
can_edit_messages (``bool``, optional):
Administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only.
can_delete_messages (``bool``, optional):
Administrators only. True, if the administrator can delete messages of other users.
can_invite_users (``bool``, optional):
Administrators only. True, if the administrator can invite new users to the chat.
can_restrict_members (``bool``, optional):
Administrators only. True, if the administrator can restrict, ban or unban chat members.
can_pin_messages (``bool``, optional):
Administrators only. True, if the administrator can pin messages, supergroups only.
can_promote_members (``bool``, optional):
Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user).
can_send_messages (``bool``, optional):
Restricted only. True, if the user can send text messages, contacts, locations and venues.
can_send_media_messages (``bool``, optional):
Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages.
can_send_other_messages (``bool``, optional):
Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages.
can_add_web_page_previews (``bool``, optional):
Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages.
"""
ID = 0xb0700016
def __init__(self, user, status, until_date=None, can_be_edited=None, can_change_info=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_invite_users=None, can_restrict_members=None, can_pin_messages=None, can_promote_members=None, can_send_messages=None, can_send_media_messages=None, can_send_other_messages=None, can_add_web_page_previews=None):
self.user = user # User
self.status = status # string
self.until_date = until_date # flags.0?int
self.can_be_edited = can_be_edited # flags.1?Bool
self.can_change_info = can_change_info # flags.2?Bool
self.can_post_messages = can_post_messages # flags.3?Bool
self.can_edit_messages = can_edit_messages # flags.4?Bool
self.can_delete_messages = can_delete_messages # flags.5?Bool
self.can_invite_users = can_invite_users # flags.6?Bool
self.can_restrict_members = can_restrict_members # flags.7?Bool
self.can_pin_messages = can_pin_messages # flags.8?Bool
self.can_promote_members = can_promote_members # flags.9?Bool
self.can_send_messages = can_send_messages # flags.10?Bool
self.can_send_media_messages = can_send_media_messages # flags.11?Bool
self.can_send_other_messages = can_send_other_messages # flags.12?Bool
self.can_add_web_page_previews = can_add_web_page_previews # flags.13?Bool

View File

@ -0,0 +1,40 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class ChatPhoto(Object):
"""This object represents a chat photo.
Attributes:
ID: ``0xb0700015``
Args:
small_file_id (``str``):
Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download.
big_file_id (``str``):
Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download.
"""
ID = 0xb0700015
def __init__(self, small_file_id, big_file_id):
self.small_file_id = small_file_id # string
self.big_file_id = big_file_id # string

View File

@ -0,0 +1,48 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Contact(Object):
"""This object represents a phone contact.
Attributes:
ID: ``0xb0700011``
Args:
phone_number (``str``):
Contact's phone number.
first_name (``str``):
Contact's first name.
last_name (``str``, optional):
Contact's last name.
user_id (``int`` ``32-bit``, optional):
Contact's user identifier in Telegram.
"""
ID = 0xb0700011
def __init__(self, phone_number, first_name, last_name=None, user_id=None):
self.phone_number = phone_number # string
self.first_name = first_name # string
self.last_name = last_name # flags.0?string
self.user_id = user_id # flags.1?int

View File

@ -0,0 +1,52 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Document(Object):
"""This object represents a general file (as opposed to photos, voice messages and audio files).
Attributes:
ID: ``0xb0700007``
Args:
file_id (``str``):
Unique file identifier.
thumb (:obj:`PhotoSize <pyrogram.types.PhotoSize>`, optional):
Document thumbnail as defined by sender.
file_name (``str``, optional):
Original filename as defined by sender.
mime_type (``str``, optional):
MIME type of the file as defined by sender.
file_size (``int`` ``32-bit``, optional):
File size.
"""
ID = 0xb0700007
def __init__(self, file_id, thumb=None, file_name=None, mime_type=None, file_size=None):
self.file_id = file_id # string
self.thumb = thumb # flags.0?PhotoSize
self.file_name = file_name # flags.1?string
self.mime_type = mime_type # flags.2?string
self.file_size = file_size # flags.3?int

View File

@ -0,0 +1,40 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Location(Object):
"""This object represents a point on the map.
Attributes:
ID: ``0xb0700012``
Args:
longitude (``float`` ``64-bit``):
Longitude as defined by sender.
latitude (``float`` ``64-bit``):
Latitude as defined by sender.
"""
ID = 0xb0700012
def __init__(self, longitude, latitude):
self.longitude = longitude # double
self.latitude = latitude # double

View File

@ -0,0 +1,200 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Message(Object):
"""This object represents a message.
Attributes:
ID: ``0xb0700003``
Args:
message_id (``int`` ``32-bit``):
Unique message identifier inside this chat.
date (``int`` ``32-bit``, optional):
Sender, empty for messages sent to channels.
chat (:obj:`Chat <pyrogram.types.Chat>`):
Date the message was sent in Unix time.
from_user (:obj:`User <pyrogram.types.User>`):
Conversation the message belongs to.
forward_from (:obj:`User <pyrogram.types.User>`, optional):
For forwarded messages, sender of the original message.
forward_from_chat (:obj:`Chat <pyrogram.types.Chat>`, optional):
For messages forwarded from channels, information about the original channel.
forward_from_message_id (``int`` ``32-bit``, optional):
For messages forwarded from channels, identifier of the original message in the channel.
forward_signature (``str``, optional):
For messages forwarded from channels, signature of the post author if present.
forward_date (``int`` ``32-bit``, optional):
For forwarded messages, date the original message was sent in Unix time.
reply_to_message (:obj:`Message <pyrogram.types.Message>`, optional):
For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
edit_date (``int`` ``32-bit``, optional):
Date the message was last edited in Unix time.
media_group_id (``str``, optional):
The unique identifier of a media message group this message belongs to.
author_signature (``str``, optional):
Signature of the post author for messages in channels.
text (``str``, optional):
For text messages, the actual UTF-8 text of the message, 0-4096 characters.
entities (List of :obj:`MessageEntity <pyrogram.types.MessageEntity>`, optional):
For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
caption_entities (List of :obj:`MessageEntity <pyrogram.types.MessageEntity>`, optional):
For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption.
audio (:obj:`Audio <pyrogram.types.Audio>`, optional):
Message is an audio file, information about the file.
document (:obj:`Document <pyrogram.types.Document>`, optional):
Message is a general file, information about the file.
game (:obj:`Game <pyrogram.types.Game>`, optional):
Message is a game, information about the game. More about games.
photo (List of :obj:`PhotoSize <pyrogram.types.PhotoSize>`, optional):
Message is a photo, available sizes of the photo.
sticker (:obj:`Sticker <pyrogram.types.Sticker>`, optional):
Message is a sticker, information about the sticker.
video (:obj:`Video <pyrogram.types.Video>`, optional):
Message is a video, information about the video.
voice (:obj:`Voice <pyrogram.types.Voice>`, optional):
Message is a voice message, information about the file.
video_note (:obj:`VideoNote <pyrogram.types.VideoNote>`, optional):
Message is a video note, information about the video message.
caption (``str``, optional):
Caption for the audio, document, photo, video or voice, 0-200 characters.
contact (:obj:`Contact <pyrogram.types.Contact>`, optional):
Message is a shared contact, information about the contact.
location (:obj:`Location <pyrogram.types.Location>`, optional):
Message is a shared location, information about the location.
venue (:obj:`Venue <pyrogram.types.Venue>`, optional):
Message is a venue, information about the venue.
new_chat_members (List of :obj:`User <pyrogram.types.User>`, optional):
New members that were added to the group or supergroup and information about them (the bot itself may be one of these members).
left_chat_member (:obj:`User <pyrogram.types.User>`, optional):
A member was removed from the group, information about them (this member may be the bot itself).
new_chat_title (``str``, optional):
A chat title was changed to this value.
new_chat_photo (List of :obj:`PhotoSize <pyrogram.types.PhotoSize>`, optional):
A chat photo was change to this value.
delete_chat_photo (``bool``, optional):
Service message: the chat photo was deleted.
group_chat_created (``bool``, optional):
Service message: the group has been created.
supergroup_chat_created (``bool``, optional):
Service message: the supergroup has been created. This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.
channel_chat_created (``bool``, optional):
Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.
migrate_to_chat_id (``int`` ``32-bit``, optional):
The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
migrate_from_chat_id (``int`` ``32-bit``, optional):
The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
pinned_message (:obj:`Message <pyrogram.types.Message>`, optional):
Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
invoice (:obj:`Invoice <pyrogram.types.Invoice>`, optional):
Message is an invoice for a payment, information about the invoice. More about payments.
successful_payment (:obj:`SuccessfulPayment <pyrogram.types.SuccessfulPayment>`, optional):
Message is a service message about a successful payment, information about the payment. More about payments.
connected_website (``str``, optional):
The domain name of the website on which the user has logged in. More about Telegram Login.
"""
ID = 0xb0700003
def __init__(self, message_id, date, chat, from_user=None, forward_from=None, forward_from_chat=None, forward_from_message_id=None, forward_signature=None, forward_date=None, reply_to_message=None, edit_date=None, media_group_id=None, author_signature=None, text=None, entities=None, caption_entities=None, audio=None, document=None, game=None, photo=None, sticker=None, video=None, voice=None, video_note=None, caption=None, contact=None, location=None, venue=None, new_chat_members=None, left_chat_member=None, new_chat_title=None, new_chat_photo=None, delete_chat_photo=None, group_chat_created=None, supergroup_chat_created=None, channel_chat_created=None, migrate_to_chat_id=None, migrate_from_chat_id=None, pinned_message=None, invoice=None, successful_payment=None, connected_website=None):
self.message_id = message_id # int
self.from_user = from_user # flags.0?User
self.date = date # int
self.chat = chat # Chat
self.forward_from = forward_from # flags.1?User
self.forward_from_chat = forward_from_chat # flags.2?Chat
self.forward_from_message_id = forward_from_message_id # flags.3?int
self.forward_signature = forward_signature # flags.4?string
self.forward_date = forward_date # flags.5?int
self.reply_to_message = reply_to_message # flags.6?Message
self.edit_date = edit_date # flags.7?int
self.media_group_id = media_group_id # flags.8?string
self.author_signature = author_signature # flags.9?string
self.text = text # flags.10?string
self.entities = entities # flags.11?Vector<MessageEntity>
self.caption_entities = caption_entities # flags.12?Vector<MessageEntity>
self.audio = audio # flags.13?Audio
self.document = document # flags.14?Document
self.game = game # flags.15?Game
self.photo = photo # flags.16?Vector<PhotoSize>
self.sticker = sticker # flags.17?Sticker
self.video = video # flags.18?Video
self.voice = voice # flags.19?Voice
self.video_note = video_note # flags.20?VideoNote
self.caption = caption # flags.21?string
self.contact = contact # flags.22?Contact
self.location = location # flags.23?Location
self.venue = venue # flags.24?Venue
self.new_chat_members = new_chat_members # flags.25?Vector<User>
self.left_chat_member = left_chat_member # flags.26?User
self.new_chat_title = new_chat_title # flags.27?string
self.new_chat_photo = new_chat_photo # flags.28?Vector<PhotoSize>
self.delete_chat_photo = delete_chat_photo # flags.29?true
self.group_chat_created = group_chat_created # flags.30?true
self.supergroup_chat_created = supergroup_chat_created # flags.31?true
self.channel_chat_created = channel_chat_created # flags.32?true
self.migrate_to_chat_id = migrate_to_chat_id # flags.33?int
self.migrate_from_chat_id = migrate_from_chat_id # flags.34?int
self.pinned_message = pinned_message # flags.35?Message
self.invoice = invoice # flags.36?Invoice
self.successful_payment = successful_payment # flags.37?SuccessfulPayment
self.connected_website = connected_website # flags.38?string

View File

@ -0,0 +1,52 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class MessageEntity(Object):
"""This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
Attributes:
ID: ``0xb0700004``
Args:
type (``str``):
Type of the entity. Can be mention (@username), hashtag, bot_command, url, email, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs), text_mention (for users without usernames).
offset (``int`` ``32-bit``):
Offset in UTF-16 code units to the start of the entity.
length (``int`` ``32-bit``):
Length of the entity in UTF-16 code units.
url (``str``, optional):
For "text_link" only, url that will be opened after user taps on the text.
user (:obj:`User <pyrogram.types.User>`, optional):
For "text_mention" only, the mentioned user.
"""
ID = 0xb0700004
def __init__(self, type, offset, length, url=None, user=None):
self.type = type # string
self.offset = offset # int
self.length = length # int
self.url = url # flags.0?string
self.user = user # flags.1?User

View File

@ -0,0 +1,48 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class PhotoSize(Object):
"""This object represents one size of a photo or a file / sticker thumbnail.
Attributes:
ID: ``0xb0700005``
Args:
file_id (``str``):
Unique identifier for this file.
width (``int`` ``32-bit``):
Photo width.
height (``int`` ``32-bit``):
Photo height.
file_size (``int`` ``32-bit``, optional):
File size.
"""
ID = 0xb0700005
def __init__(self, file_id, width, height, file_size=None):
self.file_id = file_id # string
self.width = width # int
self.height = height # int
self.file_size = file_size # flags.0?int

View File

@ -0,0 +1,64 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Sticker(Object):
"""This object represents a sticker.
Attributes:
ID: ``0xb0700017``
Args:
file_id (``str``):
Unique identifier for this file.
width (``int`` ``32-bit``):
Sticker width.
height (``int`` ``32-bit``):
Sticker height.
thumb (:obj:`PhotoSize <pyrogram.types.PhotoSize>`, optional):
Sticker thumbnail in the .webp or .jpg format.
emoji (``str``, optional):
Emoji associated with the sticker.
set_name (``str``, optional):
Name of the sticker set to which the sticker belongs.
mask_position (:obj:`MaskPosition <pyrogram.types.MaskPosition>`, optional):
For mask stickers, the position where the mask should be placed.
file_size (``int`` ``32-bit``, optional):
File size.
"""
ID = 0xb0700017
def __init__(self, file_id, width, height, thumb=None, emoji=None, set_name=None, mask_position=None, file_size=None):
self.file_id = file_id # string
self.width = width # int
self.height = height # int
self.thumb = thumb # flags.0?PhotoSize
self.emoji = emoji # flags.1?string
self.set_name = set_name # flags.2?string
self.mask_position = mask_position # flags.3?MaskPosition
self.file_size = file_size # flags.4?int

View File

@ -0,0 +1,72 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Update(Object):
"""This object represents an incoming update.At most one of the optional parameters can be present in any given update.
Attributes:
ID: ``0xb0700000``
Args:
update_id (``int`` ``32-bit``):
The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you're using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.
message (:obj:`Message <pyrogram.types.Message>`, optional):
New incoming message of any kind text, photo, sticker, etc.
edited_message (:obj:`Message <pyrogram.types.Message>`, optional):
New version of a message that is known to the bot and was edited.
channel_post (:obj:`Message <pyrogram.types.Message>`, optional):
New incoming channel post of any kind text, photo, sticker, etc.
edited_channel_post (:obj:`Message <pyrogram.types.Message>`, optional):
New version of a channel post that is known to the bot and was edited.
inline_query (:obj:`InlineQuery <pyrogram.types.InlineQuery>`, optional):
New incoming inline query.
chosen_inline_result (:obj:`ChosenInlineResult <pyrogram.types.ChosenInlineResult>`, optional):
The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.
callback_query (:obj:`CallbackQuery <pyrogram.types.CallbackQuery>`, optional):
New incoming callback query.
shipping_query (:obj:`ShippingQuery <pyrogram.types.ShippingQuery>`, optional):
New incoming shipping query. Only for invoices with flexible price.
pre_checkout_query (:obj:`PreCheckoutQuery <pyrogram.types.PreCheckoutQuery>`, optional):
New incoming pre-checkout query. Contains full information about checkout.
"""
ID = 0xb0700000
def __init__(self, update_id, message=None, edited_message=None, channel_post=None, edited_channel_post=None, inline_query=None, chosen_inline_result=None, callback_query=None, shipping_query=None, pre_checkout_query=None):
self.update_id = update_id # int
self.message = message # flags.0?Message
self.edited_message = edited_message # flags.1?Message
self.channel_post = channel_post # flags.2?Message
self.edited_channel_post = edited_channel_post # flags.3?Message
self.inline_query = inline_query # flags.4?InlineQuery
self.chosen_inline_result = chosen_inline_result # flags.5?ChosenInlineResult
self.callback_query = callback_query # flags.6?CallbackQuery
self.shipping_query = shipping_query # flags.7?ShippingQuery
self.pre_checkout_query = pre_checkout_query # flags.8?PreCheckoutQuery

View File

@ -0,0 +1,56 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class User(Object):
"""This object represents a Telegram user or bot.
Attributes:
ID: ``0xb0700001``
Args:
id (``int`` ``32-bit``):
Unique identifier for this user or bot.
is_bot (``bool``):
True, if this user is a bot.
first_name (``str``):
User's or bot's first name.
last_name (``str``, optional):
User's or bot's last name.
username (``str``, optional):
User's or bot's username.
language_code (``str``, optional):
IETF language tag of the user's language.
"""
ID = 0xb0700001
def __init__(self, id, is_bot, first_name, last_name=None, username=None, language_code=None):
self.id = id # int
self.is_bot = is_bot # Bool
self.first_name = first_name # string
self.last_name = last_name # flags.0?string
self.username = username # flags.1?string
self.language_code = language_code # flags.2?string

View File

@ -0,0 +1,40 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class UserProfilePhotos(Object):
"""This object represent a user's profile pictures.
Attributes:
ID: ``0xb0700014``
Args:
total_count (``int`` ``32-bit``):
Total number of profile pictures the target user has.
photos (List of List of :obj:`PhotoSize <pyrogram.types.PhotoSize>`):
Requested profile pictures (in up to 4 sizes each).
"""
ID = 0xb0700014
def __init__(self, total_count, photos):
self.total_count = total_count # int
self.photos = photos # Vector<Vector<PhotoSize>>

View File

@ -0,0 +1,48 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Venue(Object):
"""This object represents a venue.
Attributes:
ID: ``0xb0700013``
Args:
location (:obj:`Location <pyrogram.types.Location>`):
Venue location.
title (``str``):
Name of the venue.
address (``str``):
Address of the venue.
foursquare_id (``str``, optional):
Foursquare identifier of the venue.
"""
ID = 0xb0700013
def __init__(self, location, title, address, foursquare_id=None):
self.location = location # Location
self.title = title # string
self.address = address # string
self.foursquare_id = foursquare_id # flags.0?string

View File

@ -0,0 +1,60 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Video(Object):
"""This object represents a video file.
Attributes:
ID: ``0xb0700008``
Args:
file_id (``str``):
Unique identifier for this file.
width (``int`` ``32-bit``):
Video width as defined by sender.
height (``int`` ``32-bit``):
Video height as defined by sender.
duration (``int`` ``32-bit``):
Duration of the video in seconds as defined by sender.
thumb (:obj:`PhotoSize <pyrogram.types.PhotoSize>`, optional):
Video thumbnail.
mime_type (``str``, optional):
Mime type of a file as defined by sender.
file_size (``int`` ``32-bit``, optional):
File size.
"""
ID = 0xb0700008
def __init__(self, file_id, width, height, duration, thumb=None, mime_type=None, file_size=None):
self.file_id = file_id # string
self.width = width # int
self.height = height # int
self.duration = duration # int
self.thumb = thumb # flags.0?PhotoSize
self.mime_type = mime_type # flags.1?string
self.file_size = file_size # flags.2?int

View File

@ -0,0 +1,52 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class VideoNote(Object):
"""This object represents a video message (available in Telegram apps as of v.4.0).
Attributes:
ID: ``0xb0700010``
Args:
file_id (``str``):
Unique identifier for this file.
length (``int`` ``32-bit``):
Video width and height as defined by sender.
duration (``int`` ``32-bit``):
Duration of the video in seconds as defined by sender.
thumb (:obj:`PhotoSize <pyrogram.types.PhotoSize>`, optional):
Video thumbnail.
file_size (``int`` ``32-bit``, optional):
File size.
"""
ID = 0xb0700010
def __init__(self, file_id, length, duration, thumb=None, file_size=None):
self.file_id = file_id # string
self.length = length # int
self.duration = duration # int
self.thumb = thumb # flags.0?PhotoSize
self.file_size = file_size # flags.1?int

View File

@ -0,0 +1,48 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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
class Voice(Object):
"""This object represents a voice note.
Attributes:
ID: ``0xb0700009``
Args:
file_id (``str``):
Unique identifier for this file.
duration (``int`` ``32-bit``):
Duration of the audio in seconds as defined by sender.
mime_type (``str``, optional):
MIME type of the file as defined by sender.
file_size (``int`` ``32-bit``, optional):
File size.
"""
ID = 0xb0700009
def __init__(self, file_id, duration, mime_type=None, file_size=None):
self.file_id = file_id # string
self.duration = duration # int
self.mime_type = mime_type # flags.0?string
self.file_size = file_size # flags.1?int