mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Type hint all Pyrogram types
This commit is contained in:
parent
e8fbae3166
commit
5035daa9d7
@ -19,6 +19,7 @@
|
|||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ..user_and_chats import User
|
from ..user_and_chats import User
|
||||||
@ -58,11 +59,11 @@ class CallbackQuery(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
id: str,
|
id: str,
|
||||||
from_user,
|
from_user: User,
|
||||||
chat_instance: str,
|
chat_instance: str,
|
||||||
message=None,
|
message: "pyrogram.Message" = None,
|
||||||
inline_message_id: str = None,
|
inline_message_id: str = None,
|
||||||
data: bytes = None,
|
data: bytes = None,
|
||||||
game_short_name: str = None):
|
game_short_name: str = None):
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from pyrogram.api.types import ReplyInlineMarkup, KeyboardButtonRow
|
from pyrogram.api.types import ReplyInlineMarkup, KeyboardButtonRow
|
||||||
from . import InlineKeyboardButton
|
from . import InlineKeyboardButton
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -30,7 +32,7 @@ class InlineKeyboardMarkup(PyrogramType):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
inline_keyboard: list):
|
inline_keyboard: List[List[InlineKeyboardButton]]):
|
||||||
super().__init__(None)
|
super().__init__(None)
|
||||||
|
|
||||||
self.inline_keyboard = inline_keyboard
|
self.inline_keyboard = inline_keyboard
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from pyrogram.api.types import KeyboardButtonRow
|
from pyrogram.api.types import KeyboardButtonRow
|
||||||
from pyrogram.api.types import ReplyKeyboardMarkup as RawReplyKeyboardMarkup
|
from pyrogram.api.types import ReplyKeyboardMarkup as RawReplyKeyboardMarkup
|
||||||
from . import KeyboardButton
|
from . import KeyboardButton
|
||||||
@ -48,7 +50,7 @@ class ReplyKeyboardMarkup(PyrogramType):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
keyboard: list,
|
keyboard: List[List[KeyboardButton]],
|
||||||
resize_keyboard: bool = None,
|
resize_keyboard: bool = None,
|
||||||
one_time_keyboard: bool = None,
|
one_time_keyboard: bool = None,
|
||||||
selective: bool = None):
|
selective: bool = None):
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -58,12 +59,12 @@ class Animation(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
file_id: str,
|
file_id: str,
|
||||||
width: int,
|
width: int,
|
||||||
height: int,
|
height: int,
|
||||||
duration: int,
|
duration: int,
|
||||||
thumb=None,
|
thumb: PhotoSize = None,
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
@ -82,7 +83,7 @@ class Animation(PyrogramType):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, animation: types.Document, video_attributes: types.DocumentAttributeVideo,
|
def _parse(client, animation: types.Document, video_attributes: types.DocumentAttributeVideo,
|
||||||
file_name: str) -> "Animation":
|
file_name: str) -> "Animation":
|
||||||
return Animation(
|
return Animation(
|
||||||
file_id=encode(
|
file_id=encode(
|
||||||
pack(
|
pack(
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -58,10 +59,10 @@ class Audio(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
file_id: str,
|
file_id: str,
|
||||||
duration: int,
|
duration: int,
|
||||||
thumb=None,
|
thumb: PhotoSize = None,
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
@ -81,7 +82,8 @@ class Audio(PyrogramType):
|
|||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio, file_name: str) -> "Audio":
|
def _parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio,
|
||||||
|
file_name: str) -> "Audio":
|
||||||
return Audio(
|
return Audio(
|
||||||
file_id=encode(
|
file_id=encode(
|
||||||
pack(
|
pack(
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ class Contact(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
phone_number: str,
|
phone_number: str,
|
||||||
first_name: str,
|
first_name: str,
|
||||||
last_name: str = None,
|
last_name: str = None,
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -49,9 +50,9 @@ class Document(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
file_id: str,
|
file_id: str,
|
||||||
thumb=None,
|
thumb: PhotoSize = None,
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
@ -31,7 +33,11 @@ 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: "pyrogram.Client",
|
||||||
|
longitude: float,
|
||||||
|
latitude: float):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.longitude = longitude
|
self.longitude = longitude
|
||||||
|
@ -337,7 +337,7 @@ class Message(PyrogramType):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, message: types.Message or types.MessageService or types.MessageEmpty, users: dict, chats: dict,
|
def _parse(client, message: types.Message or types.MessageService or types.MessageEmpty, users: dict, chats: dict,
|
||||||
replies: int = 1):
|
replies: int = 1):
|
||||||
if isinstance(message, types.MessageEmpty):
|
if isinstance(message, types.MessageEmpty):
|
||||||
return Message(message_id=message.id, empty=True, client=client)
|
return Message(message_id=message.id, empty=True, client=client)
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ..user_and_chats.user import User
|
from ..user_and_chats.user import User
|
||||||
@ -63,12 +65,12 @@ class MessageEntity(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
type: str,
|
type: str,
|
||||||
offset: int,
|
offset: int,
|
||||||
length: int,
|
length: int,
|
||||||
url: str = None,
|
url: str = None,
|
||||||
user=None):
|
user: User = None):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.type = type
|
self.type = type
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .message import Message
|
from .message import Message
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -35,9 +38,9 @@ class Messages(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
total_count: int,
|
total_count: int,
|
||||||
messages: list):
|
messages: List[Message]):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.total_count = total_count
|
self.total_count = total_count
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -41,10 +43,10 @@ class Photo(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
id: str,
|
id: str,
|
||||||
date: int,
|
date: int,
|
||||||
sizes: list):
|
sizes: List[PhotoSize]):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.id = id
|
self.id = id
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from pyrogram.client.ext.utils import encode
|
from pyrogram.client.ext.utils import encode
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -42,7 +43,7 @@ class PhotoSize(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
file_id: str,
|
file_id: str,
|
||||||
width: int,
|
width: int,
|
||||||
height: int,
|
height: int,
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types, functions
|
from pyrogram.api import types, functions
|
||||||
from pyrogram.api.errors import StickersetInvalid
|
from pyrogram.api.errors import StickersetInvalid
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
@ -65,18 +66,17 @@ class Sticker(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
file_id: str,
|
file_id: str,
|
||||||
width: int,
|
width: int,
|
||||||
height: int,
|
height: int,
|
||||||
thumb=None,
|
thumb: PhotoSize = None,
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
date: int = None,
|
date: int = None,
|
||||||
emoji: str = None,
|
emoji: str = None,
|
||||||
set_name: 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
|
||||||
@ -89,7 +89,7 @@ class Sticker(PyrogramType):
|
|||||||
self.height = height
|
self.height = height
|
||||||
self.emoji = emoji
|
self.emoji = emoji
|
||||||
self.set_name = set_name
|
self.set_name = set_name
|
||||||
self.mask_position = mask_position
|
# self.mask_position = mask_position
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@lru_cache(maxsize=256)
|
@lru_cache(maxsize=256)
|
||||||
@ -105,7 +105,7 @@ class Sticker(PyrogramType):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, sticker: types.Document, image_size_attributes: types.DocumentAttributeImageSize,
|
def _parse(client, sticker: types.Document, image_size_attributes: types.DocumentAttributeImageSize,
|
||||||
sticker_attributes: types.DocumentAttributeSticker, file_name: str) -> "Sticker":
|
sticker_attributes: types.DocumentAttributeSticker, file_name: str) -> "Sticker":
|
||||||
sticker_set = sticker_attributes.stickerset
|
sticker_set = sticker_attributes.stickerset
|
||||||
|
|
||||||
if isinstance(sticker_set, types.InputStickerSetID):
|
if isinstance(sticker_set, types.InputStickerSetID):
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from .photo import Photo
|
from .photo import Photo
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
@ -33,9 +36,9 @@ class UserProfilePhotos(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
total_count: int,
|
total_count: int,
|
||||||
photos: list):
|
photos: List[Photo]):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.total_count = total_count
|
self.total_count = total_count
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .location import Location
|
from .location import Location
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -45,8 +46,8 @@ class Venue(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
location,
|
location: Location,
|
||||||
title: str,
|
title: str,
|
||||||
address: str,
|
address: str,
|
||||||
foursquare_id: str = None,
|
foursquare_id: str = None,
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -58,12 +59,12 @@ class Video(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
file_id: str,
|
file_id: str,
|
||||||
width: int,
|
width: int,
|
||||||
height: int,
|
height: int,
|
||||||
duration: int,
|
duration: int,
|
||||||
thumb=None,
|
thumb: PhotoSize = None,
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
@ -81,7 +82,8 @@ class Video(PyrogramType):
|
|||||||
self.duration = duration
|
self.duration = duration
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, video: types.Document, video_attributes: types.DocumentAttributeVideo, file_name: str) -> "Video":
|
def _parse(client, video: types.Document, video_attributes: types.DocumentAttributeVideo,
|
||||||
|
file_name: str) -> "Video":
|
||||||
return Video(
|
return Video(
|
||||||
file_id=encode(
|
file_id=encode(
|
||||||
pack(
|
pack(
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -52,11 +53,11 @@ class VideoNote(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
file_id: str,
|
file_id: str,
|
||||||
length: int,
|
length: int,
|
||||||
duration: int,
|
duration: int,
|
||||||
thumb=None,
|
thumb: PhotoSize = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
date: int = None):
|
date: int = None):
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
@ -48,7 +49,7 @@ class Voice(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
file_id: str,
|
file_id: str,
|
||||||
duration: int,
|
duration: int,
|
||||||
waveform: bytes = None,
|
waveform: bytes = None,
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .chat_photo import ChatPhoto
|
from .chat_photo import ChatPhoto
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
@ -78,7 +79,7 @@ class Chat(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
id: int,
|
id: int,
|
||||||
type: str,
|
type: str,
|
||||||
title: str = None,
|
title: str = None,
|
||||||
@ -86,7 +87,7 @@ class Chat(PyrogramType):
|
|||||||
first_name: str = None,
|
first_name: str = None,
|
||||||
last_name: str = None,
|
last_name: str = None,
|
||||||
all_members_are_administrators: bool = None,
|
all_members_are_administrators: bool = None,
|
||||||
photo=None,
|
photo: ChatPhoto = None,
|
||||||
description: str = None,
|
description: str = None,
|
||||||
invite_link: str = None,
|
invite_link: str = None,
|
||||||
pinned_message=None,
|
pinned_message=None,
|
||||||
@ -175,7 +176,7 @@ class Chat(PyrogramType):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_full(client, chat_full: types.messages.ChatFull or types.UserFull) -> "Chat":
|
def _parse_full(client, chat_full: types.messages.ChatFull or types.UserFull) -> "Chat":
|
||||||
if isinstance(chat_full, types.UserFull):
|
if isinstance(chat_full, types.UserFull):
|
||||||
_parsed_chat = Chat.parse_user_chat(client, chat_full.user)
|
parsed_chat = Chat._parse_user_chat(client, chat_full.user)
|
||||||
parsed_chat.description = chat_full.about
|
parsed_chat.description = chat_full.about
|
||||||
else:
|
else:
|
||||||
full_chat = chat_full.full_chat
|
full_chat = chat_full.full_chat
|
||||||
@ -186,12 +187,12 @@ class Chat(PyrogramType):
|
|||||||
chat = i
|
chat = i
|
||||||
|
|
||||||
if isinstance(full_chat, types.ChatFull):
|
if isinstance(full_chat, types.ChatFull):
|
||||||
_parsed_chat = Chat.parse_chat_chat(client, chat)
|
parsed_chat = Chat._parse_chat_chat(client, chat)
|
||||||
|
|
||||||
if isinstance(full_chat.participants, types.ChatParticipants):
|
if isinstance(full_chat.participants, types.ChatParticipants):
|
||||||
parsed_chat.members_count = len(full_chat.participants.participants)
|
parsed_chat.members_count = len(full_chat.participants.participants)
|
||||||
else:
|
else:
|
||||||
_parsed_chat = Chat.parse_channel_chat(client, chat)
|
parsed_chat = Chat._parse_channel_chat(client, chat)
|
||||||
parsed_chat.members_count = full_chat.participants_count
|
parsed_chat.members_count = full_chat.participants_count
|
||||||
parsed_chat.description = full_chat.about or None
|
parsed_chat.description = full_chat.about or None
|
||||||
# TODO: Add StickerSet type
|
# TODO: Add StickerSet type
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
@ -81,8 +83,8 @@ class ChatMember(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
user,
|
user: "pyrogram.User",
|
||||||
status: str,
|
status: str,
|
||||||
until_date: int = None,
|
until_date: int = None,
|
||||||
can_be_edited: bool = None,
|
can_be_edited: bool = None,
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .chat_member import ChatMember
|
from .chat_member import ChatMember
|
||||||
from .user import User
|
from .user import User
|
||||||
@ -35,9 +38,9 @@ class ChatMembers(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
total_count: int,
|
total_count: int,
|
||||||
chat_members: list):
|
chat_members: List[ChatMember]):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.total_count = total_count
|
self.total_count = total_count
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
@ -36,7 +37,7 @@ class ChatPhoto(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
small_file_id: str,
|
small_file_id: str,
|
||||||
big_file_id: str):
|
big_file_id: str):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ..user_and_chats import Chat
|
from ..user_and_chats import Chat
|
||||||
@ -46,9 +48,9 @@ class Dialog(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
chat,
|
chat: Chat,
|
||||||
top_message,
|
top_message: "pyrogram.Message",
|
||||||
unread_messages_count: int,
|
unread_messages_count: int,
|
||||||
unread_mentions_count: int,
|
unread_mentions_count: int,
|
||||||
unread_mark: bool,
|
unread_mark: bool,
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .dialog import Dialog
|
from .dialog import Dialog
|
||||||
from ..messages_and_media import Message
|
from ..messages_and_media import Message
|
||||||
@ -35,9 +38,9 @@ class Dialogs(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
total_count: int,
|
total_count: int,
|
||||||
dialogs: list):
|
dialogs: List[Dialog]):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.total_count = total_count
|
self.total_count = total_count
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .chat_photo import ChatPhoto
|
from .chat_photo import ChatPhoto
|
||||||
from .user_status import UserStatus
|
from .user_status import UserStatus
|
||||||
@ -71,7 +72,7 @@ class User(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
id: int,
|
id: int,
|
||||||
is_self: bool,
|
is_self: bool,
|
||||||
is_contact: bool,
|
is_contact: bool,
|
||||||
@ -80,11 +81,11 @@ class User(PyrogramType):
|
|||||||
is_bot: bool,
|
is_bot: bool,
|
||||||
first_name: str,
|
first_name: str,
|
||||||
last_name: str = None,
|
last_name: str = None,
|
||||||
status=None,
|
status: UserStatus = None,
|
||||||
username: str = None,
|
username: str = None,
|
||||||
language_code: str = None,
|
language_code: str = None,
|
||||||
phone_number: str = None,
|
phone_number: str = None,
|
||||||
photo=None,
|
photo: ChatPhoto = None,
|
||||||
restriction_reason: str = None):
|
restriction_reason: str = None):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ class UserStatus(PyrogramType):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
*,
|
*,
|
||||||
client,
|
client: "pyrogram.Client",
|
||||||
user_id: int,
|
user_id: int,
|
||||||
online: bool = None,
|
online: bool = None,
|
||||||
offline: bool = None,
|
offline: bool = None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user