Accommodate the new types

This commit is contained in:
Dan 2018-04-24 16:08:33 +02:00
parent 59bca1c109
commit 6e78935857
13 changed files with 139 additions and 122 deletions

View File

@ -67,8 +67,8 @@ def get_docstring_arg_type(t: str, is_list: bool = False, is_pyrogram_type: bool
n = len(t) - 1
t = (("e" if is_list else "E") + "ither " if n else "") + ", ".join(
":obj:`{1} <pyrogram.api.types.{0}{1}>`".format(
"pyrogram." if is_pyrogram_type else "",
":obj:`{1} <{0}.{1}>`".format(
"pyrogram.types" if is_pyrogram_type else "pyrogram.api.types",
i.replace("pyrogram.", "")
)
for i in t
@ -274,7 +274,7 @@ def start():
) if c.args else "pass"
docstring_args = []
# docs = c.docs.split("|")[1:] if c.docs else None
docs = c.docs.split("|")[1:] if c.docs else None
for i, arg in enumerate(sorted_args):
arg_name, arg_type = arg
@ -282,24 +282,23 @@ def start():
flag_number = is_optional.group(1) if is_optional else -1
arg_type = arg_type.split("?")[-1]
# if c.namespace == "pyrogram":
# docstring_args.append(
# "{} ({}{}):\n {}\n".format(
# arg_name,
# get_docstring_arg_type(arg_type, is_pyrogram_type=True),
# ", optional" if "Optional" in docs[i] else "",
# re.sub("Optional\. ", "", docs[i].split("§")[1].rstrip(".") + ".")
# )
# )
# else:
docstring_args.append(
"{}{}: {}".format(
arg_name,
" (optional)".format(flag_number) if is_optional else "",
get_docstring_arg_type(arg_type, is_pyrogram_type=c.namespace == "pyrogram")
if docs:
docstring_args.append(
"{} ({}{}):\n {}\n".format(
arg_name,
get_docstring_arg_type(arg_type, is_pyrogram_type=True),
", optional" if "Optional" in docs[i] else "",
re.sub("Optional\. ", "", docs[i].split("§")[1].rstrip(".") + ".")
)
)
else:
docstring_args.append(
"{}{}: {}".format(
arg_name,
" (optional)".format(flag_number) if is_optional else "",
get_docstring_arg_type(arg_type, is_pyrogram_type=c.namespace == "pyrogram")
)
)
)
if docstring_args:
docstring_args = "Args:\n " + "\n ".join(docstring_args)
@ -442,17 +441,36 @@ def start():
for c in combinators:
path = ".".join(filter(None, [c.section, c.namespace, capit(c.name)]))
f.write("\n {}: \"{}\",".format(c.id, path))
f.write("\n {}: \"pyrogram.api.{}\",".format(c.id, path))
f.write("\n 0xbc799737: \"core.BoolFalse\",")
f.write("\n 0x997275b5: \"core.BoolTrue\",")
f.write("\n 0x56730bcc: \"core.Null\",")
f.write("\n 0x1cb5c415: \"core.Vector\",")
f.write("\n 0x73f1f8dc: \"core.MsgContainer\",")
f.write("\n 0xae500895: \"core.FutureSalts\",")
f.write("\n 0x0949d9dc: \"core.FutureSalt\",")
f.write("\n 0x3072cfa1: \"core.GzipPacked\",")
f.write("\n 0x5bb8e511: \"core.Message\"")
f.write("\n 0xbc799737: \"pyrogram.api.core.BoolFalse\",")
f.write("\n 0x997275b5: \"pyrogram.api.core.BoolTrue\",")
f.write("\n 0x56730bcc: \"pyrogram.api.core.Null\",")
f.write("\n 0x1cb5c415: \"pyrogram.api.core.Vector\",")
f.write("\n 0x73f1f8dc: \"pyrogram.api.core.MsgContainer\",")
f.write("\n 0xae500895: \"pyrogram.api.core.FutureSalts\",")
f.write("\n 0x0949d9dc: \"pyrogram.api.core.FutureSalt\",")
f.write("\n 0x3072cfa1: \"pyrogram.api.core.GzipPacked\",")
f.write("\n 0x5bb8e511: \"pyrogram.api.core.Message\",")
f.write("\n 0xb0700000: \"pyrogram.client.types.Update\",")
f.write("\n 0xb0700001: \"pyrogram.client.types.User\",")
f.write("\n 0xb0700002: \"pyrogram.client.types.Chat\",")
f.write("\n 0xb0700003: \"pyrogram.client.types.Message\",")
f.write("\n 0xb0700004: \"pyrogram.client.types.MessageEntity\",")
f.write("\n 0xb0700005: \"pyrogram.client.types.PhotoSize\",")
f.write("\n 0xb0700006: \"pyrogram.client.types.Audio\",")
f.write("\n 0xb0700007: \"pyrogram.client.types.Document\",")
f.write("\n 0xb0700008: \"pyrogram.client.types.Video\",")
f.write("\n 0xb0700009: \"pyrogram.client.types.Voice\",")
f.write("\n 0xb0700010: \"pyrogram.client.types.VideoNote\",")
f.write("\n 0xb0700011: \"pyrogram.client.types.Contact\",")
f.write("\n 0xb0700012: \"pyrogram.client.types.Location\",")
f.write("\n 0xb0700013: \"pyrogram.client.types.Venue\",")
f.write("\n 0xb0700014: \"pyrogram.client.types.UserProfilePhotos\",")
f.write("\n 0xb0700015: \"pyrogram.client.types.ChatPhoto\",")
f.write("\n 0xb0700016: \"pyrogram.client.types.ChatMember\",")
f.write("\n 0xb0700017: \"pyrogram.client.types.Sticker\"")
f.write("\n}\n")

View File

@ -2,21 +2,21 @@
---types---
pyrogram.update#b0700000 flags:# update_id:int message:flags.0?Message edited_message:flags.1?Message channel_post:flags.2?Message edited_channel_post:flags.3?Message inline_query:flags.4?InlineQuery chosen_inline_result:flags.5?ChosenInlineResult callback_query:flags.6?CallbackQuery shipping_query:flags.7?ShippingQuery pre_checkout_query:flags.8?PreCheckoutQuery = pyrogram.Update;
pyrogram.user#b0700001 flags:# id:int is_bot:Bool first_name:string last_name:flags.0?string username:flags.1?string language_code:flags.2?string phone_number:flags.3?string photo:flags.4?ChatPhoto = pyrogram.User;
pyrogram.chat#b0700002 flags:# id:int type:string title:flags.0?string username:flags.1?string first_name:flags.2?string last_name:flags.3?string all_members_are_administrators:flags.4?Bool photo:flags.5?ChatPhoto description:flags.6?string invite_link:flags.7?string pinned_message:flags.8?Message sticker_set_name:flags.9?string can_set_sticker_set:flags.10?Bool = pyrogram.Chat;
pyrogram.message#b0700003 flags:# message_id:int from_user:flags.0?User date:int chat:Chat forward_from:flags.1?User forward_from_chat:flags.2?Chat forward_from_message_id:flags.3?int forward_signature:flags.4?string forward_date:flags.5?int reply_to_message:flags.6?Message edit_date:flags.7?int media_group_id:flags.8?string author_signature:flags.9?string text:flags.10?string entities:flags.11?Vector<MessageEntity> caption_entities:flags.12?Vector<MessageEntity> audio:flags.13?Audio document:flags.14?Document game:flags.15?Game photo:flags.16?Vector<PhotoSize> sticker:flags.17?Sticker video:flags.18?Video voice:flags.19?Voice video_note:flags.20?VideoNote caption:flags.21?string contact:flags.22?Contact location:flags.23?Location venue:flags.24?Venue new_chat_members:flags.25?Vector<User> left_chat_member:flags.26?User new_chat_title:flags.27?string new_chat_photo:flags.28?Vector<PhotoSize> delete_chat_photo:flags.29?true group_chat_created:flags.30?true supergroup_chat_created:flags.31?true channel_chat_created:flags.32?true migrate_to_chat_id:flags.33?int migrate_from_chat_id:flags.34?int pinned_message:flags.35?Message invoice:flags.36?Invoice successful_payment:flags.37?SuccessfulPayment connected_website:flags.38?string views:flags.39?int via_bot:flags.40?User = pyrogram.Message;
pyrogram.messageEntity#b0700004 flags:# type:string offset:int length:int url:flags.0?string user:flags.1?User = pyrogram.MessageEntity;
pyrogram.photoSize#b0700005 flags:# file_id:string file_size:flags.0?int date:flags.1?int width:int height:int = pyrogram.PhotoSize;
pyrogram.audio#b0700006 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int duration:int performer:flags.5?string title:flags.6?string = pyrogram.Audio;
pyrogram.document#b0700007 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int = pyrogram.Document;
pyrogram.video#b0700008 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int width:int height:int duration:int = pyrogram.Video;
pyrogram.voice#b0700009 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int duration:int = pyrogram.Voice;
pyrogram.videoNote#b0700010 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int length:int duration:int = pyrogram.VideoNote;
pyrogram.contact#b0700011 flags:# phone_number:string first_name:string last_name:flags.0?string user_id:flags.1?int = pyrogram.Contact;
pyrogram.location#b0700012 longitude:double latitude:double = pyrogram.Location;
pyrogram.venue#b0700013 flags:# location:Location title:string address:string foursquare_id:flags.0?string = pyrogram.Venue;
pyrogram.userProfilePhotos#b0700014 total_count:int photos:Vector<Vector<PhotoSize>> = pyrogram.UserProfilePhotos;
pyrogram.chatPhoto#b0700015 small_file_id:string big_file_id:string = pyrogram.ChatPhoto;
pyrogram.chatMember#b0700016 flags:# user:User status:string until_date:flags.0?int can_be_edited:flags.1?Bool can_change_info:flags.2?Bool can_post_messages:flags.3?Bool can_edit_messages:flags.4?Bool can_delete_messages:flags.5?Bool can_invite_users:flags.6?Bool can_restrict_members:flags.7?Bool can_pin_messages:flags.8?Bool can_promote_members:flags.9?Bool can_send_messages:flags.10?Bool can_send_media_messages:flags.11?Bool can_send_other_messages:flags.12?Bool can_add_web_page_previews:flags.13?Bool = pyrogram.ChatMember;
pyrogram.sticker#b0700017 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int width:int height:int emoji:flags.5?string set_name:flags.6?string mask_position:flags.7?MaskPosition = pyrogram.Sticker;
//pyrogram.update#b0700000 flags:# update_id:int message:flags.0?Message edited_message:flags.1?Message channel_post:flags.2?Message edited_channel_post:flags.3?Message inline_query:flags.4?InlineQuery chosen_inline_result:flags.5?ChosenInlineResult callback_query:flags.6?CallbackQuery shipping_query:flags.7?ShippingQuery pre_checkout_query:flags.8?PreCheckoutQuery = pyrogram.Update;
//pyrogram.user#b0700001 flags:# id:int is_bot:Bool first_name:string last_name:flags.0?string username:flags.1?string language_code:flags.2?string phone_number:flags.3?string photo:flags.4?ChatPhoto = pyrogram.User;
//pyrogram.chat#b0700002 flags:# id:int type:string title:flags.0?string username:flags.1?string first_name:flags.2?string last_name:flags.3?string all_members_are_administrators:flags.4?Bool photo:flags.5?ChatPhoto description:flags.6?string invite_link:flags.7?string pinned_message:flags.8?Message sticker_set_name:flags.9?string can_set_sticker_set:flags.10?Bool = pyrogram.Chat;
//pyrogram.message#b0700003 flags:# message_id:int from_user:flags.0?User date:int chat:Chat forward_from:flags.1?User forward_from_chat:flags.2?Chat forward_from_message_id:flags.3?int forward_signature:flags.4?string forward_date:flags.5?int reply_to_message:flags.6?Message edit_date:flags.7?int media_group_id:flags.8?string author_signature:flags.9?string text:flags.10?string entities:flags.11?Vector<MessageEntity> caption_entities:flags.12?Vector<MessageEntity> audio:flags.13?Audio document:flags.14?Document game:flags.15?Game photo:flags.16?Vector<PhotoSize> sticker:flags.17?Sticker video:flags.18?Video voice:flags.19?Voice video_note:flags.20?VideoNote caption:flags.21?string contact:flags.22?Contact location:flags.23?Location venue:flags.24?Venue new_chat_members:flags.25?Vector<User> left_chat_member:flags.26?User new_chat_title:flags.27?string new_chat_photo:flags.28?Vector<PhotoSize> delete_chat_photo:flags.29?true group_chat_created:flags.30?true supergroup_chat_created:flags.31?true channel_chat_created:flags.32?true migrate_to_chat_id:flags.33?int migrate_from_chat_id:flags.34?int pinned_message:flags.35?Message invoice:flags.36?Invoice successful_payment:flags.37?SuccessfulPayment connected_website:flags.38?string views:flags.39?int via_bot:flags.40?User = pyrogram.Message;
//pyrogram.messageEntity#b0700004 flags:# type:string offset:int length:int url:flags.0?string user:flags.1?User = pyrogram.MessageEntity;
//pyrogram.photoSize#b0700005 flags:# file_id:string file_size:flags.0?int date:flags.1?int width:int height:int = pyrogram.PhotoSize;
//pyrogram.audio#b0700006 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int duration:int performer:flags.5?string title:flags.6?string = pyrogram.Audio;
//pyrogram.document#b0700007 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int = pyrogram.Document;
//pyrogram.video#b0700008 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int width:int height:int duration:int = pyrogram.Video;
//pyrogram.voice#b0700009 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int duration:int = pyrogram.Voice;
//pyrogram.videoNote#b0700010 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int length:int duration:int = pyrogram.VideoNote;
//pyrogram.contact#b0700011 flags:# phone_number:string first_name:string last_name:flags.0?string user_id:flags.1?int = pyrogram.Contact;
//pyrogram.location#b0700012 longitude:double latitude:double = pyrogram.Location;
//pyrogram.venue#b0700013 flags:# location:Location title:string address:string foursquare_id:flags.0?string = pyrogram.Venue;
//pyrogram.userProfilePhotos#b0700014 total_count:int photos:Vector<Vector<PhotoSize>> = pyrogram.UserProfilePhotos;
//pyrogram.chatPhoto#b0700015 small_file_id:string big_file_id:string = pyrogram.ChatPhoto;
//pyrogram.chatMember#b0700016 flags:# user:User status:string until_date:flags.0?int can_be_edited:flags.1?Bool can_change_info:flags.2?Bool can_post_messages:flags.3?Bool can_edit_messages:flags.4?Bool can_delete_messages:flags.5?Bool can_invite_users:flags.6?Bool can_restrict_members:flags.7?Bool can_pin_messages:flags.8?Bool can_promote_members:flags.9?Bool can_send_messages:flags.10?Bool can_send_media_messages:flags.11?Bool can_send_other_messages:flags.12?Bool can_add_web_page_previews:flags.13?Bool = pyrogram.ChatMember;
//pyrogram.sticker#b0700017 flags:# file_id:string thumb:flags.0?PhotoSize file_name:flags.1?string mime_type:flags.2?string file_size:flags.3?int date:flags.4?int width:int height:int emoji:flags.5?string set_name:flags.6?string mask_position:flags.7?MaskPosition = pyrogram.Sticker;

View File

@ -2,6 +2,7 @@
from pyrogram.api.core import Object
class {class_name}(Object):
"""{docstring_args}
"""

View File

@ -26,13 +26,8 @@ __license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
__version__ = "0.7.1"
from .api.errors import Error
from .api.types.pyrogram import *
from .client import ChatAction
from .client import Client
from .client import ParseMode
from .client.input_media_photo import InputMediaPhoto
from .client.input_media_video import InputMediaVideo
from .client.input_phone_contact import InputPhoneContact
from .client import Emoji
from .client.handlers import MessageHandler, RawUpdateHandler
from .client.filters import Filters
from .client.types import *
from .client import (
Client, ChatAction, ParseMode, Emoji,
MessageHandler, RawUpdateHandler, Filters
)

View File

@ -23,4 +23,4 @@ from .core.object import Object
for k, v in objects.items():
path, name = v.rsplit(".", 1)
Object.all[k] = getattr(import_module("pyrogram.api." + path), name)
Object.all[k] = getattr(import_module(path), name)

View File

@ -19,4 +19,6 @@
from .chat_action import ChatAction
from .client import Client
from .emoji import Emoji
from .filters import Filters
from .handlers import MessageHandler, RawUpdateHandler
from .parse_mode import ParseMode

View File

@ -51,10 +51,9 @@ from pyrogram.crypto import AES
from pyrogram.session import Auth, Session
from pyrogram.session.internals import MsgId
from . import message_parser
from . import types as pyrogram_types
from . import utils
from .dispatcher import Dispatcher
from .input_media_photo import InputMediaPhoto
from .input_media_video import InputMediaVideo
from .style import Markdown, HTML
from .syncer import Syncer
@ -2076,7 +2075,7 @@ class Client:
for i in media:
style = self.html if i.parse_mode.lower() == "html" else self.markdown
if isinstance(i, InputMediaPhoto):
if isinstance(i, pyrogram_types.InputMediaPhoto):
if os.path.exists(i.media):
media = self.send(
functions.messages.UploadMedia(
@ -2115,7 +2114,7 @@ class Client:
access_hash=unpacked[3]
)
)
elif isinstance(i, InputMediaVideo):
elif isinstance(i, pyrogram_types.InputMediaVideo):
if os.path.exists(i.media):
media = self.send(
functions.messages.UploadMedia(
@ -3108,7 +3107,7 @@ class Client:
return False
def download_media(self,
message: pyrogram.Message,
message: pyrogram_types.Message,
file_name: str = "",
block: bool = True,
progress: callable = None):
@ -3147,7 +3146,7 @@ class Client:
Raises:
:class:`Error <pyrogram.Error>`
"""
if isinstance(message, pyrogram.Message):
if isinstance(message, pyrogram_types.Message):
if message.photo:
media = message.photo[-1]
elif message.audio:
@ -3165,17 +3164,17 @@ class Client:
else:
return
elif isinstance(message, (
pyrogram.PhotoSize,
pyrogram.Audio,
pyrogram.Document,
pyrogram.Video,
pyrogram.Voice,
pyrogram.VideoNote,
pyrogram.Sticker
pyrogram_types.PhotoSize,
pyrogram_types.Audio,
pyrogram_types.Document,
pyrogram_types.Video,
pyrogram_types.Voice,
pyrogram_types.VideoNote,
pyrogram_types.Sticker
)):
media = message
elif isinstance(message, str):
media = pyrogram.Document(
media = pyrogram_types.Document(
file_id=message,
file_size=0,
mime_type=""

View File

@ -138,7 +138,6 @@ class Dispatcher:
self.dispatch(
pyrogram.Update(
update_id=0,
message=((message if message.chat.type != "channel"
else None) if not is_edited_message
else None),

View File

@ -18,10 +18,10 @@
from struct import pack
import pyrogram
from pyrogram.api import types, functions
from pyrogram.api.errors import StickersetInvalid
from . import types as pyrogram_types
from .utils import encode
from ..api import types, functions
from ..api.errors import StickersetInvalid
# TODO: Organize the code better?
@ -47,7 +47,7 @@ def parse_entities(entities: list, users: dict) -> list:
entity_type = ENTITIES.get(entity.ID, None)
if entity_type:
output_entities.append(pyrogram.MessageEntity(
output_entities.append(pyrogram_types.MessageEntity(
type=entity_type,
offset=entity.offset,
length=entity.length,
@ -76,7 +76,7 @@ def parse_chat_photo(photo):
loc_small = photo.photo_small
loc_big = photo.photo_big
return pyrogram.ChatPhoto(
return pyrogram_types.ChatPhoto(
small_file_id=encode(
pack(
"<iiqqqqi", 0, loc_small.dc_id, 0, 0, loc_small.volume_id,
@ -92,8 +92,8 @@ def parse_chat_photo(photo):
)
def parse_user(user: types.User) -> pyrogram.User or None:
return pyrogram.User(
def parse_user(user: types.User) -> pyrogram_types.User or None:
return pyrogram_types.User(
id=user.id,
is_bot=user.bot,
first_name=user.first_name,
@ -105,7 +105,7 @@ def parse_user(user: types.User) -> pyrogram.User or None:
) if user else None
def parse_chat(message: types.Message, users: dict, chats: dict) -> pyrogram.Chat:
def parse_chat(message: types.Message, users: dict, chats: dict) -> pyrogram_types.Chat:
if isinstance(message.to_id, types.PeerUser):
return parse_user_chat(users[message.to_id.user_id if message.out else message.from_id])
elif isinstance(message.to_id, types.PeerChat):
@ -114,8 +114,8 @@ def parse_chat(message: types.Message, users: dict, chats: dict) -> pyrogram.Cha
return parse_channel_chat(chats[message.to_id.channel_id])
def parse_user_chat(user: types.User) -> pyrogram.Chat:
return pyrogram.Chat(
def parse_user_chat(user: types.User) -> pyrogram_types.Chat:
return pyrogram_types.Chat(
id=user.id,
type="private",
username=user.username,
@ -125,8 +125,8 @@ def parse_user_chat(user: types.User) -> pyrogram.Chat:
)
def parse_chat_chat(chat: types.Chat) -> pyrogram.Chat:
return pyrogram.Chat(
def parse_chat_chat(chat: types.Chat) -> pyrogram_types.Chat:
return pyrogram_types.Chat(
id=-chat.id,
type="group",
title=chat.title,
@ -135,8 +135,8 @@ def parse_chat_chat(chat: types.Chat) -> pyrogram.Chat:
)
def parse_channel_chat(channel: types.Channel) -> pyrogram.Chat:
return pyrogram.Chat(
def parse_channel_chat(channel: types.Channel) -> pyrogram_types.Chat:
return pyrogram_types.Chat(
id=int("-100" + str(channel.id)),
type="supergroup" if channel.megagroup else "channel",
title=channel.title,
@ -145,7 +145,7 @@ def parse_channel_chat(channel: types.Channel) -> pyrogram.Chat:
)
def parse_thumb(thumb: types.PhotoSize or types.PhotoCachedSize) -> pyrogram.PhotoSize or None:
def parse_thumb(thumb: types.PhotoSize or types.PhotoCachedSize) -> pyrogram_types.PhotoSize or None:
if isinstance(thumb, (types.PhotoSize, types.PhotoCachedSize)):
loc = thumb.location
@ -155,7 +155,7 @@ def parse_thumb(thumb: types.PhotoSize or types.PhotoCachedSize) -> pyrogram.Pho
file_size = len(thumb.bytes)
if isinstance(loc, types.FileLocation):
return pyrogram.PhotoSize(
return pyrogram_types.PhotoSize(
file_id=encode(
pack(
"<iiqqqqi",
@ -181,7 +181,7 @@ def parse_message(
users: dict,
chats: dict,
replies: int = 1
) -> pyrogram.Message:
) -> pyrogram_types.Message:
entities = parse_entities(message.entities, users)
forward_from = None
@ -233,7 +233,7 @@ def parse_message(
file_size = len(size.bytes)
if isinstance(loc, types.FileLocation):
photo_size = pyrogram.PhotoSize(
photo_size = pyrogram_types.PhotoSize(
file_id=encode(
pack(
"<iiqqqqi",
@ -259,20 +259,20 @@ def parse_message(
geo_point = media.geo
if isinstance(geo_point, types.GeoPoint):
location = pyrogram.Location(
location = pyrogram_types.Location(
longitude=geo_point.long,
latitude=geo_point.lat
)
elif isinstance(media, types.MessageMediaContact):
contact = pyrogram.Contact(
contact = pyrogram_types.Contact(
phone_number=media.phone_number,
first_name=media.first_name,
last_name=media.last_name or None,
user_id=media.user_id or None
)
elif isinstance(media, types.MessageMediaVenue):
venue = pyrogram.Venue(
location=pyrogram.Location(
venue = pyrogram_types.Venue(
location=pyrogram_types.Location(
longitude=media.geo.long,
latitude=media.geo.lat
),
@ -296,7 +296,7 @@ def parse_message(
audio_attributes = attributes[types.DocumentAttributeAudio]
if audio_attributes.voice:
voice = pyrogram.Voice(
voice = pyrogram_types.Voice(
file_id=encode(
pack(
"<iiqq",
@ -314,7 +314,7 @@ def parse_message(
date=doc.date
)
else:
audio = pyrogram.Audio(
audio = pyrogram_types.Audio(
file_id=encode(
pack(
"<iiqq",
@ -334,7 +334,7 @@ def parse_message(
date=doc.date
)
elif types.DocumentAttributeAnimated in attributes:
document = pyrogram.Document(
document = pyrogram_types.Document(
file_id=encode(
pack(
"<iiqq",
@ -354,7 +354,7 @@ def parse_message(
video_attributes = attributes[types.DocumentAttributeVideo]
if video_attributes.round_message:
video_note = pyrogram.VideoNote(
video_note = pyrogram_types.VideoNote(
file_id=encode(
pack(
"<iiqq",
@ -373,7 +373,7 @@ def parse_message(
date=doc.date
)
else:
video = pyrogram.Video(
video = pyrogram_types.Video(
file_id=encode(
pack(
"<iiqq",
@ -406,7 +406,7 @@ def parse_message(
else:
set_name = None
sticker = pyrogram.Sticker(
sticker = pyrogram_types.Sticker(
file_id=encode(
pack(
"<iiqq",
@ -428,7 +428,7 @@ def parse_message(
date=doc.date
)
else:
document = pyrogram.Document(
document = pyrogram_types.Document(
file_id=encode(
pack(
"<iiqq",
@ -447,7 +447,7 @@ def parse_message(
else:
media = None
m = pyrogram.Message(
m = pyrogram_types.Message(
message_id=message.id,
date=message.date,
chat=parse_chat(message, users, chats),
@ -490,7 +490,7 @@ def parse_message_service(
message: types.MessageService,
users: dict,
chats: dict
) -> pyrogram.Message:
) -> pyrogram_types.Message:
action = message.action
new_chat_members = None
@ -538,7 +538,7 @@ def parse_message_service(
file_size = len(size.bytes)
if isinstance(loc, types.FileLocation):
photo_size = pyrogram.PhotoSize(
photo_size = pyrogram_types.PhotoSize(
file_id=encode(
pack(
"<iiqqqqi",
@ -561,7 +561,7 @@ def parse_message_service(
new_chat_photo = photo_sizes
m = pyrogram.Message(
m = pyrogram_types.Message(
message_id=message.id,
date=message.date,
chat=parse_chat(message, users, chats),
@ -590,8 +590,8 @@ def parse_message_empty(
message: types.MessageEmpty,
users: dict,
chats: dict
) -> pyrogram.Message:
return pyrogram.Message(
) -> pyrogram_types.Message:
return pyrogram_types.Message(
message_id=message.id,
date=None,
chat=None

View File

@ -16,21 +16,24 @@
# 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 .audio import Audio
from .chat import Chat
from .chat_member import ChatMember
from .chat_photo import ChatPhoto
from .contact import Contact
from .document import Document
from .input_media_photo import InputMediaPhoto
from .input_media_video import InputMediaVideo
from .input_phone_contact import InputPhoneContact
from .location import Location
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
from .update import Update
from .user import User
from .user_profile_photos import UserProfilePhotos
from .venue import Venue
from .video import Video
from .video_note import VideoNote
from .voice import Voice