1 // 2 // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 // 7 #pragma once 8 9 #include "td/telegram/DialogId.h" 10 #include "td/telegram/FullMessageId.h" 11 #include "td/telegram/MessageId.h" 12 #include "td/telegram/td_api.h" 13 #include "td/telegram/telegram_api.h" 14 #include "td/telegram/UserId.h" 15 16 #include "td/actor/PromiseFuture.h" 17 18 #include "td/utils/buffer.h" 19 #include "td/utils/common.h" 20 21 namespace td { 22 23 class Td; 24 25 class CallbackQueriesManager { 26 public: 27 explicit CallbackQueriesManager(Td *td); 28 29 void answer_callback_query(int64 callback_query_id, const string &text, bool show_alert, const string &url, 30 int32 cache_time, Promise<Unit> &&promise) const; 31 32 void on_new_query(int32 flags, int64 callback_query_id, UserId sender_user_id, DialogId dialog_id, 33 MessageId message_id, BufferSlice &&data, int64 chat_instance, string &&game_short_name); 34 35 void on_new_inline_query(int32 flags, int64 callback_query_id, UserId sender_user_id, 36 tl_object_ptr<telegram_api::InputBotInlineMessageID> &&inline_message_id, BufferSlice &&data, 37 int64 chat_instance, string &&game_short_name); 38 39 void send_callback_query(FullMessageId full_message_id, tl_object_ptr<td_api::CallbackQueryPayload> &&payload, 40 Promise<td_api::object_ptr<td_api::callbackQueryAnswer>> &&promise); 41 42 private: 43 static constexpr int32 BOT_CALLBACK_ANSWER_FLAG_HAS_MESSAGE = 1 << 0; 44 static constexpr int32 BOT_CALLBACK_ANSWER_FLAG_NEED_SHOW_ALERT = 1 << 1; 45 static constexpr int32 BOT_CALLBACK_ANSWER_FLAG_HAS_URL = 1 << 2; 46 47 static tl_object_ptr<td_api::CallbackQueryPayload> get_query_payload(int32 flags, BufferSlice &&data, 48 string &&game_short_name); 49 50 void send_get_callback_answer_query(FullMessageId full_message_id, 51 tl_object_ptr<td_api::CallbackQueryPayload> &&payload, 52 tl_object_ptr<telegram_api::InputCheckPasswordSRP> &&password, 53 Promise<td_api::object_ptr<td_api::callbackQueryAnswer>> &&promise); 54 55 Td *td_; 56 }; 57 58 } // namespace td 59