From 973e1d2bcef2103914f9bedd5f93067de9c15ba7 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Sun, 1 Dec 2024 12:23:36 +0200 Subject: [PATCH 1/4] Bot API 8.0 - Media Sharing and File Downloads --- src/api_params.rs | 10 ++++++++++ src/objects.rs | 6 ++++++ src/trait_async.rs | 5 +++-- src/trait_sync.rs | 5 +++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/api_params.rs b/src/api_params.rs index 5d078b0..d63fab4 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -1477,6 +1477,16 @@ pub struct AnswerWebAppQueryParams { pub result: InlineQueryResult, } +#[apply(apistruct!)] +pub struct SavePreparedInlineMessage { + 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..910ef0f 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -1732,6 +1732,12 @@ pub struct ChosenInlineResult { pub query: String, } +#[apply(apistruct!)] +pub struct PreparedInlineMessage { + pub id: String, + pub expiration_date: u64, +} + #[apply(apistruct!)] #[derive(Eq)] pub struct LabeledPrice { diff --git a/src/trait_async.rs b/src/trait_async.rs index b0708fc..01d7dbe 100644 --- a/src/trait_async.rs +++ b/src/trait_async.rs @@ -10,8 +10,8 @@ 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, + PreparedInlineMessage, SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, + UserChatBoosts, UserProfilePhotos, WebhookInfo, }; use crate::response::{MessageOrBool, MethodResponse}; @@ -639,6 +639,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 c8d6430..10434fa 100644 --- a/src/trait_sync.rs +++ b/src/trait_sync.rs @@ -10,8 +10,8 @@ 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, + PreparedInlineMessage, SentWebAppMessage, StarTransactions, Sticker, StickerSet, Update, User, + UserChatBoosts, UserProfilePhotos, WebhookInfo, }; use crate::response::{MessageOrBool, MethodResponse}; @@ -605,6 +605,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); From 44053d80d296955161d990426931c196daa1895c Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Sun, 1 Dec 2024 12:47:03 +0200 Subject: [PATCH 2/4] fix params --- src/api_params.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api_params.rs b/src/api_params.rs index d63fab4..22103fa 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -1478,7 +1478,7 @@ pub struct AnswerWebAppQueryParams { } #[apply(apistruct!)] -pub struct SavePreparedInlineMessage { +pub struct SavePreparedInlineMessageParams { pub user_id: u64, pub result: InlineQueryResult, pub allow_user_chats: Option, From f8c8dffa23080a6f465b2fa594d4ea4dab9185a7 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Sun, 1 Dec 2024 12:51:01 +0200 Subject: [PATCH 3/4] fix clippy --- src/objects.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/objects.rs b/src/objects.rs index 910ef0f..b262b7a 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -1733,6 +1733,7 @@ pub struct ChosenInlineResult { } #[apply(apistruct!)] +#[derive(Eq)] pub struct PreparedInlineMessage { pub id: String, pub expiration_date: u64, From 9bded7bb0209d2fc561b290f71abb7329fe230bf Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 3 Dec 2024 11:57:04 +0200 Subject: [PATCH 4/4] Bot API 8.0 - Gifts (#237) * Bot API 8.0 - Gifts * fix clippy --- src/api_params.rs | 10 ++++++++++ src/objects.rs | 23 ++++++++++++++++++----- src/trait_async.rs | 4 +++- src/trait_sync.rs | 4 +++- 4 files changed, 34 insertions(+), 7 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..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 { @@ -2238,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), @@ -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);