Add TBA 6.6 methods & types for bot's description manipulation

This commit is contained in:
Сырцев Вадим Игоревич 2024-04-04 12:44:20 +03:00
parent ed07753877
commit 6f7cdd9702
18 changed files with 295 additions and 3 deletions

View file

@ -40,7 +40,7 @@
//! [github]: https://github.com/WaffleLapkin/tg-methods-schema //! [github]: https://github.com/WaffleLapkin/tg-methods-schema
Schema( Schema(
api_version: ApiVersion(ver: "6.1", date: "June 20, 2022"), api_version: ApiVersion(ver: "6.6", date: "March 9, 2023"),
methods: [ methods: [
Method( Method(
names: ("getUpdates", "GetUpdates", "get_updates"), names: ("getUpdates", "GetUpdates", "get_updates"),
@ -2895,6 +2895,77 @@ Schema(
), ),
], ],
), ),
Method(
names: ("setMyDescription", "SetMyDescription", "set_my_description"),
return_ty: True,
doc: Doc(md: "Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#setmydescription",
tg_category: "Available methods",
params: [
Param(
name: "description",
ty: Option(String),
descr: Doc(md: "New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.")
),
Param(
name: "language_code",
ty: Option(String),
descr: Doc(md: "A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.")
)
]
),
Method(
names: ("getMyDescription", "GetMyDescription", "get_my_description"),
return_ty: RawTy("BotDescription"),
doc: Doc(md: "Use this method to get the current bot description for the given user language. Returns BotDescription on success."),
tg_doc: "https://core.telegram.org/bots/api#getmydescription",
tg_category: "Available methods",
params: [
Param(
name: "language_code",
ty: Option(String),
descr: Doc(md: "A two-letter ISO 639-1 language code or an empty string")
)
]
),
Method(
names: ("setMyShortDescription", "SetMyShortDescription", "set_my_short_description"),
return_ty: True,
doc: Doc(md: "Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#setmyshortdescription",
tg_category: "Available methods",
params: [
Param(
name: "short_description",
ty: Option(String),
descr: Doc(md: "New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.")
),
Param(
name: "language_code",
ty: Option(String),
descr: Doc(md: "A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.")
),
]
),
Method(
names: ("getMyShortDescription", "GetMyShortDescription", "get_my_short_description"),
return_ty: RawTy("BotShortDescription"),
doc: Doc(md: "Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#setmyshortdescription",
tg_category: "Available methods",
params: [
Param(
name: "short_description",
ty: Option(String),
descr: Doc(md: "New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.")
),
Param(
name: "language_code",
ty: Option(String),
descr: Doc(md: "A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.")
),
]
),
Method( Method(
names: ("setChatMenuButton", "SetChatMenuButton", "set_chat_menu_button"), names: ("setChatMenuButton", "SetChatMenuButton", "set_chat_menu_button"),
return_ty: True, return_ty: True,

View file

@ -159,6 +159,10 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_description,
get_my_description,
set_my_short_description,
get_my_short_description,
set_chat_menu_button, set_chat_menu_button,
get_chat_menu_button, get_chat_menu_button,
set_my_default_administrator_rights, set_my_default_administrator_rights,

View file

@ -248,6 +248,10 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_description,
get_my_description,
set_my_short_description,
get_my_short_description,
set_chat_menu_button, set_chat_menu_button,
get_chat_menu_button, get_chat_menu_button,
set_my_default_administrator_rights, set_my_default_administrator_rights,
@ -693,6 +697,14 @@ trait ErasableRequester<'a> {
fn get_my_commands(&self) -> ErasedRequest<'a, GetMyCommands, Self::Err>; fn get_my_commands(&self) -> ErasedRequest<'a, GetMyCommands, Self::Err>;
fn set_my_description(&self) -> ErasedRequest<'a, SetMyDescription, Self::Err>;
fn get_my_description(&self) -> ErasedRequest<'a, GetMyDescription, Self::Err>;
fn set_my_short_description(&self) -> ErasedRequest<'a, SetMyShortDescription, Self::Err>;
fn get_my_short_description(&self) -> ErasedRequest<'a, GetMyShortDescription, Self::Err>;
fn set_chat_menu_button(&self) -> ErasedRequest<'a, SetChatMenuButton, Self::Err>; fn set_chat_menu_button(&self) -> ErasedRequest<'a, SetChatMenuButton, Self::Err>;
fn get_chat_menu_button(&self) -> ErasedRequest<'a, GetChatMenuButton, Self::Err>; fn get_chat_menu_button(&self) -> ErasedRequest<'a, GetChatMenuButton, Self::Err>;
@ -1459,6 +1471,22 @@ where
Requester::get_my_commands(self).erase() Requester::get_my_commands(self).erase()
} }
fn set_my_description(&self) -> ErasedRequest<'a, SetMyDescription, Self::Err> {
Requester::set_my_description(self).erase()
}
fn get_my_description(&self) -> ErasedRequest<'a, GetMyDescription, Self::Err> {
Requester::get_my_description(self).erase()
}
fn set_my_short_description(&self) -> ErasedRequest<'a, SetMyShortDescription, Self::Err> {
Requester::set_my_short_description(self).erase()
}
fn get_my_short_description(&self) -> ErasedRequest<'a, GetMyShortDescription, Self::Err> {
Requester::get_my_short_description(self).erase()
}
fn set_chat_menu_button(&self) -> ErasedRequest<'a, SetChatMenuButton, Self::Err> { fn set_chat_menu_button(&self) -> ErasedRequest<'a, SetChatMenuButton, Self::Err> {
Requester::set_chat_menu_button(self).erase() Requester::set_chat_menu_button(self).erase()
} }

