mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-27 21:25:50 +01:00
Add Message.giveaway.
This commit is contained in:
parent
6a5393a925
commit
84f74d8ad6
@ -1814,6 +1814,39 @@ class Client::JsonChatShared final : public td::Jsonable {
|
|||||||
const td_api::messageChatShared *chat_shared_;
|
const td_api::messageChatShared *chat_shared_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::JsonGiveaway final : public td::Jsonable {
|
||||||
|
public:
|
||||||
|
JsonGiveaway(const td_api::messagePremiumGiveaway *giveaway, const Client *client)
|
||||||
|
: giveaway_(giveaway), client_(client) {
|
||||||
|
}
|
||||||
|
void store(td::JsonValueScope *scope) const {
|
||||||
|
auto object = scope->enter_object();
|
||||||
|
td::vector<int64> chat_ids;
|
||||||
|
chat_ids.push_back(giveaway_->parameters_->boosted_chat_id_);
|
||||||
|
for (auto chat_id : giveaway_->parameters_->additional_chat_ids_) {
|
||||||
|
chat_ids.push_back(chat_id);
|
||||||
|
}
|
||||||
|
object("chats",
|
||||||
|
td::json_array(chat_ids, [client = client_](auto &chat_id) { return JsonChat(chat_id, false, client); }));
|
||||||
|
object("winners_selection_date", giveaway_->parameters_->winners_selection_date_);
|
||||||
|
object("winner_count", giveaway_->winner_count_);
|
||||||
|
if (giveaway_->parameters_->only_new_members_) {
|
||||||
|
object("only_new_members", td::JsonTrue());
|
||||||
|
}
|
||||||
|
if (!giveaway_->parameters_->country_codes_.empty()) {
|
||||||
|
object("country_codes", td::json_array(giveaway_->parameters_->country_codes_,
|
||||||
|
[](td::Slice country_code) { return td::JsonString(country_code); }));
|
||||||
|
}
|
||||||
|
if (giveaway_->month_count_ > 0) {
|
||||||
|
object("premium_subscription_month_count", giveaway_->month_count_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const td_api::messagePremiumGiveaway *giveaway_;
|
||||||
|
const Client *client_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::JsonWebAppInfo final : public td::Jsonable {
|
class Client::JsonWebAppInfo final : public td::Jsonable {
|
||||||
public:
|
public:
|
||||||
explicit JsonWebAppInfo(const td::string &url) : url_(url) {
|
explicit JsonWebAppInfo(const td::string &url) : url_(url) {
|
||||||
@ -2332,8 +2365,11 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const {
|
|||||||
case td_api::messagePremiumGiveawayCreated::ID:
|
case td_api::messagePremiumGiveawayCreated::ID:
|
||||||
object("giveaway_created", JsonEmptyObject());
|
object("giveaway_created", JsonEmptyObject());
|
||||||
break;
|
break;
|
||||||
case td_api::messagePremiumGiveaway::ID:
|
case td_api::messagePremiumGiveaway::ID: {
|
||||||
|
auto content = static_cast<const td_api::messagePremiumGiveaway *>(message_->content.get());
|
||||||
|
object("giveaway", JsonGiveaway(content, client_));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case td_api::messageStory::ID:
|
case td_api::messageStory::ID:
|
||||||
object("story", JsonEmptyObject());
|
object("story", JsonEmptyObject());
|
||||||
break;
|
break;
|
||||||
@ -11108,6 +11144,7 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::me
|
|||||||
case td_api::messageForumTopicIsClosedToggled::ID:
|
case td_api::messageForumTopicIsClosedToggled::ID:
|
||||||
case td_api::messageForumTopicIsHiddenToggled::ID:
|
case td_api::messageForumTopicIsHiddenToggled::ID:
|
||||||
case td_api::messagePremiumGiveawayCreated::ID:
|
case td_api::messagePremiumGiveawayCreated::ID:
|
||||||
|
case td_api::messagePremiumGiveaway::ID:
|
||||||
// don't skip
|
// don't skip
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -11218,8 +11255,6 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::me
|
|||||||
return true;
|
return true;
|
||||||
case td_api::messagePremiumGiftCode::ID:
|
case td_api::messagePremiumGiftCode::ID:
|
||||||
return true;
|
return true;
|
||||||
case td_api::messagePremiumGiveaway::ID:
|
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
class JsonWriteAccessAllowed;
|
class JsonWriteAccessAllowed;
|
||||||
class JsonUserShared;
|
class JsonUserShared;
|
||||||
class JsonChatShared;
|
class JsonChatShared;
|
||||||
|
class JsonGiveaway;
|
||||||
class JsonUpdateTypes;
|
class JsonUpdateTypes;
|
||||||
class JsonWebhookInfo;
|
class JsonWebhookInfo;
|
||||||
class JsonStickerSet;
|
class JsonStickerSet;
|
||||||
|
Loading…
Reference in New Issue
Block a user