Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ def get_title_list(s: str) -> list:
InlineQueryResultVoice
InlineQueryResultArticle
InlineQueryResultContact
InlineQueryResultGame
InlineQueryResultLocation
InlineQueryResultVenue
""",
Expand Down Expand Up @@ -795,6 +796,10 @@ def get_title_list(s: str) -> list:
CallbackQuery.edit_message_caption
CallbackQuery.edit_message_media
CallbackQuery.edit_message_reply_markup
ChosenInlineResult.edit_message_text
ChosenInlineResult.edit_message_caption
ChosenInlineResult.edit_message_media
ChosenInlineResult.edit_message_reply_markup
""",
inline_query="""
InlineQuery
Expand Down
9 changes: 9 additions & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

Changes in this Fork
=====================

.. admonition :: A Word of Warning
:class: tip

Expand Down Expand Up @@ -29,6 +32,12 @@ Changes in this Fork
| Scheme layer used: 199 |
+------------------------+

- Added the class :obj:`~pyrogram.types.InlineQueryResultGame`.
- Added the bound methods :meth:`~pyrogram.types.ChosenInlineResult.edit_message_text`, :meth:`~pyrogram.types.ChosenInlineResult.edit_message_caption`, :meth:`~pyrogram.types.ChosenInlineResult.edit_message_media` and :meth:`~pyrogram.types.ChosenInlineResult.edit_message_reply_markup`.
- Renamed the fields ``thumb_url``, ``thumb_width``, and ``thumb_height`` in the classes :obj:`~pyrogram.types.InlineQueryResultArticle`, :obj:`~pyrogram.types.InlineQueryResultContact`, :obj:`~pyrogram.types.InlineQueryResultDocument`, :obj:`~pyrogram.types.InlineQueryResultLocation`, and :obj:`~pyrogram.types.InlineQueryResultVenue` to ``thumbnail_url``, ``thumbnail_width``, and ``thumbnail_height`` respectively.
- Renamed the field ``thumb_url`` in the classes :obj:`~pyrogram.types.InlineQueryResultPhoto` and :obj:`~pyrogram.types.InlineQueryResultVideo` to ``thumbnail_url``.
- Added the field ``animation_mime_type`` and renamed the fields ``thumb_url`` and ``thumb_mime_type`` in the classes :obj:`~pyrogram.types.InlineQueryResultAnimation` to ``thumbnail_url`` and ``thumbnail_mime_type`` respectively.
- Fixed a bug with ``_client`` being None in :obj:`~pyrogram.handlers.ChosenInlineResultHandler`.
- Added the parameters ``video_cover`` and ``video_start_timestamp`` to the method :meth:`~pyrogram.Client.copy_message`, allowing bots to change the start timestamp for copied videos.
- Added ``for_paid_reactions`` in :meth:`~pyrogram.Client.get_send_as_chats`.
- `Updated documentation and parameter names according to BOT API 8.3 <https://github.com/TelegramPlayGround/pyrogram/commit/7675b40>`__
Expand Down
11 changes: 10 additions & 1 deletion pyrogram/types/bots_and_keyboards/callback_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ def __init__(
self.matches = matches

@staticmethod
async def _parse(client: "pyrogram.Client", callback_query, users, chats) -> "CallbackQuery":
async def _parse(
client: "pyrogram.Client",
callback_query: Union[
"raw.types.UpdateBotCallbackQuery",
"raw.types.UpdateInlineBotCallbackQuery",
"raw.types.UpdateBusinessBotCallbackQuery",
],
users: dict,
chats: dict,
) -> "CallbackQuery":
message = None
inline_message_id = None

Expand Down
2 changes: 2 additions & 0 deletions pyrogram/types/inline_mode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .inline_query_result_cached_video import InlineQueryResultCachedVideo
from .inline_query_result_cached_voice import InlineQueryResultCachedVoice
from .inline_query_result_contact import InlineQueryResultContact
from .inline_query_result_game import InlineQueryResultGame
from .inline_query_result_document import InlineQueryResultDocument
from .inline_query_result_location import InlineQueryResultLocation
from .inline_query_result_photo import InlineQueryResultPhoto
Expand Down Expand Up @@ -56,6 +57,7 @@
"InlineQueryResultVoice",
"InlineQueryResultArticle",
"InlineQueryResultContact",
"InlineQueryResultGame",
"InlineQueryResultLocation",
"InlineQueryResultVenue",
]
155 changes: 152 additions & 3 deletions pyrogram/types/inline_mode/chosen_inline_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Optional

import pyrogram
from pyrogram import raw, types, utils
Expand All @@ -28,8 +29,8 @@ class ChosenInlineResult(Object, Update):

.. note::

In order to receive these updates, your bot must have "inline feedback" enabled. You can enable this feature
with `@BotFather <https://t.me/botfather>`_.
In order to receive these updates, your bot must have "inline feedback" enabled.
You can enable this feature with `@BotFather <https://t.me/botfather>`_.

Parameters:
result_id (``str``):
Expand Down Expand Up @@ -83,5 +84,153 @@ def _parse(client, chosen_inline_result: raw.types.UpdateBotInlineSend, users) -
latitude=chosen_inline_result.geo.lat,
client=client
) if chosen_inline_result.geo else None,
inline_message_id=inline_message_id
inline_message_id=inline_message_id,
client=client
)

async def edit_message_text(
self,
text: str,
parse_mode: Optional["enums.ParseMode"] = None,
entities: list["types.MessageEntity"] = None,
link_preview_options: "types.LinkPreviewOptions" = None,
reply_markup: "types.InlineKeyboardMarkup" = None
) -> bool:
"""Edit the text of messages attached to sent :obj:`~pyrogram.types.InlineQueryResult` messages.

