Add td_api::setMessageReactions for bots.
This commit is contained in:
parent
cc37a0c937
commit
e4e76a7483
@ -7408,6 +7408,13 @@ addMessageReaction chat_id:int53 message_id:int53 reaction_type:ReactionType is_
|
||||
//@reaction_type Type of the reaction to remove
|
||||
removeMessageReaction chat_id:int53 message_id:int53 reaction_type:ReactionType = Ok;
|
||||
|
||||
//@description Sets reactions on a message; for bots only
|
||||
//@chat_id Identifier of the chat to which the message belongs
|
||||
//@message_id Identifier of the message
|
||||
//@reaction_types Types of the reaction to set
|
||||
//@is_big Pass true if the reactions are added with a big animation
|
||||
setMessageReactions chat_id:int53 message_id:int53 reaction_types:vector<ReactionType> is_big:Bool = Ok;
|
||||
|
||||
//@description Returns reactions added for a message, along with their sender
|
||||
//@chat_id Identifier of the chat to which the message belongs
|
||||
//@message_id Identifier of the message
|
||||
|
@ -876,6 +876,19 @@ void send_message_reaction(Td *td, MessageFullId message_full_id, vector<Reactio
|
||||
->send(message_full_id, std::move(reaction_types), is_big, add_to_recent);
|
||||
}
|
||||
|
||||
void set_message_reactions(Td *td, MessageFullId message_full_id, vector<ReactionType> reaction_types, bool is_big,
|
||||
Promise<Unit> &&promise) {
|
||||
if (!td->messages_manager_->have_message_force(message_full_id, "set_message_reactions")) {
|
||||
return promise.set_error(Status::Error(400, "Message not found"));
|
||||
}
|
||||
for (const auto &reaction_type : reaction_types) {
|
||||
if (reaction_type.is_empty()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid reaction type specified"));
|
||||
}
|
||||
}
|
||||
send_message_reaction(td, message_full_id, std::move(reaction_types), is_big, false, std::move(promise));
|
||||
}
|
||||
|
||||
void get_message_added_reactions(Td *td, MessageFullId message_full_id, ReactionType reaction_type, string offset,
|
||||
int32 limit, Promise<td_api::object_ptr<td_api::addedReactions>> &&promise) {
|
||||
if (!td->messages_manager_->have_message_force(message_full_id, "get_message_added_reactions")) {
|
||||
|
@ -216,6 +216,9 @@ void reload_message_reactions(Td *td, DialogId dialog_id, vector<MessageId> &&me
|
||||
void send_message_reaction(Td *td, MessageFullId message_full_id, vector<ReactionType> reaction_types, bool is_big,
|
||||
bool add_to_recent, Promise<Unit> &&promise);
|
||||
|
||||
void set_message_reactions(Td *td, MessageFullId message_full_id, vector<ReactionType> reaction_types, bool is_big,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void get_message_added_reactions(Td *td, MessageFullId message_full_id, ReactionType reaction_type, string offset,
|
||||
int32 limit, Promise<td_api::object_ptr<td_api::addedReactions>> &&promise);
|
||||
|
||||
|
@ -5489,6 +5489,13 @@ void Td::on_request(uint64 id, const td_api::removeMessageReaction &request) {
|
||||
ReactionType(request.reaction_type_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setMessageReactions &request) {
|
||||
CHECK_IS_BOT();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
set_message_reactions(this, {DialogId(request.chat_id_), MessageId(request.message_id_)},
|
||||
ReactionType::get_reaction_types(request.reaction_types_), request.is_big_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getMessageAddedReactions &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.offset_);
|
||||
|
@ -747,6 +747,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::removeMessageReaction &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setMessageReactions &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getMessageAddedReactions &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setDefaultReactionType &request);
|
||||
|
@ -2778,6 +2778,14 @@ class CliClient final : public Actor {
|
||||
string reaction;
|
||||
get_args(args, chat_id, message_id, reaction);
|
||||
send_request(td_api::make_object<td_api::removeMessageReaction>(chat_id, message_id, as_reaction_type(reaction)));
|
||||
} else if (op == "reactbot" || op == "reactbotbig") {
|
||||
ChatId chat_id;
|
||||
MessageId message_id;
|
||||
string reactions;
|
||||
get_args(args, chat_id, message_id, reactions);
|
||||
auto reaction_types = transform(autosplit_str(reactions), as_reaction_type);
|
||||
send_request(td_api::make_object<td_api::setMessageReactions>(chat_id, message_id, std::move(reaction_types),
|
||||
op == "reactbotbig"));
|
||||
} else if (op == "gmars") {
|
||||
ChatId chat_id;
|
||||
MessageId message_id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user