View file

@ -240,6 +240,10 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_description,
get_my_description,
set_my_short_description,
get_my_short_description,
set_chat_menu_button, set_chat_menu_button,
get_chat_menu_button, get_chat_menu_button,
set_my_default_administrator_rights, set_my_default_administrator_rights,

View file

@ -142,6 +142,10 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_description,
get_my_description,
set_my_short_description,
get_my_short_description,
set_chat_menu_button, set_chat_menu_button,
get_chat_menu_button, get_chat_menu_button,
set_my_default_administrator_rights, set_my_default_administrator_rights,

View file

@ -188,6 +188,10 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_description,
get_my_description,
set_my_short_description,
get_my_short_description,
set_chat_menu_button, set_chat_menu_button,
get_chat_menu_button, get_chat_menu_button,
set_my_default_administrator_rights, set_my_default_administrator_rights,

View file

@ -829,6 +829,29 @@ impl Requester for Bot {
Self::GetMyCommands::new(self.clone(), payloads::GetMyCommands::new()) Self::GetMyCommands::new(self.clone(), payloads::GetMyCommands::new())
} }
type SetMyDescription = JsonRequest<payloads::SetMyDescription>;
fn set_my_description(&self) -> Self::SetMyDescription {
Self::SetMyDescription::new(self.clone(), payloads::SetMyDescription::new())
}
type GetMyDescription = JsonRequest<payloads::GetMyDescription>;
fn get_my_description(&self) -> Self::GetMyDescription {
Self::GetMyDescription::new(self.clone(), payloads::GetMyDescription::new())
}
type SetMyShortDescription = JsonRequest<payloads::SetMyShortDescription>;
fn set_my_short_description(&self) -> Self::SetMyShortDescription {
Self::SetMyShortDescription::new(self.clone(), payloads::SetMyShortDescription::new())
}
type GetMyShortDescription = JsonRequest<payloads::GetMyShortDescription>;
fn get_my_short_description(&self) -> Self::GetMyShortDescription {
Self::GetMyShortDescription::new(self.clone(), payloads::GetMyShortDescription::new())
}
type SetChatMenuButton = JsonRequest<payloads::SetChatMenuButton>; type SetChatMenuButton = JsonRequest<payloads::SetChatMenuButton>;
fn set_chat_menu_button(&self) -> Self::SetChatMenuButton { fn set_chat_menu_button(&self) -> Self::SetChatMenuButton {

View file

@ -1033,6 +1033,38 @@ macro_rules! requester_forward {
$body!(get_my_commands this ()) $body!(get_my_commands this ())
} }
}; };
(@method set_my_description $body:ident $ty:ident) => {
type SetMyDescription = $ty![SetMyDescription];
fn set_my_description(&self, ) -> Self::SetMyDescription {
let this = self;
$body!(set_my_description this ())
}
};
(@method get_my_description $body:ident $ty:ident) => {
type GetMyDescription = $ty![GetMyDescription];
fn get_my_description(&self, ) -> Self::GetMyDescription {
let this = self;
$body!(get_my_description this ())
}
};
(@method set_my_short_description $body:ident $ty:ident) => {
type SetMyShortDescription = $ty![SetMyShortDescription];
fn set_my_short_description(&self, ) -> Self::SetMyShortDescription {
let this = self;
$body!(set_my_short_description this ())
}
};
(@method get_my_short_description $body:ident $ty:ident) => {
type GetMyShortDescription = $ty![GetMyShortDescription];
fn get_my_short_description(&self, ) -> Self::GetMyShortDescription {
let this = self;
$body!(get_my_short_description this ())
}
};
(@method set_chat_menu_button $body:ident $ty:ident) => { (@method set_chat_menu_button $body:ident $ty:ident) => {
type SetChatMenuButton = $ty![SetChatMenuButton]; type SetChatMenuButton = $ty![SetChatMenuButton];

View file

@ -68,6 +68,8 @@ mod get_game_high_scores;
mod get_me; mod get_me;
mod get_my_commands; mod get_my_commands;
mod get_my_default_administrator_rights; mod get_my_default_administrator_rights;
mod get_my_description;
mod get_my_short_description;
mod get_sticker_set; mod get_sticker_set;
mod get_updates; mod get_updates;
mod get_user_profile_photos; mod get_user_profile_photos;
@ -111,6 +113,8 @@ mod set_game_score;
mod set_game_score_inline; mod set_game_score_inline;
mod set_my_commands; mod set_my_commands;
mod set_my_default_administrator_rights; mod set_my_default_administrator_rights;
mod set_my_description;
mod set_my_short_description;
mod set_passport_data_errors; mod set_passport_data_errors;
mod set_sticker_position_in_set; mod set_sticker_position_in_set;
mod set_sticker_set_thumb; mod set_sticker_set_thumb;
@ -187,6 +191,8 @@ pub use get_my_commands::{GetMyCommands, GetMyCommandsSetters};
pub use get_my_default_administrator_rights::{ pub use get_my_default_administrator_rights::{
GetMyDefaultAdministratorRights, GetMyDefaultAdministratorRightsSetters, GetMyDefaultAdministratorRights, GetMyDefaultAdministratorRightsSetters,
}; };
pub use get_my_description::{GetMyDescription, GetMyDescriptionSetters};
pub use get_my_short_description::{GetMyShortDescription, GetMyShortDescriptionSetters};
pub use get_sticker_set::{GetStickerSet, GetStickerSetSetters}; pub use get_sticker_set::{GetStickerSet, GetStickerSetSetters};
pub use get_updates::{GetUpdates, GetUpdatesSetters}; pub use get_updates::{GetUpdates, GetUpdatesSetters};
pub use get_user_profile_photos::{GetUserProfilePhotos, GetUserProfilePhotosSetters}; pub use get_user_profile_photos::{GetUserProfilePhotos, GetUserProfilePhotosSetters};
@ -234,6 +240,8 @@ pub use set_my_commands::{SetMyCommands, SetMyCommandsSetters};
pub use set_my_default_administrator_rights::{ pub use set_my_default_administrator_rights::{
SetMyDefaultAdministratorRights, SetMyDefaultAdministratorRightsSetters, SetMyDefaultAdministratorRights, SetMyDefaultAdministratorRightsSetters,
}; };
pub use set_my_description::{SetMyDescription, SetMyDescriptionSetters};
pub use set_my_short_description::{SetMyShortDescription, SetMyShortDescriptionSetters};
pub use set_passport_data_errors::{SetPassportDataErrors, SetPassportDataErrorsSetters}; pub use set_passport_data_errors::{SetPassportDataErrors, SetPassportDataErrorsSetters};
pub use set_sticker_position_in_set::{SetStickerPositionInSet, SetStickerPositionInSetSetters}; pub use set_sticker_position_in_set::{SetStickerPositionInSet, SetStickerPositionInSetSetters};
pub use set_sticker_set_thumb::{SetStickerSetThumb, SetStickerSetThumbSetters}; pub use set_sticker_set_thumb::{SetStickerSetThumb, SetStickerSetThumbSetters};

View file

@ -0,0 +1,16 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::BotDescription;
impl_payload! {
/// Use this method to get the current bot description for the given user language. Returns BotDescription on success.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub GetMyDescription (GetMyDescriptionSetters) => BotDescription {
optional {
/// A two-letter ISO 639-1 language code or an empty string
pub language_code: String [into],
}
}
}

View file

@ -0,0 +1,18 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::BotShortDescription;
impl_payload! {
/// Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub GetMyShortDescription (GetMyShortDescriptionSetters) => BotShortDescription {
optional {
/// New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
pub short_description: String [into],
/// A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.
pub language_code: String [into],
}
}
}

