mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 05:30:15 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/client/dispatcher/dispatcher.py # pyrogram/client/methods/bots/request_callback_answer.py # pyrogram/client/types/messages_and_media/message.py
This commit is contained in:
commit
017c61a876
@ -128,7 +128,7 @@ class Dispatcher:
|
||||
if parser is None:
|
||||
continue
|
||||
|
||||
update, handler_type = await parser(update, users, chats)
|
||||
parsed_update, handler_type = await parser(update, users, chats)
|
||||
|
||||
for group in self.groups.values():
|
||||
for handler in group:
|
||||
@ -137,8 +137,8 @@ class Dispatcher:
|
||||
if isinstance(handler, RawUpdateHandler):
|
||||
args = (update, users, chats)
|
||||
elif isinstance(handler, handler_type):
|
||||
if handler.check(update):
|
||||
args = (update,)
|
||||
if handler.check(parsed_update):
|
||||
args = (parsed_update,)
|
||||
|
||||
if args is None:
|
||||
continue
|
||||
|
@ -22,7 +22,6 @@ import sys
|
||||
from base64 import b64decode, b64encode
|
||||
from concurrent.futures.thread import ThreadPoolExecutor
|
||||
from struct import pack
|
||||
from weakref import proxy
|
||||
|
||||
from pyrogram.client import types as pyrogram_types
|
||||
from ...api import types, functions
|
||||
@ -636,7 +635,7 @@ async def parse_messages(
|
||||
views=message.views,
|
||||
via_bot=parse_user(users.get(message.via_bot_id, None)),
|
||||
outgoing=message.out,
|
||||
client=proxy(client),
|
||||
client=client,
|
||||
reply_markup=reply_markup
|
||||
)
|
||||
|
||||
@ -751,7 +750,7 @@ async def parse_messages(
|
||||
migrate_from_chat_id=-migrate_from_chat_id if migrate_from_chat_id else None,
|
||||
group_chat_created=group_chat_created,
|
||||
channel_chat_created=channel_chat_created,
|
||||
client=proxy(client)
|
||||
client=client
|
||||
# TODO: supergroup_chat_created
|
||||
)
|
||||
|
||||
@ -765,7 +764,7 @@ async def parse_messages(
|
||||
except MessageIdsEmpty:
|
||||
pass
|
||||
else:
|
||||
m = pyrogram_types.Message(message_id=message.id, client=proxy(client), empty=True)
|
||||
m = pyrogram_types.Message(message_id=message.id, client=client, empty=True)
|
||||
|
||||
parsed_messages.append(m)
|
||||
|
||||
|
@ -24,7 +24,7 @@ class RequestCallbackAnswer(BaseClient):
|
||||
async def request_callback_answer(self,
|
||||
chat_id: int or str,
|
||||
message_id: int,
|
||||
callback_data: str):
|
||||
callback_data: bytes):
|
||||
"""Use this method to request a callback answer from bots. This is the equivalent of clicking an
|
||||
inline button containing callback data.
|
||||
|
||||
@ -37,7 +37,7 @@ class RequestCallbackAnswer(BaseClient):
|
||||
message_id (``int``):
|
||||
The message id the inline keyboard is attached on.
|
||||
|
||||
callback_data (``str``):
|
||||
callback_data (``bytes``):
|
||||
Callback data associated with the inline button you want to get the answer from.
|
||||
|
||||
Returns:
|
||||
@ -52,7 +52,7 @@ class RequestCallbackAnswer(BaseClient):
|
||||
functions.messages.GetBotCallbackAnswer(
|
||||
peer=self.resolve_peer(chat_id),
|
||||
msg_id=message_id,
|
||||
data=callback_data.encode()
|
||||
data=callback_data
|
||||
),
|
||||
retries=0,
|
||||
timeout=10
|
||||
|
@ -67,6 +67,7 @@ class SendMessage(BaseClient):
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
style = self.html if parse_mode.lower() == "html" else self.markdown
|
||||
message, entities = style.parse(text).values()
|
||||
|
||||
r = await self.send(
|
||||
functions.messages.SendMessage(
|
||||
@ -76,16 +77,20 @@ class SendMessage(BaseClient):
|
||||
reply_to_msg_id=reply_to_message_id,
|
||||
random_id=self.rnd_id(),
|
||||
reply_markup=reply_markup.write() if reply_markup else None,
|
||||
**style.parse(text)
|
||||
message=message,
|
||||
entities=entities
|
||||
)
|
||||
)
|
||||
|
||||
if isinstance(r, types.UpdateShortSentMessage):
|
||||
return pyrogram_types.Message(
|
||||
message_id=r.id,
|
||||
chat=pyrogram_types.Chat(id=list(self.resolve_peer(chat_id).__dict__.values())[0], type="private"),
|
||||
text=message,
|
||||
date=r.date,
|
||||
outgoing=r.out,
|
||||
entities=utils.parse_entities(r.entities, {}) or None
|
||||
entities=entities,
|
||||
client=self
|
||||
)
|
||||
|
||||
for i in r.updates:
|
||||
|
@ -579,10 +579,7 @@ class Message(Object):
|
||||
``TimeoutError``: If, after clicking an inline button, the bot fails to answer within 10 seconds
|
||||
"""
|
||||
if isinstance(self.reply_markup, ReplyKeyboardMarkup):
|
||||
if quote is None:
|
||||
quote = self.chat.type != "private"
|
||||
|
||||
return await self.reply(x, quote=quote)
|
||||
return await self.reply(x)
|
||||
elif isinstance(self.reply_markup, InlineKeyboardMarkup):
|
||||
if isinstance(x, int) and y is None:
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user