Skip to content

Commit 663ffd3

Browse files
committed
Add schedule_date and attempt to parse send_inline_bot_result
Git-Origin-Commit-Id: 591cd3a
1 parent 69a281e commit 663ffd3

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

docs/source/releases/changes-in-this-fork.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Changes in this Fork
2323
| Scheme layer used: 194 |
2424
+------------------------+
2525

26+
- Added the field ``schedule_date`` and changed the return type of the :meth:`~pyrogram.Client.send_inline_bot_result`.
2627
- Added the field ``subscription_expiration_date`` in the :obj:`~pyrogram.types.SuccessfulPayment`.
2728
- Added the parameter ``subscription_period`` in the :meth:`~pyrogram.Client.create_invoice_link`.
2829
- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=192&to=194>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=192&to=194>`__.

pyrogram/methods/bots/send_inline_bot_result.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
import logging
20+
from datetime import datetime
2021
from typing import Union
2122

2223
import pyrogram
@@ -35,8 +36,9 @@ async def send_inline_bot_result(
3536
reply_parameters: "types.ReplyParameters" = None,
3637
send_as: Union[int, str] = None,
3738
message_thread_id: int = None,
39+
schedule_date: datetime = None,
3840
reply_to_message_id: int = None
39-
) -> "raw.base.Updates":
41+
) -> Union["types.Message", bool]:
4042
"""Send an inline bot result.
4143
Bot results can be retrieved using :meth:`~pyrogram.Client.get_inline_bot_results`
4244
@@ -71,8 +73,14 @@ async def send_inline_bot_result(
7173
message_thread_id (``int``, *optional*):
7274
If the message is in a thread, ID of the original message.
7375
76+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
77+
Date when the message will be automatically sent.
78+
7479
Returns:
75-
:obj:`~pyrogram.raw.base.Updates`: Currently, on success, a raw result is returned.
80+
:obj:`~pyrogram.types.Message`: On success, the sent message is returned or False if no message was sent.
81+
82+
Raises:
83+
RPCError: In case of a Telegram RPC error.
7684
7785
Example:
7886
.. code-block:: python
@@ -99,14 +107,33 @@ async def send_inline_bot_result(
99107
reply_parameters
100108
)
101109

102-
return await self.invoke(
110+
r = await self.invoke(
103111
raw.functions.messages.SendInlineBotResult(
104112
peer=await self.resolve_peer(chat_id),
105113
query_id=query_id,
106114
id=result_id,
107115
random_id=self.rnd_id(),
108116
send_as=await self.resolve_peer(send_as) if send_as else None,
109117
silent=disable_notification or None,
110-
reply_to=reply_to
118+
reply_to=reply_to,
119+
schedule_date=utils.datetime_to_timestamp(schedule_date),
111120
)
112121
)
122+
123+
for i in r.updates:
124+
if isinstance(
125+
i,
126+
(
127+
raw.types.UpdateNewMessage,
128+
raw.types.UpdateNewChannelMessage,
129+
raw.types.UpdateNewScheduledMessage
130+
)
131+
):
132+
return await types.Message._parse(
133+
self, i.message,
134+
{i.id: i for i in r.users},
135+
{i.id: i for i in r.chats},
136+
is_scheduled=isinstance(i, raw.types.UpdateNewScheduledMessage),
137+
replies=self.fetch_replies
138+
)
139+
return False

0 commit comments

Comments
 (0)