View file

@ -0,0 +1,18 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::True;
impl_payload! {
/// Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub SetMyDescription (SetMyDescriptionSetters) => True {
optional {
/// New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
pub description: String [into],
/// A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
pub language_code: String [into],
}
}
}

View file

@ -0,0 +1,18 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::True;
impl_payload! {
/// Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub SetMyShortDescription (SetMyShortDescriptionSetters) => True {
optional {
/// New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
pub short_description: String [into],
/// A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.
pub language_code: String [into],
}
}
}

View file

@ -22,7 +22,8 @@ pub use crate::payloads::{
GetChatMembersCountSetters as _, GetChatMenuButtonSetters as _, GetChatSetters as _, GetChatMembersCountSetters as _, GetChatMenuButtonSetters as _, GetChatSetters as _,
GetCustomEmojiStickersSetters as _, GetFileSetters as _, GetForumTopicIconStickersSetters as _, GetCustomEmojiStickersSetters as _, GetFileSetters as _, GetForumTopicIconStickersSetters as _,
GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _, GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _,
GetMyDefaultAdministratorRightsSetters as _, GetStickerSetSetters as _, GetUpdatesSetters as _, GetMyDefaultAdministratorRightsSetters as _, GetMyDescriptionSetters as _,
GetMyShortDescriptionSetters as _, GetStickerSetSetters as _, GetUpdatesSetters as _,
GetUserProfilePhotosSetters as _, GetWebhookInfoSetters as _, GetUserProfilePhotosSetters as _, GetWebhookInfoSetters as _,
HideGeneralForumTopicSetters as _, KickChatMemberSetters as _, LeaveChatSetters as _, HideGeneralForumTopicSetters as _, KickChatMemberSetters as _, LeaveChatSetters as _,
LogOutSetters as _, PinChatMessageSetters as _, PromoteChatMemberSetters as _, LogOutSetters as _, PinChatMessageSetters as _, PromoteChatMemberSetters as _,
@ -37,7 +38,8 @@ pub use crate::payloads::{
SetChatMenuButtonSetters as _, SetChatPermissionsSetters as _, SetChatPhotoSetters as _, SetChatMenuButtonSetters as _, SetChatPermissionsSetters as _, SetChatPhotoSetters as _,
SetChatStickerSetSetters as _, SetChatTitleSetters as _, SetGameScoreInlineSetters as _, SetChatStickerSetSetters as _, SetChatTitleSetters as _, SetGameScoreInlineSetters as _,
SetGameScoreSetters as _, SetMyCommandsSetters as _, SetGameScoreSetters as _, SetMyCommandsSetters as _,
SetMyDefaultAdministratorRightsSetters as _, SetPassportDataErrorsSetters as _, SetMyDefaultAdministratorRightsSetters as _, SetMyDescriptionSetters as _,
SetMyShortDescriptionSetters as _, SetPassportDataErrorsSetters as _,
SetStickerPositionInSetSetters as _, SetStickerSetThumbSetters as _, SetWebhookSetters as _, SetStickerPositionInSetSetters as _, SetStickerSetThumbSetters as _, SetWebhookSetters as _,
StopMessageLiveLocationInlineSetters as _, StopMessageLiveLocationSetters as _, StopMessageLiveLocationInlineSetters as _, StopMessageLiveLocationSetters as _,
StopPollSetters as _, UnbanChatMemberSetters as _, UnbanChatSenderChatSetters as _, StopPollSetters as _, UnbanChatMemberSetters as _, UnbanChatSenderChatSetters as _,

View file

@ -777,6 +777,26 @@ pub trait Requester {
/// For Telegram documentation see [`GetMyCommands`]. /// For Telegram documentation see [`GetMyCommands`].
fn get_my_commands(&self) -> Self::GetMyCommands; fn get_my_commands(&self) -> Self::GetMyCommands;
type SetMyDescription: Request<Payload = SetMyDescription, Err = Self::Err>;
/// For Telegram documentation see [`SetMyDescription`].
fn set_my_description(&self) -> Self::SetMyDescription;
type GetMyDescription: Request<Payload = GetMyDescription, Err = Self::Err>;
/// For Telegram documentation see [`GetMyDescription`].
fn get_my_description(&self) -> Self::GetMyDescription;
type SetMyShortDescription: Request<Payload = SetMyShortDescription, Err = Self::Err>;
/// For Telegram documentation see [`SetMyShortDescription`].
fn set_my_short_description(&self) -> Self::SetMyShortDescription;
type GetMyShortDescription: Request<Payload = GetMyShortDescription, Err = Self::Err>;
/// For Telegram documentation see [`GetMyShortDescription`].
fn get_my_short_description(&self) -> Self::GetMyShortDescription;
type SetChatMenuButton: Request<Payload = SetChatMenuButton, Err = Self::Err>; type SetChatMenuButton: Request<Payload = SetChatMenuButton, Err = Self::Err>;
/// For Telegram documentation see [`SetChatMenuButton`]. /// For Telegram documentation see [`SetChatMenuButton`].
@ -1217,6 +1237,10 @@ macro_rules! forward_all {
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_description,
get_my_description,
set_my_short_description,
get_my_short_description,
set_chat_menu_button, set_chat_menu_button,
get_chat_menu_button, get_chat_menu_button,
set_my_default_administrator_rights, set_my_default_administrator_rights,

View file

@ -5,6 +5,8 @@ pub use animation::*;
pub use audio::*; pub use audio::*;
pub use bot_command::*; pub use bot_command::*;
pub use bot_command_scope::*; pub use bot_command_scope::*;
pub use bot_description::*;
pub use bot_short_description::*;
pub use callback_game::*; pub use callback_game::*;
pub use callback_query::*; pub use callback_query::*;
pub use chat::*; pub use chat::*;
@ -128,6 +130,8 @@ mod animation;
mod audio; mod audio;
mod bot_command; mod bot_command;
mod bot_command_scope; mod bot_command_scope;
mod bot_description;
mod bot_short_description;
mod callback_game; mod callback_game;
mod callback_query; mod callback_query;
mod chat; mod chat;

View file

@ -0,0 +1,7 @@
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BotDescription {
/// The bot's description
pub description: String,
}

View file

@ -0,0 +1,7 @@
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BotShortDescription {
/// The bot's short description
pub short_description: String,
}