Allow bots to switch to inline mode in a chosen chat of the given type

This commit is contained in:
Сырцев Вадим Игоревич 2024-06-15 15:05:20 +03:00
parent 23aafb6821
commit 266dd11ec1
3 changed files with 34 additions and 1 deletions

View file

@ -106,6 +106,7 @@ pub use shipping_query::*;
pub use sticker::*; pub use sticker::*;
pub use sticker_set::*; pub use sticker_set::*;
pub use successful_payment::*; pub use successful_payment::*;
pub use switch_inline_query_chosen_chat::*;
pub use target_message::*; pub use target_message::*;
pub use thread_id::*; pub use thread_id::*;
pub use unit_false::*; pub use unit_false::*;
@ -206,6 +207,7 @@ mod shipping_query;
mod sticker; mod sticker;
mod sticker_set; mod sticker_set;
mod successful_payment; mod successful_payment;
mod switch_inline_query_chosen_chat;
mod target_message; mod target_message;
mod thread_id; mod thread_id;
mod unit_false; mod unit_false;

View file

@ -1,4 +1,4 @@
use crate::types::{CallbackGame, LoginUrl, True, WebAppInfo}; use crate::types::{CallbackGame, LoginUrl, SwitchInlineQueryChosenChat, True, WebAppInfo};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// This object represents one button of an inline keyboard. /// This object represents one button of an inline keyboard.
@ -71,6 +71,11 @@ pub enum InlineKeyboardButtonKind {
/// the same chat good for selecting something from multiple options. /// the same chat good for selecting something from multiple options.
SwitchInlineQueryCurrentChat(String), SwitchInlineQueryCurrentChat(String),
/// If set, pressing the button will prompt the user to select one of their
/// chats of the specified type, open that chat and insert the bot's
/// username and the specified inline query in the input field
SwitchInlineQueryChosenChat(SwitchInlineQueryChosenChat),
/// Description of the game that will be launched when the user presses the /// Description of the game that will be launched when the user presses the
/// button. /// button.
/// ///

View file

@ -0,0 +1,26 @@
use serde::{Deserialize, Serialize};
/// This object represents an inline button that switches the current user to
/// inline mode in a chosen chat, with an optional default inline query.
///
/// [The official docs](https://core.telegram.org/bots/api#switchinlinequerychosenchat)
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct SwitchInlineQueryChosenChat {
/// The default inline query to be inserted in the input field. If left
/// empty, only the bot's username will be inserted
pub query: Option<String>,
/// True, if private chats with users can be chosen
#[serde(default)]
pub allow_user_chats: bool,
/// True, if private chats with bots can be chosen
#[serde(default)]
pub allow_bot_chats: bool,
/// True, if group and supergroup chats can be chosen
#[serde(default)]
pub allow_group_chats: bool,
/// True, if channel chats can be chosen
#[serde(default)]
pub allow_channel_chats: bool,
}