mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-29 13:45:49 +01:00
Add "message_reaction_count" update.
This commit is contained in:
parent
668ea399eb
commit
50bb07bc46
@ -680,6 +680,20 @@ class Client::JsonReactionType final : public td::Jsonable {
|
|||||||
const td_api::ReactionType *reaction_type_;
|
const td_api::ReactionType *reaction_type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::JsonReactionCount final : public td::Jsonable {
|
||||||
|
public:
|
||||||
|
explicit JsonReactionCount(const td_api::messageReaction *message_reaction) : message_reaction_(message_reaction) {
|
||||||
|
}
|
||||||
|
void store(td::JsonValueScope *scope) const {
|
||||||
|
auto object = scope->enter_object();
|
||||||
|
object("type", JsonReactionType(message_reaction_->type_.get()));
|
||||||
|
object("total_count", message_reaction_->total_count_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const td_api::messageReaction *message_reaction_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::JsonChatPermissions final : public td::Jsonable {
|
class Client::JsonChatPermissions final : public td::Jsonable {
|
||||||
public:
|
public:
|
||||||
explicit JsonChatPermissions(const td_api::chatPermissions *chat_permissions) : chat_permissions_(chat_permissions) {
|
explicit JsonChatPermissions(const td_api::chatPermissions *chat_permissions) : chat_permissions_(chat_permissions) {
|
||||||
@ -3606,6 +3620,25 @@ class Client::JsonMessageReactionUpdated final : public td::Jsonable {
|
|||||||
const Client *client_;
|
const Client *client_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Client::JsonMessageReactionCountUpdated final : public td::Jsonable {
|
||||||
|
public:
|
||||||
|
JsonMessageReactionCountUpdated(const td_api::updateMessageReactions *update, const Client *client)
|
||||||
|
: update_(update), client_(client) {
|
||||||
|
}
|
||||||
|
void store(td::JsonValueScope *scope) const {
|
||||||
|
auto object = scope->enter_object();
|
||||||
|
object("chat", JsonChat(update_->chat_id_, client_));
|
||||||
|
object("message_id", as_client_message_id(update_->message_id_));
|
||||||
|
object("date", update_->date_);
|
||||||
|
object("reactions",
|
||||||
|
td::json_array(update_->reactions_, [](const auto &reaction) { return JsonReactionCount(reaction.get()); }));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const td_api::updateMessageReactions *update_;
|
||||||
|
const Client *client_;
|
||||||
|
};
|
||||||
|
|
||||||
class Client::JsonUpdateTypes final : public td::Jsonable {
|
class Client::JsonUpdateTypes final : public td::Jsonable {
|
||||||
public:
|
public:
|
||||||
explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) {
|
explicit JsonUpdateTypes(td::uint32 update_types) : update_types_(update_types) {
|
||||||
@ -6875,6 +6908,9 @@ void Client::on_update(object_ptr<td_api::Object> result) {
|
|||||||
case td_api::updateMessageReaction::ID:
|
case td_api::updateMessageReaction::ID:
|
||||||
add_update_message_reaction(move_object_as<td_api::updateMessageReaction>(result));
|
add_update_message_reaction(move_object_as<td_api::updateMessageReaction>(result));
|
||||||
break;
|
break;
|
||||||
|
case td_api::updateMessageReactions::ID:
|
||||||
|
add_update_message_reaction_count(move_object_as<td_api::updateMessageReactions>(result));
|
||||||
|
break;
|
||||||
case td_api::updateConnectionState::ID: {
|
case td_api::updateConnectionState::ID: {
|
||||||
auto update = move_object_as<td_api::updateConnectionState>(result);
|
auto update = move_object_as<td_api::updateConnectionState>(result);
|
||||||
if (update->state_->get_id() == td_api::connectionStateReady::ID) {
|
if (update->state_->get_id() == td_api::connectionStateReady::ID) {
|
||||||
@ -13114,6 +13150,8 @@ td::Slice Client::get_update_type_name(UpdateType update_type) {
|
|||||||
return td::Slice("removed_chat_boost");
|
return td::Slice("removed_chat_boost");
|
||||||
case UpdateType::MessageReaction:
|
case UpdateType::MessageReaction:
|
||||||
return td::Slice("message_reaction");
|
return td::Slice("message_reaction");
|
||||||
|
case UpdateType::MessageReactionCount:
|
||||||
|
return td::Slice("message_reaction_count");
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return td::Slice();
|
return td::Slice();
|
||||||
@ -13451,6 +13489,19 @@ void Client::add_update_message_reaction(object_ptr<td_api::updateMessageReactio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::add_update_message_reaction_count(object_ptr<td_api::updateMessageReactions> &&update) {
|
||||||
|
CHECK(update != nullptr);
|
||||||
|
auto left_time = update->date_ + 86400 - get_unix_time();
|
||||||
|
if (left_time > 0) {
|
||||||
|
auto webhook_queue_id = update->chat_id_ + (static_cast<int64>(9) << 33);
|
||||||
|
add_update(UpdateType::MessageReactionCount, JsonMessageReactionCountUpdated(update.get(), this), left_time,
|
||||||
|
webhook_queue_id);
|
||||||
|
} else {
|
||||||
|
LOG(DEBUG) << "Skip updateMessageReactions with date " << update->date_ << ", because current date is "
|
||||||
|
<< get_unix_time();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
td::int64 Client::choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const {
|
td::int64 Client::choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const {
|
||||||
CHECK(message_add_members != nullptr);
|
CHECK(message_add_members != nullptr);
|
||||||
for (auto &member_user_id : message_add_members->member_user_ids_) {
|
for (auto &member_user_id : message_add_members->member_user_ids_) {
|
||||||
|
@ -105,6 +105,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
class JsonUser;
|
class JsonUser;
|
||||||
class JsonUsers;
|
class JsonUsers;
|
||||||
class JsonReactionType;
|
class JsonReactionType;
|
||||||
|
class JsonReactionCount;
|
||||||
class JsonChatPermissions;
|
class JsonChatPermissions;
|
||||||
class JsonChatPhotoInfo;
|
class JsonChatPhotoInfo;
|
||||||
class JsonChatLocation;
|
class JsonChatLocation;
|
||||||
@ -174,6 +175,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
class JsonForumTopicInfo;
|
class JsonForumTopicInfo;
|
||||||
class JsonGameHighScore;
|
class JsonGameHighScore;
|
||||||
class JsonMessageReactionUpdated;
|
class JsonMessageReactionUpdated;
|
||||||
|
class JsonMessageReactionCountUpdated;
|
||||||
class JsonAddress;
|
class JsonAddress;
|
||||||
class JsonOrderInfo;
|
class JsonOrderInfo;
|
||||||
class JsonSuccessfulPaymentBot;
|
class JsonSuccessfulPaymentBot;
|
||||||
@ -1129,6 +1131,8 @@ class Client final : public WebhookActor::Callback {
|
|||||||
|
|
||||||
void add_update_message_reaction(object_ptr<td_api::updateMessageReaction> &&update);
|
void add_update_message_reaction(object_ptr<td_api::updateMessageReaction> &&update);
|
||||||
|
|
||||||
|
void add_update_message_reaction_count(object_ptr<td_api::updateMessageReactions> &&update);
|
||||||
|
|
||||||
// append only before Size
|
// append only before Size
|
||||||
enum class UpdateType : int32 {
|
enum class UpdateType : int32 {
|
||||||
Message,
|
Message,
|
||||||
@ -1150,6 +1154,7 @@ class Client final : public WebhookActor::Callback {
|
|||||||
ChatBoostUpdated,
|
ChatBoostUpdated,
|
||||||
ChatBoostRemoved,
|
ChatBoostRemoved,
|
||||||
MessageReaction,
|
MessageReaction,
|
||||||
|
MessageReactionCount,
|
||||||
Size
|
Size
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1179,10 +1184,11 @@ class Client final : public WebhookActor::Callback {
|
|||||||
|
|
||||||
bool have_message_access(int64 chat_id) const;
|
bool have_message_access(int64 chat_id) const;
|
||||||
|
|
||||||
// by default ChatMember and MessageReaction updates are disabled
|
// by default ChatMember, MessageReaction, and MessageReactionCount updates are disabled
|
||||||
static constexpr td::uint32 DEFAULT_ALLOWED_UPDATE_TYPES = (1 << static_cast<int32>(UpdateType::Size)) - 1 -
|
static constexpr td::uint32 DEFAULT_ALLOWED_UPDATE_TYPES =
|
||||||
(1 << static_cast<int32>(UpdateType::ChatMember)) -
|
(1 << static_cast<int32>(UpdateType::Size)) - 1 - (1 << static_cast<int32>(UpdateType::ChatMember)) -
|
||||||
(1 << static_cast<int32>(UpdateType::MessageReaction));
|
(1 << static_cast<int32>(UpdateType::MessageReaction)) -
|
||||||
|
(1 << static_cast<int32>(UpdateType::MessageReactionCount));
|
||||||
|
|
||||||
object_ptr<td_api::AuthorizationState> authorization_state_;
|
object_ptr<td_api::AuthorizationState> authorization_state_;
|
||||||
bool was_authorized_ = false;
|
bool was_authorized_ = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user