Add Message.giveaway_completed.

This commit is contained in:
levlam 2023-12-04 15:23:59 +03:00 committed by David Guillen Fandos
parent 253d3acddc
commit e6e6cbc72f
2 changed files with 49 additions and 21 deletions

View File

@ -998,6 +998,24 @@ class Client::JsonChat final : public td::Jsonable {
int32 distance_; int32 distance_;
}; };
class Client::JsonDeletedMessage final : public td::Jsonable {
public:
JsonDeletedMessage(int64 chat_id, int64 message_id, const Client *client)
: chat_id_(chat_id), message_id_(message_id), client_(client) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
object("message_id", as_client_message_id(message_id_));
object("chat", JsonChat(chat_id_, client_));
object("date", 0);
}
private:
int64 chat_id_;
int64 message_id_;
const Client *client_;
};
class Client::JsonMessageSender final : public td::Jsonable { class Client::JsonMessageSender final : public td::Jsonable {
public: public:
JsonMessageSender(const td_api::MessageSender *sender_id, const Client *client) JsonMessageSender(const td_api::MessageSender *sender_id, const Client *client)
@ -2039,6 +2057,31 @@ class Client::JsonGiveaway final : public td::Jsonable {
const Client *client_; const Client *client_;
}; };
class Client::JsonGiveawayCompleted final : public td::Jsonable {
public:
JsonGiveawayCompleted(const td_api::messagePremiumGiveawayCompleted *giveaway_completed, int64 chat_id,
const Client *client)
: giveaway_completed_(giveaway_completed), chat_id_(chat_id), client_(client) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
object("winner_count", giveaway_completed_->winner_count_);
if (giveaway_completed_->unclaimed_prize_count_ > 0) {
object("unclaimed_prize_count", giveaway_completed_->unclaimed_prize_count_);
}
const MessageInfo *giveaway_message =
client_->get_message(chat_id_, giveaway_completed_->giveaway_message_id_, true);
if (giveaway_message != nullptr) {
object("giveaway_message", JsonMessage(giveaway_message, true, "giveaway completed", client_));
}
}
private:
const td_api::messagePremiumGiveawayCompleted *giveaway_completed_;
int64 chat_id_;
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) {
@ -2756,8 +2799,11 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const {
object("giveaway", JsonGiveaway(content, client_)); object("giveaway", JsonGiveaway(content, client_));
break; break;
} }
case td_api::messagePremiumGiveawayCompleted::ID: case td_api::messagePremiumGiveawayCompleted::ID: {
auto content = static_cast<const td_api::messagePremiumGiveawayCompleted *>(message_->content.get());
object("giveaway_completed", JsonGiveawayCompleted(content, message_->chat_id, client_));
break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }
@ -2775,24 +2821,6 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const {
} }
} }
class Client::JsonDeletedMessage final : public td::Jsonable {
public:
JsonDeletedMessage(int64 chat_id, int64 message_id, const Client *client)
: chat_id_(chat_id), message_id_(message_id), client_(client) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
object("message_id", as_client_message_id(message_id_));
object("chat", JsonChat(chat_id_, client_));
object("date", 0);
}
private:
int64 chat_id_;
int64 message_id_;
const Client *client_;
};
class Client::JsonMessageId final : public td::Jsonable { class Client::JsonMessageId final : public td::Jsonable {
public: public:
explicit JsonMessageId(int64 message_id) : message_id_(message_id) { explicit JsonMessageId(int64 message_id) : message_id_(message_id) {
@ -13047,6 +13075,7 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::me
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: case td_api::messagePremiumGiveaway::ID:
case td_api::messagePremiumGiveawayCompleted::ID:
// don't skip // don't skip
break; break;
default: default:
@ -13157,8 +13186,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::messagePremiumGiveawayCompleted::ID:
return true;
default: default:
break; break;
} }

View File

@ -188,6 +188,7 @@ class Client final : public WebhookActor::Callback {
class JsonUserShared; class JsonUserShared;
class JsonChatShared; class JsonChatShared;
class JsonGiveaway; class JsonGiveaway;
class JsonGiveawayCompleted;
class JsonUpdateTypes; class JsonUpdateTypes;
class JsonWebhookInfo; class JsonWebhookInfo;
class JsonStickerSet; class JsonStickerSet;