send_widget()¶
- async Client.send_widget()¶
Send a message with an HTML widget.
Currently, in the production environment, widgets can be sent only to private chats, and sent widgets automatically have protected content and therefore can’t be forwarded.
Usable by Users Bots- Parameters:
chat_id (
int|str) – Unique identifier (int) or username (str) of the target chat.html (
str) – HTML code of the widget, 1-32768 bytes. The code must not exceed 4096 bytes when compressed by zlib with the maximum compression level.width (
int, optional) – Width of the widget in logical pixels; omit if the widget must occupy the whole width of the message bubble. The width is clamped by the app to the range from 200 to the maximum width of the message bubble.height (
int, optional) – Height of the widget in logical pixels; omit if the height of the widget isn’t fixed. The height is clamped by the app to the range 50-600.public_data (
str, optional) – Public data of the widget, 0-1024 bytes, which will be available wherever the widget is shown. If the widget is shared, then all messages with it will have the same public data.chat_data (
str, optional) – Data of the widget, which is specific to the message, 0-1024 bytes.caption (
str, optional) – Widget caption, 0-1024 characters after entities parsing.parse_mode (
ParseMode, optional) – By default, texts are parsed using both Markdown and HTML styles. You can combine both syntaxes together.caption_entities (List of
MessageEntity, optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.show_caption_above_media (
bool, optional) – Pass True if the caption must be shown above the widget.allow_queries (
bool, optional) – Pass True to allow the widget to send queries to the bot.is_shared (
bool, optional) – Pass True to create a shared widget, which can be sent again usingsend_shared_widget().disable_notification (
bool, optional) – Sends the message silently. Users will receive a notification with no sound.protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) – Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.effect_id (
int, optional) – Unique identifier of the message effect to be added to the message; for private chats only.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of a forum.reply_markup (
InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply, optional) – Additional interface options.
- Returns:
Message– On success, the sent message is returned.
Example
await app.send_widget(chat_id, "<b>Hello</b>", height=120, allow_queries=True)