2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Fix all those unresolved references caused by the refactor

This commit is contained in:
Dan 2018-12-18 09:45:49 +01:00
parent dc2792fbea
commit 27052e31ca
22 changed files with 70 additions and 51 deletions

View File

@ -16,9 +16,9 @@
# 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 import functions, types
from ...ext import BaseClient, utils
import pyrogram
from pyrogram.api import functions, types
from ...ext import BaseClient
class Filters:

View File

@ -16,8 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from pyrogram.client.ext import utils
from ...ext import BaseClient
@ -86,7 +86,7 @@ class KickChatMember(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,8 +16,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from pyrogram.client.ext import BaseClient, utils
from pyrogram.client.ext import BaseClient
class EditMessageCaption(BaseClient):
@ -68,7 +70,7 @@ class EditMessageCaption(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -21,6 +21,7 @@ import mimetypes
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid
from pyrogram.client.ext import BaseClient, utils
@ -333,7 +334,7 @@ class EditMessageMedia(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,8 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from pyrogram.client.ext import BaseClient, utils
from pyrogram.client.ext import BaseClient
class EditMessageReplyMarkup(BaseClient):
@ -57,7 +58,7 @@ class EditMessageReplyMarkup(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,8 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from pyrogram.client.ext import BaseClient, utils
from pyrogram.client.ext import BaseClient
class EditMessageText(BaseClient):
@ -73,7 +74,7 @@ class EditMessageText(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,8 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from ...ext import BaseClient, utils
from ...ext import BaseClient
class ForwardMessages(BaseClient):
@ -77,7 +78,7 @@ class ForwardMessages(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
messages.append(
utils.parse_messages(
pyrogram.Message.parse(
self, i.message,
users, chats
)

View File

@ -16,8 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from ...ext import BaseClient, utils
from ...ext import BaseClient
class GetMessages(BaseClient):
@ -48,10 +49,9 @@ class GetMessages(BaseClient):
The number of subsequent replies to get for each message. Defaults to 1.
Returns:
On success and in case *message_ids* or *reply_to_message_ids* was a list, the returned value will be a
list of the requested :obj:`Messages <pyrogram.Messages>` even if a list contains just one element,
otherwise if *message_ids* or *reply_to_message_ids* was an integer, the single requested
:obj:`Message <pyrogram.Message>` is returned.
On success and in case *message_ids* or *reply_to_message_ids* was an iterable, the returned value will be a
:obj:`Messages <pyrogram.Messages>` even if a list contains just one element. Otherwise, if *message_ids* or
*reply_to_message_ids* was an integer, the single requested :obj:`Message <pyrogram.Message>` is returned.
Raises:
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
@ -76,13 +76,6 @@ class GetMessages(BaseClient):
else:
rpc = functions.messages.GetMessages(id=ids)
r = self.send(rpc)
messages = pyrogram.Messages.parse(self, self.send(rpc))
messages = utils.parse_messages(
self, r.messages,
{i.id: i for i in r.users},
{i.id: i for i in r.chats},
replies=replies
)
return messages if is_iterable else messages[0]
return messages if is_iterable else messages.messages[0]

View File

@ -21,6 +21,7 @@ import mimetypes
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid, FilePartMissing
from pyrogram.client.ext import BaseClient, utils
@ -184,7 +185,7 @@ class SendAnimation(BaseClient):
else:
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -21,6 +21,7 @@ import mimetypes
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid, FilePartMissing
from pyrogram.client.ext import BaseClient, utils
@ -184,7 +185,7 @@ class SendAudio(BaseClient):
else:
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,8 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from pyrogram.client.ext import BaseClient, utils
from pyrogram.client.ext import BaseClient
class SendContact(BaseClient):
@ -86,7 +87,7 @@ class SendContact(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -21,6 +21,7 @@ import mimetypes
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid, FilePartMissing
from pyrogram.client.ext import BaseClient, utils
@ -165,7 +166,7 @@ class SendDocument(BaseClient):
else:
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,8 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from pyrogram.client.ext import BaseClient, utils
from pyrogram.client.ext import BaseClient
class SendLocation(BaseClient):
@ -78,7 +79,7 @@ class SendLocation(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,9 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from pyrogram.client import types as pyrogram_types
from ...ext import utils, BaseClient
from ...ext import BaseClient
class SendMessage(BaseClient):
@ -83,9 +83,13 @@ class SendMessage(BaseClient):
)
if isinstance(r, types.UpdateShortSentMessage):
return pyrogram_types.Message(
return pyrogram.Message(
message_id=r.id,
chat=pyrogram_types.Chat(id=list(self.resolve_peer(chat_id).__dict__.values())[0], type="private"),
chat=pyrogram.Chat(
id=list(self.resolve_peer(chat_id).__dict__.values())[0],
type="private",
client=self
),
text=message,
date=r.date,
outgoing=r.out,
@ -95,7 +99,7 @@ class SendMessage(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -20,6 +20,7 @@ import binascii
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid, FilePartMissing
from pyrogram.client.ext import BaseClient, utils
@ -160,7 +161,7 @@ class SendPhoto(BaseClient):
else:
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -20,6 +20,7 @@ import binascii
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid, FilePartMissing
from pyrogram.client.ext import BaseClient, utils
@ -144,7 +145,7 @@ class SendSticker(BaseClient):
else:
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,8 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from pyrogram.client.ext import BaseClient, utils
from pyrogram.client.ext import BaseClient
class SendVenue(BaseClient):
@ -100,7 +101,7 @@ class SendVenue(BaseClient):
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -21,6 +21,7 @@ import mimetypes
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid, FilePartMissing
from pyrogram.client.ext import BaseClient, utils
@ -187,7 +188,7 @@ class SendVideo(BaseClient):
else:
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -21,6 +21,7 @@ import mimetypes
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid, FilePartMissing
from pyrogram.client.ext import BaseClient, utils
@ -163,7 +164,7 @@ class SendVideoNote(BaseClient):
else:
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -21,6 +21,7 @@ import mimetypes
import os
import struct
import pyrogram
from pyrogram.api import functions, types
from pyrogram.api.errors import FileIdInvalid, FilePartMissing
from pyrogram.client.ext import BaseClient, utils
@ -163,7 +164,7 @@ class SendVoice(BaseClient):
else:
for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages(
return pyrogram.Message.parse(
self, i.message,
{i.id: i for i in r.users},
{i.id: i for i in r.chats}

View File

@ -16,8 +16,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import pyrogram
from pyrogram.api import functions, types
from ...ext import BaseClient, utils
from ...ext import BaseClient
class GetMe(BaseClient):
@ -30,7 +31,8 @@ class GetMe(BaseClient):
Raises:
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
"""
return utils.parse_user(
return pyrogram.User.parse(
self,
self.send(
functions.users.GetFullUser(
types.InputPeerSelf()

View File

@ -84,7 +84,8 @@ class DownloadMedia(BaseClient):
file_id=message.photo.sizes[-1].file_id,
file_size=message.photo.sizes[-1].file_size,
mime_type="",
date=message.photo.date
date=message.photo.date,
client=self
)
elif message.audio:
media = message.audio
@ -118,7 +119,8 @@ class DownloadMedia(BaseClient):
file_id=message.sizes[-1].file_id,
file_size=message.sizes[-1].file_size,
mime_type="",
date=message.date
date=message.date,
client=self
)
else:
media = message
@ -126,7 +128,8 @@ class DownloadMedia(BaseClient):
media = pyrogram_types.Document(
file_id=message,
file_size=0,
mime_type=""
mime_type="",
client=self
)
else:
raise ValueError(error_message)