From b087bb84fefb74e55f5b483946c4d58fd5125c63 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Sun, 1 Dec 2024 13:07:46 +0200 Subject: [PATCH] Bot API 8.0 - Gifts --- src/api_params.rs | 10 ++++++++++ src/objects.rs | 21 +++++++++++++++++---- src/trait_async.rs | 4 +++- src/trait_sync.rs | 4 +++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/api_params.rs b/src/api_params.rs index 22103fa..ce581d6 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -1230,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, diff --git a/src/objects.rs b/src/objects.rs index b262b7a..371dcac 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 { @@ -2238,7 +2252,7 @@ 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), @@ -2249,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!)] @@ -2278,7 +2293,6 @@ pub struct TransactionPartnerTelegramApi { pub struct TransactionPartnerOther {} #[apply(apistruct!)] -#[derive(Eq)] pub struct StarTransaction { pub id: String, pub amount: u32, @@ -2288,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 01d7dbe..7a819b1 100644 --- a/src/trait_async.rs +++ b/src/trait_async.rs @@ -9,7 +9,7 @@ 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, + ForumTopic, GameHighScore, Gifts, InputSticker, MenuButton, Message, MessageId, Poll, PreparedInlineMessage, SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, UserChatBoosts, UserProfilePhotos, WebhookInfo, }; @@ -626,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); diff --git a/src/trait_sync.rs b/src/trait_sync.rs index 10434fa..28e33f2 100644 --- a/src/trait_sync.rs +++ b/src/trait_sync.rs @@ -9,7 +9,7 @@ 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, + ForumTopic, GameHighScore, Gifts, InputSticker, MenuButton, Message, MessageId, Poll, PreparedInlineMessage, SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, UserChatBoosts, UserProfilePhotos, WebhookInfo, }; @@ -592,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);