Add td_api::sentWebViewMessage.

This commit is contained in:
levlam 2022-03-28 15:49:01 +03:00
parent d9ddb53056
commit 37bf9979c5
4 changed files with 16 additions and 10 deletions

View File

@ -2518,6 +2518,9 @@ importedContacts user_ids:vector<int53> importer_count:vector<int32> = ImportedC
//@macos_icon Attach menu icon for the bot in TGS format for the official native macOS app; may be null
attachMenuBot bot_user_id:int53 name:string default_icon:file ios_static_icon:file ios_animated_icon:file android_icon:file macos_icon:file = AttachMenuBot;
//@description Information about the message sent by answerWebViewQuery @inline_message_id Identifier of the sent inline message, if known
sentWebViewMessage inline_message_id:string = SentWebViewMessage;
//@description Contains an HTTP URL @url The URL
httpUrl url:string = HttpUrl;
@ -4850,7 +4853,7 @@ sendWebViewData bot_user_id:int53 button_text:string data:string = Ok;
//@description Sets the result of interaction with web view and sends corresponding message on behalf of the user to the chat from which the query originated; for bots only
//@web_view_query_id Identifier of the web view query
//@result The result of the query
answerWebViewQuery web_view_query_id:string result:InputInlineQueryResult = Ok;
answerWebViewQuery web_view_query_id:string result:InputInlineQueryResult = SentWebViewMessage;
//@description Sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires @chat_id Identifier of the chat with the message @message_id Identifier of the message from which the query originated @payload Query payload

View File

@ -193,10 +193,11 @@ class SendWebViewDataQuery final : public Td::ResultHandler {
};
class SendWebViewResultMessageQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
Promise<td_api::object_ptr<td_api::sentWebViewMessage>> promise_;
public:
explicit SendWebViewResultMessageQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
explicit SendWebViewResultMessageQuery(Promise<td_api::object_ptr<td_api::sentWebViewMessage>> &&promise)
: promise_(std::move(promise)) {
}
void send(const string &bot_query_id, tl_object_ptr<telegram_api::InputBotInlineResult> &&result) {
@ -210,8 +211,10 @@ class SendWebViewResultMessageQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error());
}
// auto ptr = result_ptr.move_as_ok();
promise_.set_value(Unit());
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SendWebViewResultMessageQuery: " << to_string(ptr);
promise_.set_value(td_api::make_object<td_api::sentWebViewMessage>(
InlineQueriesManager::get_inline_message_id(std::move(ptr->msg_id_))));
}
void on_error(Status status) final {
@ -469,9 +472,9 @@ void InlineQueriesManager::send_web_view_data(UserId bot_user_id, string &&butto
->send(std::move(input_user), random_id, button_text, data);
}
void InlineQueriesManager::answer_web_view_query(const string &web_view_query_id,
td_api::object_ptr<td_api::InputInlineQueryResult> &&input_result,
Promise<Unit> &&promise) const {
void InlineQueriesManager::answer_web_view_query(
const string &web_view_query_id, td_api::object_ptr<td_api::InputInlineQueryResult> &&input_result,
Promise<td_api::object_ptr<td_api::sentWebViewMessage>> &&promise) const {
CHECK(td_->auth_manager_->is_bot());
TRY_RESULT_PROMISE(promise, result, get_input_bot_inline_result(std::move(input_result), nullptr, nullptr));

View File

@ -49,7 +49,7 @@ class InlineQueriesManager final : public Actor {
void answer_web_view_query(const string &web_view_query_id,
td_api::object_ptr<td_api::InputInlineQueryResult> &&input_result,
Promise<Unit> &&promise) const;
Promise<td_api::object_ptr<td_api::sentWebViewMessage>> &&promise) const;
uint64 send_inline_query(UserId bot_user_id, DialogId dialog_id, Location user_location, const string &query,
const string &offset, Promise<Unit> &&promise);

View File

@ -7340,7 +7340,7 @@ void Td::on_request(uint64 id, td_api::sendWebViewData &request) {
void Td::on_request(uint64 id, td_api::answerWebViewQuery &request) {
CHECK_IS_BOT();
CLEAN_INPUT_STRING(request.web_view_query_id_);
CREATE_OK_REQUEST_PROMISE();
CREATE_REQUEST_PROMISE();
inline_queries_manager_->answer_web_view_query(request.web_view_query_id_, std::move(request.result_),
std::move(promise));
}