Add the TBA6.7 methods for bot's name manipulation

This commit is contained in:
Сырцев Вадим Игоревич 2024-06-15 12:51:17 +03:00
parent 3ff302a36c
commit b7e2f25562
15 changed files with 151 additions and 4 deletions

View file

@ -39,7 +39,7 @@
//! [github]: https://github.com/WaffleLapkin/tg-methods-schema //! [github]: https://github.com/WaffleLapkin/tg-methods-schema
Schema( Schema(
api_version: ApiVersion(ver: "6.6", date: "March 9, 2023"), api_version: ApiVersion(ver: "6.7", date: "April 21, 2023"),
methods: [ methods: [
Method( Method(
names: ("getUpdates", "GetUpdates", "get_updates"), names: ("getUpdates", "GetUpdates", "get_updates"),
@ -2894,6 +2894,42 @@ Schema(
), ),
], ],
), ),
Method(
names: ("setMyName", "SetMyName", "set_my_name"),
return_ty: True,
doc: Doc(md: "Use this method to change the bot's name. Returns True on success."),
tg_doc: "https://core.telegram.org/bots/api#setmyname",
tg_category: "Available methods",
params: [
Param(
name: "name",
ty: Option(String),
descr: Doc(md: "New bot name; 0-64 characters. Pass an empty string to remove the dedicated name 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 name will be shown to all users for whose language there is no dedicated name.")
),
],
),
Method(
names: ("getMyName", "GetMyName", "get_my_name"),
return_ty: RawTy("BotName"),
doc: Doc(
md: "Use this method to get the current bot name for the given user language. Returns [BotName] on success.",
md_links: {"BotName": "https://core.telegram.org/bots/api#botname"},
),
tg_doc: "https://core.telegram.org/bots/api#getmyname",
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( Method(
names: ("setMyDescription", "SetMyDescription", "set_my_description"), names: ("setMyDescription", "SetMyDescription", "set_my_description"),
return_ty: True, return_ty: True,

View file

@ -159,6 +159,8 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_name,
get_my_name,
set_my_description, set_my_description,
get_my_description, get_my_description,
set_my_short_description, set_my_short_description,

View file

@ -254,6 +254,8 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_name,
get_my_name,
set_my_description, set_my_description,
get_my_description, get_my_description,
set_my_short_description, set_my_short_description,
@ -709,6 +711,10 @@ 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_name(&self) -> ErasedRequest<'a, SetMyName, Self::Err>;
fn get_my_name(&self) -> ErasedRequest<'a, GetMyName, Self::Err>;
fn set_my_description(&self) -> ErasedRequest<'a, SetMyDescription, Self::Err>; fn set_my_description(&self) -> ErasedRequest<'a, SetMyDescription, Self::Err>;
fn get_my_description(&self) -> ErasedRequest<'a, GetMyDescription, Self::Err>; fn get_my_description(&self) -> ErasedRequest<'a, GetMyDescription, Self::Err>;
@ -1512,6 +1518,14 @@ where
Requester::get_my_commands(self).erase() Requester::get_my_commands(self).erase()
} }
fn set_my_name(&self) -> ErasedRequest<'a, SetMyName, Self::Err> {
Requester::set_my_name(self).erase()
}
fn get_my_name(&self) -> ErasedRequest<'a, GetMyName, Self::Err> {
Requester::get_my_name(self).erase()
}
fn set_my_description(&self) -> ErasedRequest<'a, SetMyDescription, Self::Err> { fn set_my_description(&self) -> ErasedRequest<'a, SetMyDescription, Self::Err> {
Requester::set_my_description(self).erase() Requester::set_my_description(self).erase()
} }

View file

@ -240,6 +240,8 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_name,
get_my_name,
set_my_description, set_my_description,
get_my_description, get_my_description,
set_my_short_description, set_my_short_description,

View file

@ -142,6 +142,8 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_name,
get_my_name,
set_my_description, set_my_description,
get_my_description, get_my_description,
set_my_short_description, set_my_short_description,

View file

