mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 13:34:54 +00:00
More async chore
This commit is contained in:
parent
26e828b956
commit
21af0f3e82
@ -249,7 +249,7 @@ def encode(s: bytes) -> str:
|
|||||||
|
|
||||||
|
|
||||||
# TODO: Reorganize code, maybe split parts as well
|
# TODO: Reorganize code, maybe split parts as well
|
||||||
def parse_messages(
|
async def parse_messages(
|
||||||
client,
|
client,
|
||||||
messages: list or types.Message or types.MessageService or types.MessageEmpty,
|
messages: list or types.Message or types.MessageService or types.MessageEmpty,
|
||||||
users: dict,
|
users: dict,
|
||||||
@ -484,9 +484,9 @@ def parse_messages(
|
|||||||
|
|
||||||
if isinstance(sticker_attribute.stickerset, types.InputStickerSetID):
|
if isinstance(sticker_attribute.stickerset, types.InputStickerSetID):
|
||||||
try:
|
try:
|
||||||
set_name = client.send(
|
set_name = (await client.send(
|
||||||
functions.messages.GetStickerSet(sticker_attribute.stickerset)
|
functions.messages.GetStickerSet(sticker_attribute.stickerset)
|
||||||
).set.short_name
|
)).set.short_name
|
||||||
except StickersetInvalid:
|
except StickersetInvalid:
|
||||||
set_name = None
|
set_name = None
|
||||||
else:
|
else:
|
||||||
@ -591,7 +591,7 @@ def parse_messages(
|
|||||||
if message.reply_to_msg_id and replies:
|
if message.reply_to_msg_id and replies:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
m.reply_to_message = client.get_messages(
|
m.reply_to_message = await client.get_messages(
|
||||||
m.chat.id, message.reply_to_msg_id,
|
m.chat.id, message.reply_to_msg_id,
|
||||||
replies=replies - 1
|
replies=replies - 1
|
||||||
)
|
)
|
||||||
@ -693,7 +693,7 @@ def parse_messages(
|
|||||||
if isinstance(action, types.MessageActionPinMessage):
|
if isinstance(action, types.MessageActionPinMessage):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
m.pinned_message = client.get_messages(
|
m.pinned_message = await client.get_messages(
|
||||||
m.chat.id, message.reply_to_msg_id,
|
m.chat.id, message.reply_to_msg_id,
|
||||||
replies=0
|
replies=0
|
||||||
)
|
)
|
||||||
@ -790,7 +790,7 @@ def parse_photos(photos):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_callback_query(client, callback_query, users):
|
async def parse_callback_query(client, callback_query, users):
|
||||||
peer = callback_query.peer
|
peer = callback_query.peer
|
||||||
|
|
||||||
if isinstance(peer, types.PeerUser):
|
if isinstance(peer, types.PeerUser):
|
||||||
@ -803,14 +803,14 @@ def parse_callback_query(client, callback_query, users):
|
|||||||
return pyrogram_types.CallbackQuery(
|
return pyrogram_types.CallbackQuery(
|
||||||
id=str(callback_query.query_id),
|
id=str(callback_query.query_id),
|
||||||
from_user=parse_user(users[callback_query.user_id]),
|
from_user=parse_user(users[callback_query.user_id]),
|
||||||
message=client.get_messages(peer_id, callback_query.msg_id),
|
message=await client.get_messages(peer_id, callback_query.msg_id),
|
||||||
chat_instance=str(callback_query.chat_instance),
|
chat_instance=str(callback_query.chat_instance),
|
||||||
data=callback_query.data.decode(),
|
data=callback_query.data.decode(),
|
||||||
game_short_name=callback_query.game_short_name
|
game_short_name=callback_query.game_short_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_inline_callback_query(callback_query, users):
|
async def parse_inline_callback_query(callback_query, users):
|
||||||
return pyrogram_types.CallbackQuery(
|
return pyrogram_types.CallbackQuery(
|
||||||
id=str(callback_query.query_id),
|
id=str(callback_query.query_id),
|
||||||
from_user=parse_user(users[callback_query.user_id]),
|
from_user=parse_user(users[callback_query.user_id]),
|
||||||
@ -828,7 +828,7 @@ def parse_inline_callback_query(callback_query, users):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_chat_full(
|
async def parse_chat_full(
|
||||||
client,
|
client,
|
||||||
chat_full: types.messages.ChatFull or types.UserFull
|
chat_full: types.messages.ChatFull or types.UserFull
|
||||||
) -> pyrogram_types.Chat:
|
) -> pyrogram_types.Chat:
|
||||||
@ -853,7 +853,7 @@ def parse_chat_full(
|
|||||||
chat.sticker_set_name = full_chat.stickerset
|
chat.sticker_set_name = full_chat.stickerset
|
||||||
|
|
||||||
if full_chat.pinned_msg_id:
|
if full_chat.pinned_msg_id:
|
||||||
chat.pinned_message = client.get_messages(
|
chat.pinned_message = await client.get_messages(
|
||||||
int("-100" + str(full_chat.id)),
|
int("-100" + str(full_chat.id)),
|
||||||
full_chat.pinned_msg_id
|
full_chat.pinned_msg_id
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user