Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot API 8.0 - Media Sharing and File Downloads #236

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/api_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub text_parse_mode: Option<ParseMode>,
pub text_entities: Option<Vec<MessageEntity>>,
}

#[apply(apistruct!)]
pub struct AnswerInlineQueryParams {
pub inline_query_id: String,
Expand Down Expand Up @@ -1477,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<bool>,
pub allow_bot_chats: Option<bool>,
pub allow_group_chats: Option<bool>,
pub allow_channel_chats: Option<bool>,
}

#[apply(apistruct!)]
#[derive(Eq)]
pub struct SetChatMenuButtonParams {
Expand Down
30 changes: 25 additions & 5 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,20 @@ pub struct InputSticker {
pub keywords: Option<Vec<String>>,
}

#[apply(apistruct!)]
pub struct Gift {
pub id: String,
pub stricker: Sticker,
pub star_count: u32,
pub total_count: Option<u32>,
pub remaining_count: Option<u32>,
}

#[apply(apistruct!)]
pub struct Gifts {
pub gifts: Vec<Gift>,
}

#[apply(apistruct!)]
#[derive(Eq)]
pub struct Story {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -2231,23 +2252,24 @@ 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<TransactionPartnerUser>),
Fragment(TransactionPartnerFragment),
TelegramAds(TransactionPartnerTelegramAds),
TelegramApi(TransactionPartnerTelegramApi),
Other(TransactionPartnerOther),
}

#[apply(apistruct!)]
#[derive(Eq)]
pub struct TransactionPartnerUser {
pub user: User,
pub invoice_payload: Option<String>,
pub subscription_period: Option<u32>,
pub paid_media: Option<Vec<PaidMedia>>,
pub paid_media_payload: Option<String>,
pub gift: Option<Gift>,
}

#[apply(apistruct!)]
Expand All @@ -2271,7 +2293,6 @@ pub struct TransactionPartnerTelegramApi {
pub struct TransactionPartnerOther {}

#[apply(apistruct!)]
#[derive(Eq)]
pub struct StarTransaction {
pub id: String,
pub amount: u32,
Expand All @@ -2281,7 +2302,6 @@ pub struct StarTransaction {
}

#[apply(apistruct!)]
#[derive(Eq)]
pub struct StarTransactions {
pub transactions: Vec<StarTransaction>,
}
Expand Down
9 changes: 6 additions & 3 deletions src/trait_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
Expand All @@ -639,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);
Expand Down
9 changes: 6 additions & 3 deletions src/trait_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
Expand All @@ -605,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);
Expand Down
Loading