@ -188,6 +188,8 @@ where
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_name,
get_my_name,
set_my_description, set_my_description,
get_my_description, get_my_description,
set_my_short_description, set_my_short_description,

View file

@ -829,6 +829,18 @@ impl Requester for Bot {
Self::GetMyCommands::new(self.clone(), payloads::GetMyCommands::new()) Self::GetMyCommands::new(self.clone(), payloads::GetMyCommands::new())
} }
type SetMyName = JsonRequest<payloads::SetMyName>;
fn set_my_name(&self) -> Self::SetMyName {
Self::SetMyName::new(self.clone(), payloads::SetMyName::new())
}
type GetMyName = JsonRequest<payloads::GetMyName>;
fn get_my_name(&self) -> Self::GetMyName {
Self::GetMyName::new(self.clone(), payloads::GetMyName::new())
}
type SetMyDescription = JsonRequest<payloads::SetMyDescription>; type SetMyDescription = JsonRequest<payloads::SetMyDescription>;
fn set_my_description(&self) -> Self::SetMyDescription { fn set_my_description(&self) -> Self::SetMyDescription {

View file

@ -1033,6 +1033,22 @@ macro_rules! requester_forward {
$body!(get_my_commands this ()) $body!(get_my_commands this ())
} }
}; };
(@method set_my_name $body:ident $ty:ident) => {
type SetMyName = $ty![SetMyName];
fn set_my_name(&self, ) -> Self::SetMyName {
let this = self;
$body!(set_my_name this ())
}
};
(@method get_my_name $body:ident $ty:ident) => {
type GetMyName = $ty![GetMyName];
fn get_my_name(&self, ) -> Self::GetMyName {
let this = self;
$body!(get_my_name this ())
}
};
(@method set_my_description $body:ident $ty:ident) => { (@method set_my_description $body:ident $ty:ident) => {
type SetMyDescription = $ty![SetMyDescription]; type SetMyDescription = $ty![SetMyDescription];

View file

@ -70,6 +70,7 @@ 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_description;
mod get_my_name;
mod get_my_short_description; mod get_my_short_description;
mod get_sticker_set; mod get_sticker_set;
mod get_updates; mod get_updates;
@ -116,6 +117,7 @@ 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_description;
mod set_my_name;
mod set_my_short_description; mod set_my_short_description;
mod set_passport_data_errors; mod set_passport_data_errors;
mod set_sticker_emoji_list; mod set_sticker_emoji_list;
@ -199,6 +201,7 @@ pub use get_my_default_administrator_rights::{
GetMyDefaultAdministratorRights, GetMyDefaultAdministratorRightsSetters, GetMyDefaultAdministratorRights, GetMyDefaultAdministratorRightsSetters,
}; };
pub use get_my_description::{GetMyDescription, GetMyDescriptionSetters}; pub use get_my_description::{GetMyDescription, GetMyDescriptionSetters};
pub use get_my_name::{GetMyName, GetMyNameSetters};
pub use get_my_short_description::{GetMyShortDescription, GetMyShortDescriptionSetters}; 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};
@ -251,6 +254,7 @@ pub use set_my_default_administrator_rights::{
SetMyDefaultAdministratorRights, SetMyDefaultAdministratorRightsSetters, SetMyDefaultAdministratorRights, SetMyDefaultAdministratorRightsSetters,
}; };
pub use set_my_description::{SetMyDescription, SetMyDescriptionSetters}; pub use set_my_description::{SetMyDescription, SetMyDescriptionSetters};
pub use set_my_name::{SetMyName, SetMyNameSetters};
pub use set_my_short_description::{SetMyShortDescription, SetMyShortDescriptionSetters}; 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_emoji_list::{SetStickerEmojiList, SetStickerEmojiListSetters}; pub use set_sticker_emoji_list::{SetStickerEmojiList, SetStickerEmojiListSetters};

View file

