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