mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-09-21 03:08:49 +03:00
Improve inline result documentation with more examples
This commit is contained in:
parent
9c5b9abb93
commit
312dac90a3
|
@ -147,6 +147,9 @@ class InlineQuery(EventBuilder):
|
||||||
"""
|
"""
|
||||||
Answers the inline query with the given results.
|
Answers the inline query with the given results.
|
||||||
|
|
||||||
|
See the documentation for `builder` to know what kind of answers
|
||||||
|
can be given.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
results (`list`, optional):
|
results (`list`, optional):
|
||||||
A list of :tl:`InputBotInlineResult` to use.
|
A list of :tl:`InputBotInlineResult` to use.
|
||||||
|
|
|
@ -83,6 +83,31 @@ class InlineBuilder:
|
||||||
content (:tl:`InputWebDocument`, optional):
|
content (:tl:`InputWebDocument`, optional):
|
||||||
The content to be shown for this result.
|
The content to be shown for this result.
|
||||||
For now it has to be a :tl:`InputWebDocument` if present.
|
For now it has to be a :tl:`InputWebDocument` if present.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
results = [
|
||||||
|
# Option with title and description sending a message.
|
||||||
|
builder.article(
|
||||||
|
title='First option',
|
||||||
|
description='This is the first option',
|
||||||
|
text='Text sent after clicking this option',
|
||||||
|
),
|
||||||
|
# Option with title URL to be opened when clicked.
|
||||||
|
builder.article(
|
||||||
|
title='Second option',
|
||||||
|
url='https://example.com',
|
||||||
|
text='Text sent if the user clicks the option and not the URL',
|
||||||
|
),
|
||||||
|
# Sending a message with buttons.
|
||||||
|
# You can use a list or a list of lists to include more buttons.
|
||||||
|
builder.article(
|
||||||
|
title='Third option',
|
||||||
|
text='Text sent with buttons below',
|
||||||
|
buttons=Button.url('https://example.com'),
|
||||||
|
),
|
||||||
|
]
|
||||||
"""
|
"""
|
||||||
# TODO Does 'article' work always?
|
# TODO Does 'article' work always?
|
||||||
# article, photo, gif, mpeg4_gif, video, audio,
|
# article, photo, gif, mpeg4_gif, video, audio,
|
||||||
|
@ -126,6 +151,28 @@ class InlineBuilder:
|
||||||
file (`obj`, optional):
|
file (`obj`, optional):
|
||||||
Same as ``file`` for `client.send_file()
|
Same as ``file`` for `client.send_file()
|
||||||
<telethon.client.uploads.UploadMethods.send_file>`.
|
<telethon.client.uploads.UploadMethods.send_file>`.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
results = [
|
||||||
|
# Sending just the photo when the user selects it.
|
||||||
|
builder.photo('/path/to/photo.jpg'),
|
||||||
|
|
||||||
|
# Including a caption with some in-memory photo.
|
||||||
|
photo_bytesio = ...
|
||||||
|
builder.photo(
|
||||||
|
photo_bytesio,
|
||||||
|
text='This will be the caption of the sent photo',
|
||||||
|
),
|
||||||
|
|
||||||
|
# Sending just the message without including the photo.
|
||||||
|
builder.photo(
|
||||||
|
photo,
|
||||||
|
text='This will be a normal text message',
|
||||||
|
include_media=False,
|
||||||
|
),
|
||||||
|
]
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
fh = utils.get_input_photo(file)
|
fh = utils.get_input_photo(file)
|
||||||
|
@ -190,15 +237,35 @@ class InlineBuilder:
|
||||||
Further explanation of what this result means.
|
Further explanation of what this result means.
|
||||||
|
|
||||||
type (`str`, optional):
|
type (`str`, optional):
|
||||||
The type of the document. May be one of: photo, gif,
|
The type of the document. May be one of: article, audio,
|
||||||
mpeg4_gif, video, audio, voice, document, sticker.
|
contact, file, geo, gif, photo, sticker, venue, video, voice.
|
||||||
|
|
||||||
See "Type of the result" in https://core.telegram.org/bots/api.
|
|
||||||
|
|
||||||
include_media (`bool`, optional):
|
include_media (`bool`, optional):
|
||||||
Whether the document file used to display the result should be
|
Whether the document file used to display the result should be
|
||||||
included in the message itself or not. By default, the document
|
included in the message itself or not. By default, the document
|
||||||
is included, and the text parameter alters the caption.
|
is included, and the text parameter alters the caption.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
results = [
|
||||||
|
# Sending just the file when the user selects it.
|
||||||
|
builder.document('/path/to/file.pdf'),
|
||||||
|
|
||||||
|
# Including a caption with some in-memory file.
|
||||||
|
file_bytesio = ...
|
||||||
|
builder.document(
|
||||||
|
file_bytesio,
|
||||||
|
text='This will be the caption of the sent file',
|
||||||
|
),
|
||||||
|
|
||||||
|
# Sending just the message without including the file.
|
||||||
|
builder.document(
|
||||||
|
photo,
|
||||||
|
text='This will be a normal text message',
|
||||||
|
include_media=False,
|
||||||
|
),
|
||||||
|
]
|
||||||
"""
|
"""
|
||||||
if type is None:
|
if type is None:
|
||||||
if voice_note:
|
if voice_note:
|
||||||
|
|
|
@ -13,6 +13,10 @@ class InlineResult:
|
||||||
result (:tl:`BotInlineResult`):
|
result (:tl:`BotInlineResult`):
|
||||||
The original :tl:`BotInlineResult` object.
|
The original :tl:`BotInlineResult` object.
|
||||||
"""
|
"""
|
||||||
|
# tdlib types are the following (InlineQueriesManager::answer_inline_query @ 1a4a834):
|
||||||
|
# gif, article, audio, contact, file, geo, photo, sticker, venue, video, voice
|
||||||
|
#
|
||||||
|
# However, those documented in https://core.telegram.org/bots/api#inline-mode are different.
|
||||||
ARTICLE = 'article'
|
ARTICLE = 'article'
|
||||||
PHOTO = 'photo'
|
PHOTO = 'photo'
|
||||||
GIF = 'gif'
|
GIF = 'gif'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user