@ -0,0 +1,18 @@
//! Generated by `codegen_payloads`, do not edit by hand.
use serde::Serialize;
use crate::types::BotName;
impl_payload! {
/// Use this method to get the current bot name for the given user language. Returns [`BotName`] on success.
///
/// [`BotName`]: crate::types::BotName
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub GetMyName (GetMyNameSetters) => BotName {
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::True;
impl_payload! {
/// Use this method to change the bot's name. Returns True on success.
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub SetMyName (SetMyNameSetters) => True {
optional {
/// New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
pub name: String [into],
/// A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
pub language_code: String [into],
}
}
}

View file

@ -23,8 +23,8 @@ pub use crate::payloads::{
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 _, GetMyDescriptionSetters as _, GetMyDefaultAdministratorRightsSetters as _, GetMyDescriptionSetters as _,
GetMyShortDescriptionSetters as _, GetStickerSetSetters as _, GetUpdatesSetters as _, GetMyNameSetters as _, GetMyShortDescriptionSetters as _, GetStickerSetSetters as _,
GetUserProfilePhotosSetters as _, GetWebhookInfoSetters as _, GetUpdatesSetters 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 _,
ReopenForumTopicSetters as _, ReopenGeneralForumTopicSetters as _, ReopenForumTopicSetters as _, ReopenGeneralForumTopicSetters as _,
@ -40,7 +40,7 @@ pub use crate::payloads::{
SetCustomEmojiStickerSetThumbnailSetters as _, SetGameScoreInlineSetters as _, SetCustomEmojiStickerSetThumbnailSetters as _, SetGameScoreInlineSetters as _,
SetGameScoreSetters as _, SetMyCommandsSetters as _, SetGameScoreSetters as _, SetMyCommandsSetters as _,
SetMyDefaultAdministratorRightsSetters as _, SetMyDescriptionSetters as _, SetMyDefaultAdministratorRightsSetters as _, SetMyDescriptionSetters as _,
SetMyShortDescriptionSetters as _, SetPassportDataErrorsSetters as _, SetMyNameSetters as _, SetMyShortDescriptionSetters as _, SetPassportDataErrorsSetters as _,
SetStickerEmojiListSetters as _, SetStickerKeywordsSetters as _, SetStickerEmojiListSetters as _, SetStickerKeywordsSetters as _,
SetStickerMaskPositionSetters as _, SetStickerPositionInSetSetters as _, SetStickerMaskPositionSetters as _, SetStickerPositionInSetSetters as _,
SetStickerSetThumbnailSetters as _, SetStickerSetTitleSetters as _, SetWebhookSetters as _, SetStickerSetThumbnailSetters as _, SetStickerSetTitleSetters as _, SetWebhookSetters as _,

View file

@ -777,6 +777,16 @@ 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 SetMyName: Request<Payload = SetMyName, Err = Self::Err>;
/// For Telegram documentation see [`SetMyName`].
fn set_my_name(&self) -> Self::SetMyName;
type GetMyName: Request<Payload = GetMyName, Err = Self::Err>;
/// For Telegram documentation see [`GetMyName`].
fn get_my_name(&self) -> Self::GetMyName;
type SetMyDescription: Request<Payload = SetMyDescription, Err = Self::Err>; type SetMyDescription: Request<Payload = SetMyDescription, Err = Self::Err>;
/// For Telegram documentation see [`SetMyDescription`]. /// For Telegram documentation see [`SetMyDescription`].
@ -1290,6 +1300,8 @@ macro_rules! forward_all {
answer_callback_query, answer_callback_query,
set_my_commands, set_my_commands,
get_my_commands, get_my_commands,
set_my_name,
get_my_name,
set_my_description, set_my_description,
get_my_description, get_my_description,
set_my_short_description, set_my_short_description,

View file

@ -6,6 +6,7 @@ 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_description::*;
pub use bot_name::*;
pub use bot_short_description::*; pub use bot_short_description::*;
pub use callback_game::*; pub use callback_game::*;
pub use callback_query::*; pub use callback_query::*;
@ -131,6 +132,7 @@ mod audio;
mod bot_command; mod bot_command;
mod bot_command_scope; mod bot_command_scope;
mod bot_description; mod bot_description;
mod bot_name;
mod bot_short_description; mod bot_short_description;
mod callback_game; mod callback_game;
mod callback_query; mod callback_query;

View file

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