From b669f6322107888e8166dbef4412e854d72651b2 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 3 Dec 2024 11:57:54 +0200 Subject: [PATCH] Bot API 8.0 - Emoji Status (#235) * Bot API 8.0 - Media Sharing and File Downloads (#236) * Bot API 8.0 - Gifts (#237) --- src/api_params.rs | 28 ++++++++++++++++++++++++++++ src/objects.rs | 30 +++++++++++++++++++++++++----- src/trait_async.rs | 10 +++++++--- src/trait_sync.rs | 10 +++++++--- 4 files changed, 67 insertions(+), 11 deletions(-) diff --git a/src/api_params.rs b/src/api_params.rs index ec0b6d2..ce581d6 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -622,6 +622,14 @@ pub struct GetUserProfilePhotosParams { pub limit: Option, } +#[apply(apistruct!)] +#[derive(Eq)] +pub struct SetUserEmojiStatusParams { + pub user_id: u64, + pub emoji_status_custom_emoji_id: Option, + pub emoji_status_expiration_date: Option, +} + #[apply(apistruct!)] #[derive(Eq)] pub struct GetFileParams { @@ -1222,6 +1230,16 @@ pub struct DeleteStickerSetParams { pub name: String, } +#[apply(apistruct!)] +#[derive(Eq)] +pub struct SendGiftParams { + pub user_id: u64, + pub gift_id: String, + pub text: Option, + pub text_parse_mode: Option, + pub text_entities: Option>, +} + #[apply(apistruct!)] pub struct AnswerInlineQueryParams { pub inline_query_id: String, @@ -1469,6 +1487,16 @@ pub struct AnswerWebAppQueryParams { pub result: InlineQueryResult, } +#[apply(apistruct!)] +pub struct SavePreparedInlineMessageParams { + pub user_id: u64, + pub result: InlineQueryResult, + pub allow_user_chats: Option, + pub allow_bot_chats: Option, + pub allow_group_chats: Option, + pub allow_channel_chats: Option, +} + #[apply(apistruct!)] #[derive(Eq)] pub struct SetChatMenuButtonParams { diff --git a/src/objects.rs b/src/objects.rs index 5b672d6..f926fc2 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -1335,6 +1335,20 @@ pub struct InputSticker { pub keywords: Option>, } +#[apply(apistruct!)] +pub struct Gift { + pub id: String, + pub stricker: Sticker, + pub star_count: u32, + pub total_count: Option, + pub remaining_count: Option, +} + +#[apply(apistruct!)] +pub struct Gifts { + pub gifts: Vec, +} + #[apply(apistruct!)] #[derive(Eq)] pub struct Story { @@ -1732,6 +1746,13 @@ pub struct ChosenInlineResult { pub query: String, } +#[apply(apistruct!)] +#[derive(Eq)] +pub struct PreparedInlineMessage { + pub id: String, + pub expiration_date: u64, +} + #[apply(apistruct!)] #[derive(Eq)] pub struct LabeledPrice { @@ -2231,10 +2252,10 @@ pub struct RevenueWithdrawalStateSucceeded { #[derive(Eq)] pub struct RevenueWithdrawalStateFailed {} -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(tag = "type", rename_all = "snake_case")] pub enum TransactionPartner { - User(TransactionPartnerUser), + User(Box), Fragment(TransactionPartnerFragment), TelegramAds(TransactionPartnerTelegramAds), TelegramApi(TransactionPartnerTelegramApi), @@ -2242,12 +2263,13 @@ pub enum TransactionPartner { } #[apply(apistruct!)] -#[derive(Eq)] pub struct TransactionPartnerUser { pub user: User, pub invoice_payload: Option, pub subscription_period: Option, pub paid_media: Option>, + pub paid_media_payload: Option, + pub gift: Option, } #[apply(apistruct!)] @@ -2271,7 +2293,6 @@ pub struct TransactionPartnerTelegramApi { pub struct TransactionPartnerOther {} #[apply(apistruct!)] -#[derive(Eq)] pub struct StarTransaction { pub id: String, pub amount: u32, @@ -2281,7 +2302,6 @@ pub struct StarTransaction { } #[apply(apistruct!)] -#[derive(Eq)] pub struct StarTransactions { pub transactions: Vec, } diff --git a/src/trait_async.rs b/src/trait_async.rs index 8804ebb..7a819b1 100644 --- a/src/trait_async.rs +++ b/src/trait_async.rs @@ -9,9 +9,9 @@ use crate::api_params::{ use crate::objects::{ BotCommand, BotDescription, BotName, BotShortDescription, BusinessConnection, ChatAdministratorRights, ChatFullInfo, ChatInviteLink, ChatMember, File as FileObject, - ForumTopic, GameHighScore, InputSticker, MenuButton, Message, MessageId, Poll, - SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, UserChatBoosts, - UserProfilePhotos, WebhookInfo, + ForumTopic, GameHighScore, Gifts, InputSticker, MenuButton, Message, MessageId, Poll, + PreparedInlineMessage, SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, + UserChatBoosts, UserProfilePhotos, WebhookInfo, }; use crate::response::{MessageOrBool, MethodResponse}; @@ -314,6 +314,7 @@ where request!(sendChatAction, bool); request!(setMessageReaction, bool); request!(getUserProfilePhotos, UserProfilePhotos); + request!(setUserEmojiStatus, bool); request!(getFile, FileObject); request!(banChatMember, bool); request!(unbanChatMember, bool); @@ -625,6 +626,8 @@ where request!(setCustomEmojiStickerSetThumbnail, bool); request!(deleteStickerSet, bool); + request_nb!(getAvailableGifts, Gifts); + request!(sendGift, bool); request!(sendInvoice, Message); request!(createInvoiceLink, String); request!(answerShippingQuery, bool); @@ -638,6 +641,7 @@ where request!(setMyDefaultAdministratorRights, bool); request!(getMyDefaultAdministratorRights, ChatAdministratorRights); request!(answerWebAppQuery, SentWebAppMessage); + request!(savePreparedInlineMessage, PreparedInlineMessage); request!(setChatMenuButton, bool); request!(getChatMenuButton, MenuButton); request!(unpinAllGeneralForumTopicMessages, bool); diff --git a/src/trait_sync.rs b/src/trait_sync.rs index dd58167..28e33f2 100644 --- a/src/trait_sync.rs +++ b/src/trait_sync.rs @@ -9,9 +9,9 @@ use crate::api_params::{ use crate::objects::{ BotCommand, BotDescription, BotName, BotShortDescription, BusinessConnection, ChatAdministratorRights, ChatFullInfo, ChatInviteLink, ChatMember, File as FileObject, - ForumTopic, GameHighScore, InputSticker, MenuButton, Message, MessageId, Poll, - SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, UserChatBoosts, - UserProfilePhotos, WebhookInfo, + ForumTopic, GameHighScore, Gifts, InputSticker, MenuButton, Message, MessageId, Poll, + PreparedInlineMessage, SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, + UserChatBoosts, UserProfilePhotos, WebhookInfo, }; use crate::response::{MessageOrBool, MethodResponse}; @@ -286,6 +286,7 @@ pub trait TelegramApi { request!(sendChatAction, bool); request!(setMessageReaction, bool); request!(getUserProfilePhotos, UserProfilePhotos); + request!(setUserEmojiStatus, bool); request!(getFile, FileObject); request!(banChatMember, bool); request!(unbanChatMember, bool); @@ -591,6 +592,8 @@ pub trait TelegramApi { request!(setCustomEmojiStickerSetThumbnail, bool); request!(deleteStickerSet, bool); + request_nb!(getAvailableGifts, Gifts); + request!(sendGift, bool); request!(sendInvoice, Message); request!(createInvoiceLink, String); request!(answerShippingQuery, bool); @@ -604,6 +607,7 @@ pub trait TelegramApi { request!(setMyDefaultAdministratorRights, bool); request!(getMyDefaultAdministratorRights, ChatAdministratorRights); request!(answerWebAppQuery, SentWebAppMessage); + request!(savePreparedInlineMessage, PreparedInlineMessage); request!(setChatMenuButton, bool); request!(getChatMenuButton, MenuButton); request!(unpinAllGeneralForumTopicMessages, bool);