diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 40f4c9f1f..e974e050e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3529,7 +3529,8 @@ messagePremiumGiveawayWinners boosted_chat_id:int53 giveaway_message_id:int53 ad //@cryptocurrency_amount The paid amount, in the smallest units of the cryptocurrency; 0 if none //@star_count Number of Telegram Stars that were gifted //@transaction_id Identifier of the transaction for Telegram Stars purchase; for receiver only -messageGiftedStars gifter_user_id:int53 receiver_user_id:int53 currency:string amount:int53 cryptocurrency:string cryptocurrency_amount:int64 star_count:int53 transaction_id:string = MessageContent; +//@sticker A sticker to be shown in the message; may be null if unknown +messageGiftedStars gifter_user_id:int53 receiver_user_id:int53 currency:string amount:int53 cryptocurrency:string cryptocurrency_amount:int64 star_count:int53 transaction_id:string sticker:sticker = MessageContent; //@description A contact has registered with Telegram messageContactRegistered = MessageContent; diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 2f41464b2..c1654a11a 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -5798,6 +5798,10 @@ static bool need_register_message_content_for_bots(MessageContentType content_ty return content_type == MessageContentType::Poll; } +static int32 get_months_by_star_count(int64 star_count) { + return star_count <= 1000 ? 3 : (star_count < 2500 ? 6 : 12); +} + void register_message_content(Td *td, const MessageContent *content, MessageFullId message_full_id, const char *source) { auto content_type = content->get_type(); @@ -5843,6 +5847,11 @@ void register_message_content(Td *td, const MessageContent *content, MessageFull case MessageContentType::Story: return td->story_manager_->register_story(static_cast(content)->story_full_id, message_full_id, {}, source); + case MessageContentType::GiftStars: { + auto star_count = static_cast(content)->star_count; + return td->stickers_manager_->register_premium_gift(get_months_by_star_count(star_count), message_full_id, + source); + } default: return; } @@ -5917,6 +5926,12 @@ void reregister_message_content(Td *td, const MessageContent *old_content, const return; } break; + case MessageContentType::GiftStars: + if (static_cast(old_content)->star_count == + static_cast(new_content)->star_count) { + return; + } + break; default: return; } @@ -5967,6 +5982,11 @@ void unregister_message_content(Td *td, const MessageContent *content, MessageFu case MessageContentType::Story: return td->story_manager_->unregister_story(static_cast(content)->story_full_id, message_full_id, {}, source); + case MessageContentType::GiftStars: { + auto star_count = static_cast(content)->star_count; + return td->stickers_manager_->unregister_premium_gift(get_months_by_star_count(star_count), message_full_id, + source); + } default: return; } @@ -7941,9 +7961,10 @@ tl_object_ptr get_message_content_object(const MessageCo } else { LOG(ERROR) << "Receive gifted stars in " << dialog_id; } - return td_api::make_object(gifter_user_id, receiver_user_id, m->currency, m->amount, - m->crypto_currency, m->crypto_amount, m->star_count, - m->transaction_id); + return td_api::make_object( + gifter_user_id, receiver_user_id, m->currency, m->amount, m->crypto_currency, m->crypto_amount, m->star_count, + m->transaction_id, + td->stickers_manager_->get_premium_gift_sticker_object(get_months_by_star_count(m->star_count))); } default: UNREACHABLE();