Add td_api::sendWebAppCustomRequest.
This commit is contained in:
parent
49c1764746
commit
89e2a29926
@ -8220,6 +8220,12 @@ canBotSendMessages bot_user_id:int53 = Ok;
|
|||||||
//@description Allows the specified bot to send messages to the user @bot_user_id Identifier of the target bot
|
//@description Allows the specified bot to send messages to the user @bot_user_id Identifier of the target bot
|
||||||
allowBotToSendMessages bot_user_id:int53 = Ok;
|
allowBotToSendMessages bot_user_id:int53 = Ok;
|
||||||
|
|
||||||
|
//@description Sends a custom request from a Web App
|
||||||
|
//@bot_user_id Identifier of the bot
|
||||||
|
//@method The method name
|
||||||
|
//@parameters JSON-serialized method parameters
|
||||||
|
sendWebAppCustomRequest bot_user_id:int53 method:string parameters:string = CustomRequestResult;
|
||||||
|
|
||||||
|
|
||||||
//@description Sets the name of a bot. Can be called only if userTypeBot.can_be_edited == true
|
//@description Sets the name of a bot. Can be called only if userTypeBot.can_be_edited == true
|
||||||
//@bot_user_id Identifier of the target bot
|
//@bot_user_id Identifier of the target bot
|
||||||
|
@ -265,6 +265,38 @@ class ProlongWebViewQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class InvokeWebViewCustomMethodQuery final : public Td::ResultHandler {
|
||||||
|
Promise<td_api::object_ptr<td_api::customRequestResult>> promise_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit InvokeWebViewCustomMethodQuery(Promise<td_api::object_ptr<td_api::customRequestResult>> &&promise)
|
||||||
|
: promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(UserId bot_user_id, const string &method, const string ¶meters) {
|
||||||
|
auto r_input_user = td_->contacts_manager_->get_input_user(bot_user_id);
|
||||||
|
if (r_input_user.is_error()) {
|
||||||
|
return on_error(r_input_user.move_as_error());
|
||||||
|
}
|
||||||
|
send_query(G()->net_query_creator().create(telegram_api::bots_invokeWebViewCustomMethod(
|
||||||
|
r_input_user.move_as_ok(), method, make_tl_object<telegram_api::dataJSON>(parameters))));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::bots_invokeWebViewCustomMethod>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = result_ptr.move_as_ok();
|
||||||
|
promise_.set_value(td_api::make_object<td_api::customRequestResult>(result->data_));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class GetAttachMenuBotsQuery final : public Td::ResultHandler {
|
class GetAttachMenuBotsQuery final : public Td::ResultHandler {
|
||||||
Promise<telegram_api::object_ptr<telegram_api::AttachMenuBots>> promise_;
|
Promise<telegram_api::object_ptr<telegram_api::AttachMenuBots>> promise_;
|
||||||
|
|
||||||
@ -826,6 +858,12 @@ void AttachMenuManager::close_web_view(int64 query_id, Promise<Unit> &&promise)
|
|||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AttachMenuManager::invoke_web_view_custom_method(
|
||||||
|
UserId bot_user_id, const string &method, const string ¶meters,
|
||||||
|
Promise<td_api::object_ptr<td_api::customRequestResult>> &&promise) {
|
||||||
|
td_->create_handler<InvokeWebViewCustomMethodQuery>(std::move(promise))->send(bot_user_id, method, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
Result<AttachMenuManager::AttachMenuBot> AttachMenuManager::get_attach_menu_bot(
|
Result<AttachMenuManager::AttachMenuBot> AttachMenuManager::get_attach_menu_bot(
|
||||||
tl_object_ptr<telegram_api::attachMenuBot> &&bot) {
|
tl_object_ptr<telegram_api::attachMenuBot> &&bot) {
|
||||||
UserId user_id(bot->bot_id_);
|
UserId user_id(bot->bot_id_);
|
||||||
|
@ -52,6 +52,9 @@ class AttachMenuManager final : public Actor {
|
|||||||
|
|
||||||
void close_web_view(int64 query_id, Promise<Unit> &&promise);
|
void close_web_view(int64 query_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void invoke_web_view_custom_method(UserId bot_user_id, const string &method, const string ¶meters,
|
||||||
|
Promise<td_api::object_ptr<td_api::customRequestResult>> &&promise);
|
||||||
|
|
||||||
void reload_attach_menu_bots(Promise<Unit> &&promise);
|
void reload_attach_menu_bots(Promise<Unit> &&promise);
|
||||||
|
|
||||||
void get_attach_menu_bot(UserId user_id, Promise<td_api::object_ptr<td_api::attachmentMenuBot>> &&promise);
|
void get_attach_menu_bot(UserId user_id, Promise<td_api::object_ptr<td_api::attachmentMenuBot>> &&promise);
|
||||||
|
@ -7308,15 +7308,26 @@ void Td::on_request(uint64 id, const td_api::setDefaultChannelAdministratorRight
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::canBotSendMessages &request) {
|
void Td::on_request(uint64 id, const td_api::canBotSendMessages &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
bot_info_manager_->can_bot_send_messages(UserId(request.bot_user_id_), std::move(promise));
|
bot_info_manager_->can_bot_send_messages(UserId(request.bot_user_id_), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::allowBotToSendMessages &request) {
|
void Td::on_request(uint64 id, const td_api::allowBotToSendMessages &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
bot_info_manager_->allow_bot_to_send_messages(UserId(request.bot_user_id_), std::move(promise));
|
bot_info_manager_->allow_bot_to_send_messages(UserId(request.bot_user_id_), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, td_api::sendWebAppCustomRequest &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CLEAN_INPUT_STRING(request.method_);
|
||||||
|
CLEAN_INPUT_STRING(request.parameters_);
|
||||||
|
CREATE_REQUEST_PROMISE();
|
||||||
|
attach_menu_manager_->invoke_web_view_custom_method(UserId(request.bot_user_id_), request.method_,
|
||||||
|
request.parameters_, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::setBotName &request) {
|
void Td::on_request(uint64 id, td_api::setBotName &request) {
|
||||||
CLEAN_INPUT_STRING(request.name_);
|
CLEAN_INPUT_STRING(request.name_);
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
@ -1225,6 +1225,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::allowBotToSendMessages &request);
|
void on_request(uint64 id, const td_api::allowBotToSendMessages &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, td_api::sendWebAppCustomRequest &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::setBotName &request);
|
void on_request(uint64 id, td_api::setBotName &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getBotName &request);
|
void on_request(uint64 id, const td_api::getBotName &request);
|
||||||
|
@ -5518,6 +5518,12 @@ class CliClient final : public Actor {
|
|||||||
UserId bot_user_id;
|
UserId bot_user_id;
|
||||||
get_args(args, bot_user_id);
|
get_args(args, bot_user_id);
|
||||||
send_request(td_api::make_object<td_api::allowBotToSendMessages>(bot_user_id));
|
send_request(td_api::make_object<td_api::allowBotToSendMessages>(bot_user_id));
|
||||||
|
} else if (op == "swacr") {
|
||||||
|
UserId bot_user_id;
|
||||||
|
string method;
|
||||||
|
string parameters;
|
||||||
|
get_args(args, bot_user_id, method, parameters);
|
||||||
|
send_request(td_api::make_object<td_api::sendWebAppCustomRequest>(bot_user_id, method, parameters));
|
||||||
} else if (op == "gbi") {
|
} else if (op == "gbi") {
|
||||||
UserId bot_user_id;
|
UserId bot_user_id;
|
||||||
string language_code;
|
string language_code;
|
||||||
|
Loading…
Reference in New Issue
Block a user