diff --git a/pyrogram/client/dispatcher/dispatcher.py b/pyrogram/client/dispatcher/dispatcher.py
index e6dcd4b6..8a22ad7e 100644
--- a/pyrogram/client/dispatcher/dispatcher.py
+++ b/pyrogram/client/dispatcher/dispatcher.py
@@ -72,7 +72,7 @@ class Dispatcher:
self.update_parsers = {
Dispatcher.MESSAGE_UPDATES: message_parser,
- Dispatcher.DELETE_MESSAGE_UPDATES: deleted_messages_parser,
+ Dispatcher.DELETE_MESSAGES_UPDATES: deleted_messages_parser,
Dispatcher.CALLBACK_QUERY_UPDATES: callback_query_parser,
(types.UpdateUserStatus,): user_status_parser
}
diff --git a/pyrogram/client/ext/utils.py b/pyrogram/client/ext/utils.py
index 3e67e3cd..cb2dda39 100644
--- a/pyrogram/client/ext/utils.py
+++ b/pyrogram/client/ext/utils.py
@@ -16,7 +16,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+import asyncio
+import sys
from base64 import b64decode, b64encode
+from concurrent.futures.thread import ThreadPoolExecutor
from ...api import types
@@ -57,6 +60,15 @@ def encode(s: bytes) -> str:
return b64encode(r, b"-_").decode().rstrip("=")
+async def ainput(prompt: str = ""):
+ print(prompt, end="", flush=True)
+
+ with ThreadPoolExecutor(1) as executor:
+ return (await asyncio.get_event_loop().run_in_executor(
+ executor, sys.stdin.readline
+ )).rstrip()
+
+
def get_peer_id(input_peer) -> int:
return (
input_peer.user_id if isinstance(input_peer, types.InputPeerUser)
diff --git a/pyrogram/client/methods/messages/get_messages.py b/pyrogram/client/methods/messages/get_messages.py
index edcad039..b1ee9339 100644
--- a/pyrogram/client/methods/messages/get_messages.py
+++ b/pyrogram/client/methods/messages/get_messages.py
@@ -78,6 +78,6 @@ class GetMessages(BaseClient):
else:
rpc = functions.messages.GetMessages(id=ids)
- messages = await pyrogram.Messages._parse(self, self.send(rpc))
+ messages = await pyrogram.Messages._parse(self, await self.send(rpc))
return messages if is_iterable else messages.messages[0]
diff --git a/pyrogram/client/methods/users/get_me.py b/pyrogram/client/methods/users/get_me.py
index 390c3b2c..11dd657f 100644
--- a/pyrogram/client/methods/users/get_me.py
+++ b/pyrogram/client/methods/users/get_me.py
@@ -33,9 +33,9 @@ class GetMe(BaseClient):
"""
return pyrogram.User._parse(
self,
- await self.send(
+ (await self.send(
functions.users.GetFullUser(
types.InputPeerSelf()
)
- ).user
+ )).user
)
diff --git a/pyrogram/client/types/bots/callback_query.py b/pyrogram/client/types/bots/callback_query.py
index c3c23333..3c046cf9 100644
--- a/pyrogram/client/types/bots/callback_query.py
+++ b/pyrogram/client/types/bots/callback_query.py
@@ -78,7 +78,7 @@ class CallbackQuery(PyrogramType):
self.game_short_name = game_short_name
@staticmethod
- def _parse(client, callback_query, users) -> "CallbackQuery":
+ async def _parse(client, callback_query, users) -> "CallbackQuery":
message = None
inline_message_id = None
@@ -92,7 +92,7 @@ class CallbackQuery(PyrogramType):
else:
peer_id = int("-100" + str(peer.channel_id))
- message = client.get_messages(peer_id, callback_query.msg_id)
+ message = await client.get_messages(peer_id, callback_query.msg_id)
elif isinstance(callback_query, types.UpdateInlineBotCallbackQuery):
inline_message_id = b64encode(
pack(
diff --git a/pyrogram/client/types/messages_and_media/sticker.py b/pyrogram/client/types/messages_and_media/sticker.py
index 94385681..c84acd23 100644
--- a/pyrogram/client/types/messages_and_media/sticker.py
+++ b/pyrogram/client/types/messages_and_media/sticker.py
@@ -16,9 +16,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from functools import lru_cache
from struct import pack
+from async_lru import alru_cache
+
import pyrogram
from pyrogram.api import types, functions
from pyrogram.api.errors import StickersetInvalid
@@ -92,14 +93,14 @@ class Sticker(PyrogramType):
# self.mask_position = mask_position
@staticmethod
- @lru_cache(maxsize=256)
+ @alru_cache(maxsize=256)
async def get_sticker_set_name(send, input_sticker_set_id):
try:
- return await send(
+ return (await send(
functions.messages.GetStickerSet(
types.InputStickerSetID(*input_sticker_set_id)
)
- ).set.short_name
+ )).set.short_name
except StickersetInvalid:
return None
diff --git a/requirements.txt b/requirements.txt
index 8f1eea95..ccfa89ee 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,3 @@
pyaes==1.6.1
pysocks==1.6.8
-typing==3.6.6
\ No newline at end of file
+async_lru==1.0.1
\ No newline at end of file