mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Add InlineQueryResultCachedSticker
This commit is contained in:
parent
0b0af2da5b
commit
a9cadf3022
@ -24,6 +24,7 @@ from .inline_query_result_article import InlineQueryResultArticle
|
||||
from .inline_query_result_audio import InlineQueryResultAudio
|
||||
from .inline_query_result_cached_animation import InlineQueryResultCachedAnimation
|
||||
from .inline_query_result_cached_photo import InlineQueryResultCachedPhoto
|
||||
from .inline_query_result_cached_sticker import InlineQueryResultCachedSticker
|
||||
from .inline_query_result_contact import InlineQueryResultContact
|
||||
from .inline_query_result_document import InlineQueryResultDocument
|
||||
from .inline_query_result_location import InlineQueryResultLocation
|
||||
@ -36,5 +37,6 @@ __all__ = [
|
||||
"InlineQuery", "InlineQueryResult", "InlineQueryResultArticle", "InlineQueryResultPhoto",
|
||||
"InlineQueryResultAnimation", "InlineQueryResultAudio", "InlineQueryResultVideo", "ChosenInlineResult",
|
||||
"InlineQueryResultContact", "InlineQueryResultDocument", "InlineQueryResultVoice", "InlineQueryResultLocation",
|
||||
"InlineQueryResultVenue", "InlineQueryResultCachedPhoto", "InlineQueryResultCachedAnimation"
|
||||
"InlineQueryResultVenue", "InlineQueryResultCachedPhoto", "InlineQueryResultCachedAnimation",
|
||||
"InlineQueryResultCachedSticker"
|
||||
]
|
||||
|
@ -0,0 +1,78 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Pyrogram is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types
|
||||
from .inline_query_result import InlineQueryResult
|
||||
from ...file_id import FileId
|
||||
|
||||
|
||||
class InlineQueryResultCachedSticker(InlineQueryResult):
|
||||
"""A link to a sticker stored on the Telegram servers
|
||||
|
||||
By default, this sticker will be sent by the user. Alternatively, you can use *input_message_content* to send a
|
||||
message with the specified content instead of the sticker.
|
||||
|
||||
Parameters:
|
||||
sticker_file_id (``str``):
|
||||
A valid file identifier of the sticker.
|
||||
|
||||
id (``str``, *optional*):
|
||||
Unique identifier for this result, 1-64 bytes.
|
||||
Defaults to a randomly generated UUID4.
|
||||
|
||||
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
|
||||
An InlineKeyboardMarkup object.
|
||||
|
||||
input_message_content (:obj:`~pyrogram.types.InputMessageContent`):
|
||||
Content of the message to be sent instead of the photo.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
sticker_file_id: str,
|
||||
id: str = None,
|
||||
reply_markup: "types.InlineKeyboardMarkup" = None,
|
||||
input_message_content: "types.InputMessageContent" = None
|
||||
):
|
||||
super().__init__("sticker", id, input_message_content, reply_markup)
|
||||
|
||||
self.sticker_file_id = sticker_file_id
|
||||
self.reply_markup = reply_markup
|
||||
self.input_message_content = input_message_content
|
||||
|
||||
async def write(self, client: "pyrogram.Client"):
|
||||
file_id = FileId.decode(self.sticker_file_id)
|
||||
|
||||
return raw.types.InputBotInlineResultDocument(
|
||||
id=self.id,
|
||||
type=self.type,
|
||||
document=raw.types.InputDocument(
|
||||
id=file_id.media_id,
|
||||
access_hash=file_id.access_hash,
|
||||
file_reference=file_id.file_reference,
|
||||
),
|
||||
send_message=(
|
||||
await self.input_message_content.write(client, self.reply_markup)
|
||||
if self.input_message_content
|
||||
else raw.types.InputBotInlineMessageMediaAuto(
|
||||
reply_markup=await self.reply_markup.write(client) if self.reply_markup else None,
|
||||
message="",
|
||||
)
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user