Even more async chore

This commit is contained in:
Dan 2018-06-18 21:30:13 +02:00
parent 21af0f3e82
commit 4d72f84991
36 changed files with 344 additions and 344 deletions

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient
class AnswerCallbackQuery(BaseClient): class AnswerCallbackQuery(BaseClient):
def answer_callback_query(self, async def answer_callback_query(self,
callback_query_id: str, callback_query_id: str,
text: str = None, text: str = None,
show_alert: bool = None, show_alert: bool = None,
@ -51,7 +51,7 @@ class AnswerCallbackQuery(BaseClient):
The maximum amount of time in seconds that the result of the callback query may be cached client-side. The maximum amount of time in seconds that the result of the callback query may be cached client-side.
Telegram apps will support caching starting in version 3.14. Defaults to 0. Telegram apps will support caching starting in version 3.14. Defaults to 0.
""" """
return self.send( return await self.send(
functions.messages.SetBotCallbackAnswer( functions.messages.SetBotCallbackAnswer(
query_id=int(callback_query_id), query_id=int(callback_query_id),
cache_time=cache_time, cache_time=cache_time,

View file

@ -22,7 +22,7 @@ from ....ext import BaseClient
class GetInlineBotResults(BaseClient): class GetInlineBotResults(BaseClient):
def get_inline_bot_results(self, async def get_inline_bot_results(self,
bot: int or str, bot: int or str,
query: str, query: str,
offset: str = "", offset: str = "",
@ -60,9 +60,9 @@ class GetInlineBotResults(BaseClient):
# TODO: Don't return the raw type # TODO: Don't return the raw type
try: try:
return self.send( return await self.send(
functions.messages.GetInlineBotResults( functions.messages.GetInlineBotResults(
bot=self.resolve_peer(bot), bot=await self.resolve_peer(bot),
peer=types.InputPeerSelf(), peer=types.InputPeerSelf(),
query=query, query=query,
offset=offset, offset=offset,

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient
class SendInlineBotResult(BaseClient): class SendInlineBotResult(BaseClient):
def send_inline_bot_result(self, async def send_inline_bot_result(self,
chat_id: int or str, chat_id: int or str,
query_id: int, query_id: int,
result_id: str, result_id: str,
@ -56,9 +56,9 @@ class SendInlineBotResult(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
return self.send( return await self.send(
functions.messages.SendInlineBotResult( functions.messages.SendInlineBotResult(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
query_id=query_id, query_id=query_id,
id=result_id, id=result_id,
random_id=self.rnd_id(), random_id=self.rnd_id(),

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient
class ExportChatInviteLink(BaseClient): class ExportChatInviteLink(BaseClient):
def export_chat_invite_link(self, chat_id: int or str): async def export_chat_invite_link(self, chat_id: int or str):
"""Use this method to generate a new invite link for a chat; any previously generated link is revoked. """Use this method to generate a new invite link for a chat; any previously generated link is revoked.
You must be an administrator in the chat for this to work and have the appropriate admin rights. You must be an administrator in the chat for this to work and have the appropriate admin rights.
@ -37,16 +37,16 @@ class ExportChatInviteLink(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
peer = self.resolve_peer(chat_id) peer = await self.resolve_peer(chat_id)
if isinstance(peer, types.InputPeerChat): if isinstance(peer, types.InputPeerChat):
return self.send( return await self.send(
functions.messages.ExportChatInvite( functions.messages.ExportChatInvite(
chat_id=peer.chat_id chat_id=peer.chat_id
) )
).link ).link
elif isinstance(peer, types.InputPeerChannel): elif isinstance(peer, types.InputPeerChannel):
return self.send( return await self.send(
functions.channels.ExportInvite( functions.channels.ExportInvite(
channel=peer channel=peer
) )

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient, utils
class GetChat(BaseClient): class GetChat(BaseClient):
def get_chat(self, chat_id: int or str): async def get_chat(self, chat_id: int or str):
"""Use this method to get up to date information about the chat (current name of the user for """Use this method to get up to date information about the chat (current name of the user for
one-on-one conversations, current username of a user, group or channel, etc.) one-on-one conversations, current username of a user, group or channel, etc.)
@ -31,13 +31,13 @@ class GetChat(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
peer = self.resolve_peer(chat_id) peer = await self.resolve_peer(chat_id)
if isinstance(peer, types.InputPeerChannel): if isinstance(peer, types.InputPeerChannel):
r = self.send(functions.channels.GetFullChannel(peer)) r = await self.send(functions.channels.GetFullChannel(peer))
elif isinstance(peer, (types.InputPeerUser, types.InputPeerSelf)): elif isinstance(peer, (types.InputPeerUser, types.InputPeerSelf)):
r = self.send(functions.users.GetFullUser(peer)) r = await self.send(functions.users.GetFullUser(peer))
else: else:
r = self.send(functions.messages.GetFullChat(peer.chat_id)) r = await self.send(functions.messages.GetFullChat(peer.chat_id))
return utils.parse_chat_full(self, r) return await utils.parse_chat_full(self, r)

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient
class JoinChat(BaseClient): class JoinChat(BaseClient):
def join_chat(self, chat_id: str): async def join_chat(self, chat_id: str):
"""Use this method to join a group chat or channel. """Use this method to join a group chat or channel.
Args: Args:
@ -35,13 +35,13 @@ class JoinChat(BaseClient):
match = self.INVITE_LINK_RE.match(chat_id) match = self.INVITE_LINK_RE.match(chat_id)
if match: if match:
return self.send( return await self.send(
functions.messages.ImportChatInvite( functions.messages.ImportChatInvite(
hash=match.group(1) hash=match.group(1)
) )
) )
else: else:
resolved_peer = self.send( resolved_peer = await self.send(
functions.contacts.ResolveUsername( functions.contacts.ResolveUsername(
username=chat_id.lower().strip("@") username=chat_id.lower().strip("@")
) )
@ -52,7 +52,7 @@ class JoinChat(BaseClient):
access_hash=resolved_peer.chats[0].access_hash access_hash=resolved_peer.chats[0].access_hash
) )
return self.send( return await self.send(
functions.channels.JoinChannel( functions.channels.JoinChannel(
channel=channel channel=channel
) )

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient
class KickChatMember(BaseClient): class KickChatMember(BaseClient):
def kick_chat_member(self, async def kick_chat_member(self,
chat_id: int or str, chat_id: int or str,
user_id: int or str, user_id: int or str,
until_date: int = 0): until_date: int = 0):
@ -55,11 +55,11 @@ class KickChatMember(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
chat_peer = self.resolve_peer(chat_id) chat_peer = await self.resolve_peer(chat_id)
user_peer = self.resolve_peer(user_id) user_peer = await self.resolve_peer(user_id)
if isinstance(chat_peer, types.InputPeerChannel): if isinstance(chat_peer, types.InputPeerChannel):
self.send( await self.send(
functions.channels.EditBanned( functions.channels.EditBanned(
channel=chat_peer, channel=chat_peer,
user_id=user_peer, user_id=user_peer,
@ -77,7 +77,7 @@ class KickChatMember(BaseClient):
) )
) )
else: else:
self.send( await self.send(
functions.messages.DeleteChatUser( functions.messages.DeleteChatUser(
chat_id=abs(chat_id), chat_id=abs(chat_id),
user_id=user_peer user_id=user_peer

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient
class LeaveChat(BaseClient): class LeaveChat(BaseClient):
def leave_chat(self, chat_id: int or str, delete: bool = False): async def leave_chat(self, chat_id: int or str, delete: bool = False):
"""Use this method to leave a group chat or channel. """Use this method to leave a group chat or channel.
Args: Args:
@ -35,16 +35,16 @@ class LeaveChat(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
peer = self.resolve_peer(chat_id) peer = await self.resolve_peer(chat_id)
if isinstance(peer, types.InputPeerChannel): if isinstance(peer, types.InputPeerChannel):
return self.send( return await self.send(
functions.channels.LeaveChannel( functions.channels.LeaveChannel(
channel=self.resolve_peer(chat_id) channel=await self.resolve_peer(chat_id)
) )
) )
elif isinstance(peer, types.InputPeerChat): elif isinstance(peer, types.InputPeerChat):
r = self.send( r = await self.send(
functions.messages.DeleteChatUser( functions.messages.DeleteChatUser(
chat_id=peer.chat_id, chat_id=peer.chat_id,
user_id=types.InputPeerSelf() user_id=types.InputPeerSelf()
@ -52,7 +52,7 @@ class LeaveChat(BaseClient):
) )
if delete: if delete:
self.send( await self.send(
functions.messages.DeleteHistory( functions.messages.DeleteHistory(
peer=peer, peer=peer,
max_id=0 max_id=0

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient
class PromoteChatMember(BaseClient): class PromoteChatMember(BaseClient):
def promote_chat_member(self, async def promote_chat_member(self,
chat_id: int or str, chat_id: int or str,
user_id: int or str, user_id: int or str,
can_change_info: bool = True, can_change_info: bool = True,
@ -77,10 +77,10 @@ class PromoteChatMember(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
self.send( await self.send(
functions.channels.EditAdmin( functions.channels.EditAdmin(
channel=self.resolve_peer(chat_id), channel=await self.resolve_peer(chat_id),
user_id=self.resolve_peer(user_id), user_id=await self.resolve_peer(user_id),
admin_rights=types.ChannelAdminRights( admin_rights=types.ChannelAdminRights(
change_info=can_change_info or None, change_info=can_change_info or None,
post_messages=can_post_messages or None, post_messages=can_post_messages or None,

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient
class RestrictChatMember(BaseClient): class RestrictChatMember(BaseClient):
def restrict_chat_member(self, async def restrict_chat_member(self,
chat_id: int or str, chat_id: int or str,
user_id: int or str, user_id: int or str,
until_date: int = 0, until_date: int = 0,
@ -93,10 +93,10 @@ class RestrictChatMember(BaseClient):
send_media = None send_media = None
embed_links = None embed_links = None
self.send( await self.send(
functions.channels.EditBanned( functions.channels.EditBanned(
channel=self.resolve_peer(chat_id), channel=await self.resolve_peer(chat_id),
user_id=self.resolve_peer(user_id), user_id=await self.resolve_peer(user_id),
banned_rights=types.ChannelBannedRights( banned_rights=types.ChannelBannedRights(
until_date=until_date, until_date=until_date,
send_messages=send_messages, send_messages=send_messages,

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient
class UnbanChatMember(BaseClient): class UnbanChatMember(BaseClient):
def unban_chat_member(self, async def unban_chat_member(self,
chat_id: int or str, chat_id: int or str,
user_id: int or str): user_id: int or str):
"""Use this method to unban a previously kicked user in a supergroup or channel. """Use this method to unban a previously kicked user in a supergroup or channel.
@ -43,10 +43,10 @@ class UnbanChatMember(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
self.send( await self.send(
functions.channels.EditBanned( functions.channels.EditBanned(
channel=self.resolve_peer(chat_id), channel=await self.resolve_peer(chat_id),
user_id=self.resolve_peer(user_id), user_id=await self.resolve_peer(user_id),
banned_rights=types.ChannelBannedRights( banned_rights=types.ChannelBannedRights(
until_date=0 until_date=0
) )

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient
class AddContacts(BaseClient): class AddContacts(BaseClient):
def add_contacts(self, contacts: list): async def add_contacts(self, contacts: list):
"""Use this method to add contacts to your Telegram address book. """Use this method to add contacts to your Telegram address book.
Args: Args:
@ -34,7 +34,7 @@ class AddContacts(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
imported_contacts = self.send( imported_contacts = await self.send(
functions.contacts.ImportContacts( functions.contacts.ImportContacts(
contacts=contacts contacts=contacts
) )

View file

@ -22,7 +22,7 @@ from ...ext import BaseClient
class DeleteContacts(BaseClient): class DeleteContacts(BaseClient):
def delete_contacts(self, ids: list): async def delete_contacts(self, ids: list):
"""Use this method to delete contacts from your Telegram address book """Use this method to delete contacts from your Telegram address book
Args: Args:
@ -40,14 +40,14 @@ class DeleteContacts(BaseClient):
for i in ids: for i in ids:
try: try:
input_user = self.resolve_peer(i) input_user = await self.resolve_peer(i)
except PeerIdInvalid: except PeerIdInvalid:
continue continue
else: else:
if isinstance(input_user, types.InputPeerUser): if isinstance(input_user, types.InputPeerUser):
contacts.append(input_user) contacts.append(input_user)
return self.send( return await self.send(
functions.contacts.DeleteContacts( functions.contacts.DeleteContacts(
id=contacts id=contacts
) )

View file

@ -16,8 +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 asyncio
import logging import logging
import time
from pyrogram.api import functions, types from pyrogram.api import functions, types
from pyrogram.api.errors import FloodWait from pyrogram.api.errors import FloodWait
@ -27,7 +27,7 @@ log = logging.getLogger(__name__)
class GetContacts(BaseClient): class GetContacts(BaseClient):
def get_contacts(self): async def get_contacts(self):
"""Use this method to get contacts from your Telegram address book """Use this method to get contacts from your Telegram address book
Requires no parameters. Requires no parameters.
@ -40,10 +40,10 @@ class GetContacts(BaseClient):
""" """
while True: while True:
try: try:
contacts = self.send(functions.contacts.GetContacts(0)) contacts = await self.send(functions.contacts.GetContacts(0))
except FloodWait as e: except FloodWait as e:
log.warning("get_contacts flood: waiting {} seconds".format(e.x)) log.warning("get_contacts flood: waiting {} seconds".format(e.x))
time.sleep(e.x) await asyncio.sleep(e.x)
continue continue
else: else:
if isinstance(contacts, types.contacts.Contacts): if isinstance(contacts, types.contacts.Contacts):

View file

@ -16,14 +16,14 @@
# 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 threading import Event import asyncio
from pyrogram.client import types as pyrogram_types from pyrogram.client import types as pyrogram_types
from ..ext import BaseClient from ..ext import BaseClient
class DownloadMedia(BaseClient): class DownloadMedia(BaseClient):
def download_media(self, async def download_media(self,
message: pyrogram_types.Message or str, message: pyrogram_types.Message or str,
file_name: str = "", file_name: str = "",
block: bool = True, block: bool = True,
@ -114,12 +114,12 @@ class DownloadMedia(BaseClient):
else: else:
return return
done = Event() done = asyncio.Event()
path = [None] path = [None]
self.download_queue.put((media, file_name, done, progress, progress_args, path)) self.download_queue.put_nowait((media, file_name, done, progress, progress_args, path))
if block: if block:
done.wait() await done.wait()
return path[0] return path[0]

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient, ChatAction
class SendChatAction(BaseClient): class SendChatAction(BaseClient):
def send_chat_action(self, async def send_chat_action(self,
chat_id: int or str, chat_id: int or str,
action: ChatAction or str, action: ChatAction or str,
progress: int = 0): progress: int = 0):
@ -63,9 +63,9 @@ class SendChatAction(BaseClient):
else: else:
action = action() action = action()
return self.send( return await self.send(
functions.messages.SetTyping( functions.messages.SetTyping(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
action=action action=action
) )
) )

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient, utils
class ForwardMessages(BaseClient): class ForwardMessages(BaseClient):
def forward_messages(self, async def forward_messages(self,
chat_id: int or str, chat_id: int or str,
from_chat_id: int or str, from_chat_id: int or str,
message_ids, message_ids,
@ -61,10 +61,10 @@ class ForwardMessages(BaseClient):
is_iterable = not isinstance(message_ids, int) is_iterable = not isinstance(message_ids, int)
message_ids = list(message_ids) if is_iterable else [message_ids] message_ids = list(message_ids) if is_iterable else [message_ids]
r = self.send( r = await self.send(
functions.messages.ForwardMessages( functions.messages.ForwardMessages(
to_peer=self.resolve_peer(chat_id), to_peer=await self.resolve_peer(chat_id),
from_peer=self.resolve_peer(from_chat_id), from_peer=await self.resolve_peer(from_chat_id),
id=message_ids, id=message_ids,
silent=disable_notification or None, silent=disable_notification or None,
random_id=[self.rnd_id() for _ in message_ids] random_id=[self.rnd_id() for _ in message_ids]
@ -79,7 +79,7 @@ class ForwardMessages(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
messages.append( messages.append(
utils.parse_messages( await utils.parse_messages(
self, i.message, self, i.message,
users, chats users, chats
) )

View file

@ -22,7 +22,7 @@ from ...ext import BaseClient, utils
class GetHistory(BaseClient): class GetHistory(BaseClient):
def get_history(self, async def get_history(self,
chat_id: int or str, chat_id: int or str,
offset: int = 0, offset: int = 0,
limit: int = 100, limit: int = 100,
@ -60,9 +60,9 @@ class GetHistory(BaseClient):
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
r = self.send( r = await self.send(
functions.messages.GetHistory( functions.messages.GetHistory(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
offset_id=offset_id, offset_id=offset_id,
offset_date=offset_date, offset_date=offset_date,
add_offset=offset, add_offset=offset,
@ -83,7 +83,7 @@ class GetHistory(BaseClient):
} }
if reply_to_messages: if reply_to_messages:
temp = self.get_messages( temp = await self.get_messages(
chat_id, reply_to_messages, chat_id, reply_to_messages,
replies=0 replies=0
) )
@ -93,7 +93,7 @@ class GetHistory(BaseClient):
for i in range(len(temp)): for i in range(len(temp)):
reply_to_messages[temp[i].message_id] = temp[i] reply_to_messages[temp[i].message_id] = temp[i]
messages = utils.parse_messages( messages = await utils.parse_messages(
self, r.messages, self, r.messages,
users, chats, users, chats,
replies=0 replies=0

View file

@ -21,7 +21,7 @@ from ...ext import BaseClient, utils
class GetMessages(BaseClient): class GetMessages(BaseClient):
def get_messages(self, async def get_messages(self,
chat_id: int or str, chat_id: int or str,
message_ids, message_ids,
replies: int = 1): replies: int = 1):
@ -51,7 +51,7 @@ class GetMessages(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
peer = self.resolve_peer(chat_id) peer = await self.resolve_peer(chat_id)
is_iterable = not isinstance(message_ids, int) is_iterable = not isinstance(message_ids, int)
message_ids = list(message_ids) if is_iterable else [message_ids] message_ids = list(message_ids) if is_iterable else [message_ids]
message_ids = [types.InputMessageID(i) for i in message_ids] message_ids = [types.InputMessageID(i) for i in message_ids]
@ -66,9 +66,9 @@ class GetMessages(BaseClient):
id=message_ids id=message_ids
) )
r = self.send(rpc) r = await self.send(rpc)
messages = utils.parse_messages( messages = await utils.parse_messages(
self, r.messages, self, r.messages,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats}, {i.id: i for i in r.chats},

View file

@ -27,7 +27,7 @@ from ....ext import BaseClient, utils
class SendAudio(BaseClient): class SendAudio(BaseClient):
def send_audio(self, async def send_audio(self,
chat_id: int or str, chat_id: int or str,
audio: str, audio: str,
caption: str = "", caption: str = "",
@ -118,7 +118,7 @@ class SendAudio(BaseClient):
style = self.html if parse_mode.lower() == "html" else self.markdown style = self.html if parse_mode.lower() == "html" else self.markdown
if os.path.exists(audio): if os.path.exists(audio):
file = self.save_file(audio, progress=progress, progress_args=progress_args) file = await self.save_file(audio, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument( media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map.get("." + audio.split(".")[-1], "audio/mpeg"), mime_type=mimetypes.types_map.get("." + audio.split(".")[-1], "audio/mpeg"),
file=file, file=file,
@ -160,9 +160,9 @@ class SendAudio(BaseClient):
while True: while True:
try: try:
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=media, media=media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -172,11 +172,11 @@ class SendAudio(BaseClient):
) )
) )
except FilePartMissing as e: except FilePartMissing as e:
self.save_file(audio, file_id=file.id, file_part=e.x) await self.save_file(audio, file_id=file.id, file_part=e.x)
else: else:
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient, utils
class SendContact(BaseClient): class SendContact(BaseClient):
def send_contact(self, async def send_contact(self,
chat_id: int or str, chat_id: int or str,
phone_number: str, phone_number: str,
first_name: str, first_name: str,
@ -64,9 +64,9 @@ class SendContact(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaContact( media=types.InputMediaContact(
phone_number, phone_number,
first_name, first_name,
@ -82,7 +82,7 @@ class SendContact(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -27,7 +27,7 @@ from ....ext import BaseClient, utils
class SendDocument(BaseClient): class SendDocument(BaseClient):
def send_document(self, async def send_document(self,
chat_id: int or str, chat_id: int or str,
document: str, document: str,
caption: str = "", caption: str = "",
@ -104,7 +104,7 @@ class SendDocument(BaseClient):
style = self.html if parse_mode.lower() == "html" else self.markdown style = self.html if parse_mode.lower() == "html" else self.markdown
if os.path.exists(document): if os.path.exists(document):
file = self.save_file(document, progress=progress, progress_args=progress_args) file = await self.save_file(document, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument( media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map.get("." + document.split(".")[-1], "text/plain"), mime_type=mimetypes.types_map.get("." + document.split(".")[-1], "text/plain"),
file=file, file=file,
@ -141,9 +141,9 @@ class SendDocument(BaseClient):
while True: while True:
try: try:
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=media, media=media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -153,11 +153,11 @@ class SendDocument(BaseClient):
) )
) )
except FilePartMissing as e: except FilePartMissing as e:
self.save_file(document, file_id=file.id, file_part=e.x) await self.save_file(document, file_id=file.id, file_part=e.x)
else: else:
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -27,7 +27,7 @@ from ....ext import BaseClient, utils
class SendGIF(BaseClient): class SendGIF(BaseClient):
def send_gif(self, async def send_gif(self,
chat_id: int or str, chat_id: int or str,
gif: str, gif: str,
caption: str = "", caption: str = "",
@ -122,8 +122,8 @@ class SendGIF(BaseClient):
style = self.html if parse_mode.lower() == "html" else self.markdown style = self.html if parse_mode.lower() == "html" else self.markdown
if os.path.exists(gif): if os.path.exists(gif):
thumb = None if thumb is None else self.save_file(thumb) thumb = None if thumb is None else await self.save_file(thumb)
file = self.save_file(gif, progress=progress, progress_args=progress_args) file = await self.save_file(gif, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument( media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map[".mp4"], mime_type=mimetypes.types_map[".mp4"],
file=file, file=file,
@ -168,9 +168,9 @@ class SendGIF(BaseClient):
while True: while True:
try: try:
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=media, media=media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -180,11 +180,11 @@ class SendGIF(BaseClient):
) )
) )
except FilePartMissing as e: except FilePartMissing as e:
self.save_file(gif, file_id=file.id, file_part=e.x) await self.save_file(gif, file_id=file.id, file_part=e.x)
else: else:
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient, utils
class SendLocation(BaseClient): class SendLocation(BaseClient):
def send_location(self, async def send_location(self,
chat_id: int or str, chat_id: int or str,
latitude: float, latitude: float,
longitude: float, longitude: float,
@ -60,9 +60,9 @@ class SendLocation(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaGeoPoint( media=types.InputMediaGeoPoint(
types.InputGeoPoint( types.InputGeoPoint(
latitude, latitude,
@ -79,7 +79,7 @@ class SendLocation(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -31,7 +31,7 @@ class SendMediaGroup(BaseClient):
# TODO: Add progress parameter # TODO: Add progress parameter
# TODO: Return new Message object # TODO: Return new Message object
# TODO: Figure out how to send albums using URLs # TODO: Figure out how to send albums using URLs
def send_media_group(self, async def send_media_group(self,
chat_id: int or str, chat_id: int or str,
media: list, media: list,
disable_notification: bool = None, disable_notification: bool = None,
@ -65,11 +65,11 @@ class SendMediaGroup(BaseClient):
if isinstance(i, pyrogram_types.InputMediaPhoto): if isinstance(i, pyrogram_types.InputMediaPhoto):
if os.path.exists(i.media): if os.path.exists(i.media):
media = self.send( media = await self.send(
functions.messages.UploadMedia( functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaUploadedPhoto( media=types.InputMediaUploadedPhoto(
file=self.save_file(i.media) file=await self.save_file(i.media)
) )
) )
) )
@ -104,11 +104,11 @@ class SendMediaGroup(BaseClient):
) )
elif isinstance(i, pyrogram_types.InputMediaVideo): elif isinstance(i, pyrogram_types.InputMediaVideo):
if os.path.exists(i.media): if os.path.exists(i.media):
media = self.send( media = await self.send(
functions.messages.UploadMedia( functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument( media=types.InputMediaUploadedDocument(
file=self.save_file(i.media), file=await self.save_file(i.media),
mime_type=mimetypes.types_map[".mp4"], mime_type=mimetypes.types_map[".mp4"],
attributes=[ attributes=[
types.DocumentAttributeVideo( types.DocumentAttributeVideo(
@ -160,9 +160,9 @@ class SendMediaGroup(BaseClient):
) )
) )
return self.send( return await self.send(
functions.messages.SendMultiMedia( functions.messages.SendMultiMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
multi_media=multi_media, multi_media=multi_media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id reply_to_msg_id=reply_to_message_id

View file

@ -26,7 +26,7 @@ from ....ext import BaseClient, utils
class SendPhoto(BaseClient): class SendPhoto(BaseClient):
def send_photo(self, async def send_photo(self,
chat_id: int or str, chat_id: int or str,
photo: str, photo: str,
caption: str = "", caption: str = "",
@ -109,7 +109,7 @@ class SendPhoto(BaseClient):
style = self.html if parse_mode.lower() == "html" else self.markdown style = self.html if parse_mode.lower() == "html" else self.markdown
if os.path.exists(photo): if os.path.exists(photo):
file = self.save_file(photo, progress=progress, progress_args=progress_args) file = await self.save_file(photo, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedPhoto( media = types.InputMediaUploadedPhoto(
file=file, file=file,
ttl_seconds=ttl_seconds ttl_seconds=ttl_seconds
@ -145,9 +145,9 @@ class SendPhoto(BaseClient):
while True: while True:
try: try:
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=media, media=media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -157,11 +157,11 @@ class SendPhoto(BaseClient):
) )
) )
except FilePartMissing as e: except FilePartMissing as e:
self.save_file(photo, file_id=file.id, file_part=e.x) await self.save_file(photo, file_id=file.id, file_part=e.x)
else: else:
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -26,7 +26,7 @@ from ....ext import BaseClient, utils
class SendSticker(BaseClient): class SendSticker(BaseClient):
def send_sticker(self, async def send_sticker(self,
chat_id: int or str, chat_id: int or str,
sticker: str, sticker: str,
disable_notification: bool = None, disable_notification: bool = None,
@ -92,7 +92,7 @@ class SendSticker(BaseClient):
file = None file = None
if os.path.exists(sticker): if os.path.exists(sticker):
file = self.save_file(sticker, progress=progress, progress_args=progress_args) file = await self.save_file(sticker, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument( media = types.InputMediaUploadedDocument(
mime_type="image/webp", mime_type="image/webp",
file=file, file=file,
@ -129,9 +129,9 @@ class SendSticker(BaseClient):
while True: while True:
try: try:
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=media, media=media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -141,11 +141,11 @@ class SendSticker(BaseClient):
) )
) )
except FilePartMissing as e: except FilePartMissing as e:
self.save_file(sticker, file_id=file.id, file_part=e.x) await self.save_file(sticker, file_id=file.id, file_part=e.x)
else: else:
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient, utils
class SendVenue(BaseClient): class SendVenue(BaseClient):
def send_venue(self, async def send_venue(self,
chat_id: int or str, chat_id: int or str,
latitude: float, latitude: float,
longitude: float, longitude: float,
@ -72,9 +72,9 @@ class SendVenue(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaVenue( media=types.InputMediaVenue(
geo_point=types.InputGeoPoint( geo_point=types.InputGeoPoint(
lat=latitude, lat=latitude,
@ -96,7 +96,7 @@ class SendVenue(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -27,7 +27,7 @@ from ....ext import BaseClient, utils
class SendVideo(BaseClient): class SendVideo(BaseClient):
def send_video(self, async def send_video(self,
chat_id: int or str, chat_id: int or str,
video: str, video: str,
caption: str = "", caption: str = "",
@ -127,7 +127,7 @@ class SendVideo(BaseClient):
if os.path.exists(video): if os.path.exists(video):
thumb = None if thumb is None else self.save_file(thumb) thumb = None if thumb is None else self.save_file(thumb)
file = self.save_file(video, progress=progress, progress_args=progress_args) file = await self.save_file(video, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument( media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map[".mp4"], mime_type=mimetypes.types_map[".mp4"],
file=file, file=file,
@ -171,9 +171,9 @@ class SendVideo(BaseClient):
while True: while True:
try: try:
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=media, media=media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -183,11 +183,11 @@ class SendVideo(BaseClient):
) )
) )
except FilePartMissing as e: except FilePartMissing as e:
self.save_file(video, file_id=file.id, file_part=e.x) await self.save_file(video, file_id=file.id, file_part=e.x)
else: else:
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -27,7 +27,7 @@ from ....ext import BaseClient, utils
class SendVideoNote(BaseClient): class SendVideoNote(BaseClient):
def send_video_note(self, async def send_video_note(self,
chat_id: int or str, chat_id: int or str,
video_note: str, video_note: str,
duration: int = 0, duration: int = 0,
@ -101,7 +101,7 @@ class SendVideoNote(BaseClient):
file = None file = None
if os.path.exists(video_note): if os.path.exists(video_note):
file = self.save_file(video_note, progress=progress, progress_args=progress_args) file = await self.save_file(video_note, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument( media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map[".mp4"], mime_type=mimetypes.types_map[".mp4"],
file=file, file=file,
@ -139,9 +139,9 @@ class SendVideoNote(BaseClient):
while True: while True:
try: try:
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=media, media=media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -151,11 +151,11 @@ class SendVideoNote(BaseClient):
) )
) )
except FilePartMissing as e: except FilePartMissing as e:
self.save_file(video_note, file_id=file.id, file_part=e.x) await self.save_file(video_note, file_id=file.id, file_part=e.x)
else: else:
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -27,7 +27,7 @@ from ....ext import BaseClient, utils
class SendVoice(BaseClient): class SendVoice(BaseClient):
def send_voice(self, async def send_voice(self,
chat_id: int or str, chat_id: int or str,
voice: str, voice: str,
caption: str = "", caption: str = "",
@ -108,7 +108,7 @@ class SendVoice(BaseClient):
style = self.html if parse_mode.lower() == "html" else self.markdown style = self.html if parse_mode.lower() == "html" else self.markdown
if os.path.exists(voice): if os.path.exists(voice):
file = self.save_file(voice, progress=progress, progress_args=progress_args) file = await self.save_file(voice, progress=progress, progress_args=progress_args)
media = types.InputMediaUploadedDocument( media = types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map.get("." + voice.split(".")[-1], "audio/mpeg"), mime_type=mimetypes.types_map.get("." + voice.split(".")[-1], "audio/mpeg"),
file=file, file=file,
@ -148,9 +148,9 @@ class SendVoice(BaseClient):
while True: while True:
try: try:
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=media, media=media,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -160,11 +160,11 @@ class SendVoice(BaseClient):
) )
) )
except FilePartMissing as e: except FilePartMissing as e:
self.save_file(voice, file_id=file.id, file_part=e.x) await self.save_file(voice, file_id=file.id, file_part=e.x)
else: else:
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -22,7 +22,7 @@ from ...ext import utils, BaseClient
class SendMessage(BaseClient): class SendMessage(BaseClient):
def send_message(self, async def send_message(self,
chat_id: int or str, chat_id: int or str,
text: str, text: str,
parse_mode: str = "", parse_mode: str = "",
@ -69,9 +69,9 @@ class SendMessage(BaseClient):
""" """
style = self.html if parse_mode.lower() == "html" else self.markdown style = self.html if parse_mode.lower() == "html" else self.markdown
r = self.send( r = await self.send(
functions.messages.SendMessage( functions.messages.SendMessage(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
no_webpage=disable_web_page_preview or None, no_webpage=disable_web_page_preview or None,
silent=disable_notification or None, silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
@ -91,7 +91,7 @@ class SendMessage(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient
class DeleteMessages(BaseClient): class DeleteMessages(BaseClient):
def delete_messages(self, async def delete_messages(self,
chat_id: int or str, chat_id: int or str,
message_ids, message_ids,
revoke: bool = True): revoke: bool = True):
@ -56,18 +56,18 @@ class DeleteMessages(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
peer = self.resolve_peer(chat_id) peer = await self.resolve_peer(chat_id)
message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids] message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids]
if isinstance(peer, types.InputPeerChannel): if isinstance(peer, types.InputPeerChannel):
self.send( await self.send(
functions.channels.DeleteMessages( functions.channels.DeleteMessages(
channel=peer, channel=peer,
id=message_ids id=message_ids
) )
) )
else: else:
self.send( await self.send(
functions.messages.DeleteMessages( functions.messages.DeleteMessages(
id=message_ids, id=message_ids,
revoke=revoke or None revoke=revoke or None

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient, utils
class EditMessageCaption(BaseClient): class EditMessageCaption(BaseClient):
def edit_message_caption(self, async def edit_message_caption(self,
chat_id: int or str, chat_id: int or str,
message_id: int, message_id: int,
caption: str, caption: str,
@ -58,9 +58,9 @@ class EditMessageCaption(BaseClient):
""" """
style = self.html if parse_mode.lower() == "html" else self.markdown style = self.html if parse_mode.lower() == "html" else self.markdown
r = self.send( r = await self.send(
functions.messages.EditMessage( functions.messages.EditMessage(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
id=message_id, id=message_id,
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **style.parse(caption)
@ -69,7 +69,7 @@ class EditMessageCaption(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)): if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient, utils
class EditMessageReplyMarkup(BaseClient): class EditMessageReplyMarkup(BaseClient):
def edit_message_reply_markup(self, async def edit_message_reply_markup(self,
chat_id: int or str, chat_id: int or str,
message_id: int, message_id: int,
reply_markup=None): reply_markup=None):
@ -48,9 +48,9 @@ class EditMessageReplyMarkup(BaseClient):
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
r = self.send( r = await self.send(
functions.messages.EditMessage( functions.messages.EditMessage(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
id=message_id, id=message_id,
reply_markup=reply_markup.write() if reply_markup else None reply_markup=reply_markup.write() if reply_markup else None
) )
@ -58,7 +58,7 @@ class EditMessageReplyMarkup(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)): if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}

View file

@ -21,7 +21,7 @@ from ....ext import BaseClient, utils
class EditMessageText(BaseClient): class EditMessageText(BaseClient):
def edit_message_text(self, async def edit_message_text(self,
chat_id: int or str, chat_id: int or str,
message_id: int, message_id: int,
text: str, text: str,
@ -62,9 +62,9 @@ class EditMessageText(BaseClient):
""" """
style = self.html if parse_mode.lower() == "html" else self.markdown style = self.html if parse_mode.lower() == "html" else self.markdown
r = self.send( r = await self.send(
functions.messages.EditMessage( functions.messages.EditMessage(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
id=message_id, id=message_id,
no_webpage=disable_web_page_preview or None, no_webpage=disable_web_page_preview or None,
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
@ -74,7 +74,7 @@ class EditMessageText(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)): if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}