Bound method *edit_message_text* of :obj:`~pyrogram.types.ChosenInlineResult`.

Parameters:
text (``str``):
New text of the message.

parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
By default, texts are parsed using both Markdown and HTML styles.
You can combine both syntaxes together.

entities (List of :obj:`~pyrogram.types.MessageEntity`):
List of special entities that appear in message text, which can be specified instead of *parse_mode*.

link_preview_options (:obj:`~pyrogram.types.LinkPreviewOptions`, *optional*):
Link preview generation options for the message

reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
An InlineKeyboardMarkup object.

Returns:
``bool``: On success, True is returned.

Raises:
RPCError: In case of a Telegram RPC error.
"""
if self.inline_message_id is None:
raise ValueError("Identifier of the inline message is required to edit the message")
else:
return await self._client.edit_inline_text(
inline_message_id=self.inline_message_id,
text=text,
parse_mode=parse_mode,
entities=entities,
link_preview_options=link_preview_options,
reply_markup=reply_markup
)

async def edit_message_caption(
self,
caption: str,
parse_mode: Optional["enums.ParseMode"] = None,
caption_entities: list["types.MessageEntity"] = None,
reply_markup: "types.InlineKeyboardMarkup" = None
) -> bool:
"""Edit the caption of media messages attached to sent :obj:`~pyrogram.types.InlineQueryResult` messages.

Bound method *edit_message_caption* of :obj:`~pyrogram.types.ChosenInlineResult`.

Parameters:
caption (``str``):
New caption of the message.

parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
By default, texts are parsed using both Markdown and HTML styles.
You can combine both syntaxes together.

caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
List of special entities that appear in message text, which can be specified instead of *parse_mode*.

reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
An InlineKeyboardMarkup object.

Returns:
``bool``: On success, True is returned.

Raises:
RPCError: In case of a Telegram RPC error.
"""
return await self.edit_message_text(
text=caption,
parse_mode=parse_mode,
entities=caption_entities,
reply_markup=reply_markup
)

async def edit_message_media(
self,
media: "types.InputMedia",
reply_markup: "types.InlineKeyboardMarkup" = None,
file_name: str = None
) -> bool:
"""Edit animation, audio, document, photo or video messages attached to sent :obj:`~pyrogram.types.InlineQueryResult` messages.

Bound method *edit_message_media* of :obj:`~pyrogram.types.ChosenInlineResult`.

Parameters:
media (:obj:`~pyrogram.types.InputMedia`):
One of the InputMedia objects describing an animation, audio, document, photo or video.

reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
An InlineKeyboardMarkup object.

file_name (``str``, *optional*):
File name of the media to be sent. Not applicable to photos.
Defaults to file's path basename.

Returns:
``bool``: On success, True is returned.

Raises:
RPCError: In case of a Telegram RPC error.
"""
if self.inline_message_id is None:
raise ValueError("Identifier of the inline message is required to edit the message")
else:
return await self._client.edit_inline_media(
inline_message_id=self.inline_message_id,
media=media,
reply_markup=reply_markup
)

async def edit_message_reply_markup(
self,
reply_markup: "types.InlineKeyboardMarkup" = None
) -> bool:
"""Edit only the reply markup of messages attached to sent :obj:`~pyrogram.types.InlineQueryResult` messages.

Bound method *edit_message_reply_markup* of :obj:`~pyrogram.types.ChosenInlineResult`.

Parameters:
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`):
An InlineKeyboardMarkup object.

Returns:
``bool``: On success, True is returned.

Raises:
RPCError: In case of a Telegram RPC error.
"""
if self.inline_message_id is None:
raise ValueError("Identifier of the inline message is required to edit the message")
else:
return await self._client.edit_inline_reply_markup(
inline_message_id=self.inline_message_id,
reply_markup=reply_markup
)
8 changes: 7 additions & 1 deletion pyrogram/types/inline_mode/inline_query_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class InlineQueryResult(Object):
"""One result of an inline query.
"""This object represents one result of an inline query. Telegram clients currently support results of the following 20 types:

- :obj:`~pyrogram.types.InlineQueryResultCachedAudio`
- :obj:`~pyrogram.types.InlineQueryResultCachedDocument`
Expand All @@ -36,13 +36,19 @@ class InlineQueryResult(Object):
- :obj:`~pyrogram.types.InlineQueryResultArticle`
- :obj:`~pyrogram.types.InlineQueryResultAudio`
- :obj:`~pyrogram.types.InlineQueryResultContact`
- :obj:`~pyrogram.types.InlineQueryResultGame`
- :obj:`~pyrogram.types.InlineQueryResultDocument`
- :obj:`~pyrogram.types.InlineQueryResultAnimation`
- :obj:`~pyrogram.types.InlineQueryResultLocation`
- :obj:`~pyrogram.types.InlineQueryResultPhoto`
- :obj:`~pyrogram.types.InlineQueryResultVenue`
- :obj:`~pyrogram.types.InlineQueryResultVideo`
- :obj:`~pyrogram.types.InlineQueryResultVoice`

.. note::

All URLs passed in inline query results will be available to end users and therefore must be assumed to be *public*.

"""

def __init__(
Expand Down
Loading