2020-11-03 17:34:10 +01:00
|
|
|
//
|
2022-12-31 22:31:16 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2020-11-03 17:34:10 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "telegram-bot-api/Query.h"
|
|
|
|
#include "telegram-bot-api/Stats.h"
|
|
|
|
#include "telegram-bot-api/WebhookActor.h"
|
|
|
|
|
|
|
|
#include "td/telegram/ClientActor.h"
|
2022-01-25 16:18:44 +01:00
|
|
|
#include "td/telegram/td_api.h"
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-05-13 17:24:18 +02:00
|
|
|
#include "td/net/HttpFile.h"
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
#include "td/actor/actor.h"
|
|
|
|
#include "td/actor/SignalSlot.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/Container.h"
|
2022-03-16 10:41:12 +01:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
|
|
|
#include "td/utils/FlatHashSet.h"
|
2022-11-23 21:43:05 +01:00
|
|
|
#include "td/utils/HashTableUtils.h"
|
2020-11-03 17:34:10 +01:00
|
|
|
#include "td/utils/JsonBuilder.h"
|
2022-06-30 19:27:08 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2020-11-03 17:34:10 +01:00
|
|
|
#include "td/utils/Slice.h"
|
|
|
|
#include "td/utils/Status.h"
|
2022-08-21 13:44:57 +02:00
|
|
|
#include "td/utils/WaitFreeHashMap.h"
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <memory>
|
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
namespace telegram_bot_api {
|
|
|
|
|
|
|
|
struct ClientParameters;
|
|
|
|
|
|
|
|
namespace td_api = td::td_api;
|
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
class Client final : public WebhookActor::Callback {
|
2020-11-03 17:34:10 +01:00
|
|
|
public:
|
|
|
|
Client(td::ActorShared<> parent, const td::string &bot_token, bool is_test_dc, td::int64 tqueue_id,
|
|
|
|
std::shared_ptr<const ClientParameters> parameters, td::ActorId<BotStatActor> stat_actor);
|
2022-07-20 13:48:12 +02:00
|
|
|
Client(const Client &) = delete;
|
|
|
|
Client &operator=(const Client &) = delete;
|
|
|
|
Client(Client &&) = delete;
|
|
|
|
Client &operator=(Client &&) = delete;
|
|
|
|
~Client();
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
void send(PromisedQueryPtr query) final;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
// for stats
|
|
|
|
ServerBotInfo get_bot_info() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
using int32 = td::int32;
|
|
|
|
using int64 = td::int64;
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
using object_ptr = td_api::object_ptr<T>;
|
|
|
|
|
|
|
|
static constexpr bool USE_MESSAGE_DATABASE = false;
|
|
|
|
|
2022-12-29 19:02:15 +01:00
|
|
|
static constexpr int64 GENERAL_MESSAGE_THREAD_ID = 1 << 20;
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static constexpr int32 MAX_CERTIFICATE_FILE_SIZE = 3 << 20;
|
|
|
|
static constexpr int32 MAX_DOWNLOAD_FILE_SIZE = 20 << 20;
|
|
|
|
|
2023-12-12 12:37:51 +01:00
|
|
|
static constexpr int32 MAX_CONCURRENTLY_SENT_CHAT_MESSAGES = 310; // some unreasonably big value
|
2021-10-01 13:52:47 +02:00
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static constexpr std::size_t MIN_PENDING_UPDATES_WARNING = 200;
|
|
|
|
|
|
|
|
static constexpr int64 GREAT_MINDS_SET_ID = 1842540969984001;
|
2023-02-22 17:40:25 +01:00
|
|
|
static constexpr td::Slice GREAT_MINDS_SET_NAME = "TelegramGreatMinds";
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static constexpr int32 MASK_POINTS_SIZE = 4;
|
2023-02-22 17:40:25 +01:00
|
|
|
static constexpr td::Slice MASK_POINTS[MASK_POINTS_SIZE] = {"forehead", "eyes", "mouth", "chin"};
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static constexpr int32 MAX_LENGTH = 10000; // max width or height
|
|
|
|
static constexpr int32 MAX_DURATION = 24 * 60 * 60;
|
|
|
|
|
2023-02-14 12:26:42 +01:00
|
|
|
static constexpr std::size_t MAX_STICKER_EMOJI_COUNT = 20;
|
|
|
|
|
2022-12-29 15:51:39 +01:00
|
|
|
class JsonEmptyObject;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonFile;
|
|
|
|
class JsonDatedFile;
|
|
|
|
class JsonDatedFiles;
|
|
|
|
class JsonUser;
|
|
|
|
class JsonUsers;
|
2023-12-20 13:14:10 +01:00
|
|
|
class JsonReactionType;
|
2023-12-20 15:45:26 +01:00
|
|
|
class JsonReactionCount;
|
2024-03-19 14:03:04 +01:00
|
|
|
class JsonBusinessIntro;
|
2024-03-18 12:26:39 +01:00
|
|
|
class JsonBusinessLocation;
|
2024-03-18 15:04:42 +01:00
|
|
|
class JsonBusinessOpeningHoursInterval;
|
|
|
|
class JsonBusinessOpeningHours;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonChatPermissions;
|
|
|
|
class JsonChatPhotoInfo;
|
|
|
|
class JsonChatLocation;
|
2021-02-25 19:29:30 +01:00
|
|
|
class JsonChatInviteLink;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonChat;
|
|
|
|
class JsonMessageSender;
|
2023-11-13 21:17:15 +01:00
|
|
|
class JsonMessageOrigin;
|
2023-11-14 10:56:32 +01:00
|
|
|
class JsonExternalReplyInfo;
|
2023-12-04 12:18:57 +01:00
|
|
|
class JsonTextQuote;
|
2023-11-13 20:08:07 +01:00
|
|
|
class JsonLinkPreviewOptions;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonAnimation;
|
|
|
|
class JsonAudio;
|
|
|
|
class JsonDocument;
|
|
|
|
class JsonPhotoSize;
|
|
|
|
class JsonPhoto;
|
|
|
|
class JsonChatPhoto;
|
|
|
|
class JsonThumbnail;
|
|
|
|
class JsonMaskPosition;
|
|
|
|
class JsonSticker;
|
|
|
|
class JsonStickers;
|
|
|
|
class JsonVideo;
|
|
|
|
class JsonVideoNote;
|
|
|
|
class JsonVoiceNote;
|
|
|
|
class JsonContact;
|
|
|
|
class JsonDice;
|
|
|
|
class JsonGame;
|
|
|
|
class JsonInvoice;
|
|
|
|
class JsonLocation;
|
|
|
|
class JsonVenue;
|
|
|
|
class JsonPollOption;
|
|
|
|
class JsonPoll;
|
|
|
|
class JsonPollAnswer;
|
|
|
|
class JsonEntity;
|
|
|
|
class JsonVectorEntities;
|
2022-03-24 23:00:48 +01:00
|
|
|
class JsonWebAppInfo;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonInlineKeyboardButton;
|
|
|
|
class JsonInlineKeyboard;
|
|
|
|
class JsonReplyMarkup;
|
|
|
|
class JsonMessage;
|
|
|
|
class JsonMessages;
|
2023-12-04 13:32:17 +01:00
|
|
|
class JsonInaccessibleMessage;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonMessageId;
|
|
|
|
class JsonInlineQuery;
|
|
|
|
class JsonChosenInlineResult;
|
|
|
|
class JsonCallbackQuery;
|
|
|
|
class JsonInlineCallbackQuery;
|
|
|
|
class JsonShippingQuery;
|
|
|
|
class JsonPreCheckoutQuery;
|
|
|
|
class JsonBotCommand;
|
2022-04-08 02:07:52 +02:00
|
|
|
class JsonBotMenuButton;
|
2023-04-07 13:48:34 +02:00
|
|
|
class JsonBotName;
|
2023-02-27 19:32:38 +01:00
|
|
|
class JsonBotInfoDescription;
|
2023-03-04 20:12:34 +01:00
|
|
|
class JsonBotInfoShortDescription;
|
2022-04-03 12:29:57 +02:00
|
|
|
class JsonChatAdministratorRights;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonChatPhotos;
|
|
|
|
class JsonChatMember;
|
|
|
|
class JsonChatMembers;
|
2021-02-26 01:02:26 +01:00
|
|
|
class JsonChatMemberUpdated;
|
2021-11-04 11:35:43 +01:00
|
|
|
class JsonChatJoinRequest;
|
2023-11-13 17:51:05 +01:00
|
|
|
class JsonChatBoostSource;
|
|
|
|
class JsonChatBoost;
|
|
|
|
class JsonChatBoostUpdated;
|
|
|
|
class JsonChatBoostRemoved;
|
2023-11-13 18:16:11 +01:00
|
|
|
class JsonChatBoosts;
|
2022-10-31 15:35:54 +01:00
|
|
|
class JsonForumTopicCreated;
|
2022-12-29 15:37:59 +01:00
|
|
|
class JsonForumTopicEdited;
|
2022-10-31 16:44:29 +01:00
|
|
|
class JsonForumTopicInfo;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonGameHighScore;
|
2023-12-20 15:35:18 +01:00
|
|
|
class JsonMessageReactionUpdated;
|
2023-12-20 15:45:26 +01:00
|
|
|
class JsonMessageReactionCountUpdated;
|
2024-03-14 13:09:47 +01:00
|
|
|
class JsonBusinessConnection;
|
2024-03-18 11:58:44 +01:00
|
|
|
class JsonBusinessMessagesDeleted;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonAddress;
|
|
|
|
class JsonOrderInfo;
|
2024-02-14 16:43:33 +01:00
|
|
|
class JsonStory;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonSuccessfulPaymentBot;
|
|
|
|
class JsonEncryptedPassportElement;
|
|
|
|
class JsonEncryptedCredentials;
|
|
|
|
class JsonPassportData;
|
2022-03-28 16:15:39 +02:00
|
|
|
class JsonWebAppData;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonProximityAlertTriggered;
|
2021-11-04 11:02:05 +01:00
|
|
|
class JsonVideoChatScheduled;
|
|
|
|
class JsonVideoChatEnded;
|
|
|
|
class JsonInviteVideoChatParticipants;
|
2022-12-26 22:52:14 +01:00
|
|
|
class JsonChatSetMessageAutoDeleteTime;
|
2023-02-22 18:45:37 +01:00
|
|
|
class JsonWriteAccessAllowed;
|
2023-01-12 12:49:26 +01:00
|
|
|
class JsonUserShared;
|
2023-12-22 21:32:52 +01:00
|
|
|
class JsonUsersShared;
|
2023-01-12 12:49:26 +01:00
|
|
|
class JsonChatShared;
|
2023-11-13 16:38:57 +01:00
|
|
|
class JsonGiveaway;
|
2023-12-20 14:44:01 +01:00
|
|
|
class JsonGiveawayWinners;
|
2023-12-04 13:23:59 +01:00
|
|
|
class JsonGiveawayCompleted;
|
2024-02-14 15:44:52 +01:00
|
|
|
class JsonChatBoostAdded;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonUpdateTypes;
|
|
|
|
class JsonWebhookInfo;
|
|
|
|
class JsonStickerSet;
|
2022-03-24 10:02:15 +01:00
|
|
|
class JsonSentWebAppMessage;
|
2020-11-03 17:34:10 +01:00
|
|
|
class JsonCustomJson;
|
|
|
|
|
|
|
|
class TdOnOkCallback;
|
|
|
|
class TdOnAuthorizationCallback;
|
|
|
|
class TdOnInitCallback;
|
|
|
|
class TdOnGetUserProfilePhotosCallback;
|
|
|
|
class TdOnSendMessageCallback;
|
2024-03-14 20:51:02 +01:00
|
|
|
class TdOnSendBusinessMessageCallback;
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnSendMessageAlbumCallback;
|
2024-03-15 13:56:40 +01:00
|
|
|
class TdOnSendBusinessMessageAlbumCallback;
|
2023-12-12 12:37:51 +01:00
|
|
|
class TdOnForwardMessagesCallback;
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnDeleteFailedToSendMessageCallback;
|
|
|
|
class TdOnEditMessageCallback;
|
|
|
|
class TdOnEditInlineMessageCallback;
|
|
|
|
class TdOnStopPollCallback;
|
|
|
|
class TdOnOkQueryCallback;
|
|
|
|
class TdOnGetReplyMessageCallback;
|
|
|
|
class TdOnGetEditedMessageCallback;
|
|
|
|
class TdOnGetCallbackQueryMessageCallback;
|
|
|
|
class TdOnGetStickerSetCallback;
|
2022-10-31 16:44:29 +01:00
|
|
|
class TdOnGetForumTopicInfoCallback;
|
2022-04-08 02:07:52 +02:00
|
|
|
class TdOnGetMenuButtonCallback;
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnGetMyCommandsCallback;
|
2022-04-03 12:29:57 +02:00
|
|
|
class TdOnGetMyDefaultAdministratorRightsCallback;
|
2023-04-07 13:48:34 +02:00
|
|
|
class TdOnGetMyNameCallback;
|
2023-02-27 19:32:38 +01:00
|
|
|
class TdOnGetMyDescriptionCallback;
|
2023-03-04 20:12:34 +01:00
|
|
|
class TdOnGetMyShortDescriptionCallback;
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnGetChatFullInfoCallback;
|
|
|
|
class TdOnGetChatStickerSetCallback;
|
2024-02-14 16:43:33 +01:00
|
|
|
class TdOnGetChatCustomEmojiStickerSetCallback;
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnGetChatPinnedMessageCallback;
|
|
|
|
class TdOnGetChatPinnedMessageToUnpinCallback;
|
|
|
|
class TdOnGetGroupMembersCallback;
|
|
|
|
class TdOnGetSupergroupMembersCallback;
|
2023-11-13 18:16:11 +01:00
|
|
|
class TdOnGetSupergroupMemberCountCallback;
|
|
|
|
class TdOnGetUserChatBoostsCallback;
|
2022-05-09 20:49:26 +02:00
|
|
|
class TdOnCreateInvoiceLinkCallback;
|
2021-02-25 19:29:30 +01:00
|
|
|
class TdOnReplacePrimaryChatInviteLinkCallback;
|
|
|
|
class TdOnGetChatInviteLinkCallback;
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnGetGameHighScoresCallback;
|
2022-03-24 10:02:15 +01:00
|
|
|
class TdOnAnswerWebAppQueryCallback;
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnReturnFileCallback;
|
|
|
|
class TdOnReturnStickerSetCallback;
|
2022-07-21 18:00:58 +02:00
|
|
|
class TdOnGetStickerSetPromiseCallback;
|
|
|
|
class TdOnGetStickersCallback;
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnDownloadFileCallback;
|
|
|
|
class TdOnCancelDownloadFileCallback;
|
|
|
|
class TdOnSendCustomRequestCallback;
|
|
|
|
|
|
|
|
void on_get_reply_message(int64 chat_id, object_ptr<td_api::message> reply_to_message);
|
|
|
|
|
|
|
|
void on_get_edited_message(object_ptr<td_api::message> edited_message);
|
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
void on_get_callback_query_message(object_ptr<td_api::message> message, int64 user_id, int state);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
void on_get_sticker_set(int64 set_id, int64 new_callback_query_user_id, int64 new_message_chat_id,
|
2024-03-18 10:36:19 +01:00
|
|
|
const td::string &new_message_business_connection_id,
|
2020-11-03 17:34:10 +01:00
|
|
|
object_ptr<td_api::stickerSet> sticker_set);
|
|
|
|
|
|
|
|
void on_get_sticker_set_name(int64 set_id, const td::string &name);
|
|
|
|
|
|
|
|
class TdQueryCallback {
|
|
|
|
public:
|
|
|
|
virtual void on_result(object_ptr<td_api::Object> result) = 0;
|
|
|
|
TdQueryCallback() = default;
|
|
|
|
TdQueryCallback(const TdQueryCallback &) = delete;
|
|
|
|
TdQueryCallback &operator=(const TdQueryCallback &) = delete;
|
|
|
|
TdQueryCallback(TdQueryCallback &&) = delete;
|
|
|
|
TdQueryCallback &operator=(TdQueryCallback &&) = delete;
|
|
|
|
virtual ~TdQueryCallback() = default;
|
|
|
|
};
|
|
|
|
|
2023-11-14 16:55:55 +01:00
|
|
|
struct InputReplyParameters {
|
2023-11-15 14:18:00 +01:00
|
|
|
td::string reply_in_chat_id;
|
2023-11-14 16:55:55 +01:00
|
|
|
int64 reply_to_message_id = 0;
|
|
|
|
bool allow_sending_without_reply = false;
|
2023-12-04 11:42:00 +01:00
|
|
|
object_ptr<td_api::inputTextQuote> quote;
|
2023-11-14 16:55:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CheckedReplyParameters {
|
2023-11-15 14:18:00 +01:00
|
|
|
int64 reply_in_chat_id = 0;
|
2023-11-14 16:55:55 +01:00
|
|
|
int64 reply_to_message_id = 0;
|
2023-12-04 11:42:00 +01:00
|
|
|
object_ptr<td_api::inputTextQuote> quote;
|
2023-11-14 16:55:55 +01:00
|
|
|
};
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
struct UserInfo;
|
|
|
|
struct ChatInfo;
|
2021-06-23 05:48:24 +02:00
|
|
|
struct BotCommandScope;
|
2023-07-06 13:01:14 +02:00
|
|
|
struct BotUserIds;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-05-10 18:44:12 +02:00
|
|
|
enum class AccessRights { Read, ReadMembers, Edit, Write };
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
template <class OnSuccess>
|
|
|
|
class TdOnCheckUserCallback;
|
|
|
|
template <class OnSuccess>
|
|
|
|
class TdOnCheckUserNoFailCallback;
|
|
|
|
template <class OnSuccess>
|
|
|
|
class TdOnCheckChatCallback;
|
|
|
|
template <class OnSuccess>
|
2021-12-07 12:03:40 +01:00
|
|
|
class TdOnCheckChatNoFailCallback;
|
|
|
|
template <class OnSuccess>
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnCheckMessageCallback;
|
|
|
|
template <class OnSuccess>
|
2023-12-11 18:55:10 +01:00
|
|
|
class TdOnCheckMessagesCallback;
|
|
|
|
template <class OnSuccess>
|
2022-11-02 12:05:23 +01:00
|
|
|
class TdOnCheckMessageThreadCallback;
|
|
|
|
template <class OnSuccess>
|
2024-03-14 18:07:18 +01:00
|
|
|
class TdOnCheckBusinessConnectionCallback;
|
|
|
|
template <class OnSuccess>
|
2020-11-03 17:34:10 +01:00
|
|
|
class TdOnCheckRemoteFileIdCallback;
|
|
|
|
template <class OnSuccess>
|
|
|
|
class TdOnGetChatMemberCallback;
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
|
|
|
class TdOnSearchStickerSetCallback;
|
|
|
|
|
|
|
|
class TdOnResolveBotUsernameCallback;
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
2021-09-20 15:58:22 +02:00
|
|
|
void check_user(int64 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
template <class OnSuccess>
|
2021-09-20 15:58:22 +02:00
|
|
|
void check_user_no_fail(int64 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
template <class OnSuccess>
|
|
|
|
static void check_user_read_access(const UserInfo *user_info, PromisedQueryPtr query, OnSuccess on_success);
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
|
|
|
void check_chat_access(int64 chat_id, AccessRights access_rights, const ChatInfo *chat_info, PromisedQueryPtr query,
|
|
|
|
OnSuccess on_success) const;
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
2023-02-22 17:40:25 +01:00
|
|
|
void check_chat(td::Slice chat_id_str, AccessRights access_rights, PromisedQueryPtr query, OnSuccess on_success);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-12-07 12:03:40 +01:00
|
|
|
template <class OnSuccess>
|
2023-02-22 17:40:25 +01:00
|
|
|
void check_chat_no_fail(td::Slice chat_id_str, PromisedQueryPtr query, OnSuccess on_success);
|
2021-12-07 12:03:40 +01:00
|
|
|
|
2024-03-14 18:07:18 +01:00
|
|
|
static td::Result<int64> get_business_connection_chat_id(td::Slice chat_id_str);
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
|
|
|
void check_business_connection(const td::string &business_connection_id, PromisedQueryPtr query,
|
|
|
|
OnSuccess on_success);
|
|
|
|
|
2021-06-23 05:48:24 +02:00
|
|
|
template <class OnSuccess>
|
|
|
|
void check_bot_command_scope(BotCommandScope &&scope, PromisedQueryPtr query, OnSuccess on_success);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
template <class OnSuccess>
|
|
|
|
void check_remote_file_id(td::string file_id, PromisedQueryPtr query, OnSuccess on_success);
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
2023-02-22 17:40:25 +01:00
|
|
|
void check_message(td::Slice chat_id_str, int64 message_id, bool allow_empty, AccessRights access_rights,
|
|
|
|
td::Slice message_type, PromisedQueryPtr query, OnSuccess on_success);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-12-11 18:55:10 +01:00
|
|
|
template <class OnSuccess>
|
|
|
|
void check_messages(td::Slice chat_id_str, td::vector<int64> message_ids, bool allow_empty,
|
|
|
|
AccessRights access_rights, td::Slice message_type, PromisedQueryPtr query, OnSuccess on_success);
|
|
|
|
|
2022-11-02 12:05:23 +01:00
|
|
|
template <class OnSuccess>
|
2023-11-14 16:55:55 +01:00
|
|
|
void check_reply_parameters(td::Slice chat_id_str, InputReplyParameters &&reply_parameters, int64 message_thread_id,
|
|
|
|
PromisedQueryPtr query, OnSuccess on_success);
|
2022-11-02 12:05:23 +01:00
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
template <class OnSuccess>
|
|
|
|
void resolve_sticker_set(const td::string &sticker_set_name, PromisedQueryPtr query, OnSuccess on_success);
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
|
|
|
void resolve_reply_markup_bot_usernames(object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query,
|
|
|
|
OnSuccess on_success);
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
|
|
|
void resolve_inline_query_results_bot_usernames(td::vector<object_ptr<td_api::InputInlineQueryResult>> results,
|
|
|
|
PromisedQueryPtr query, OnSuccess on_success);
|
|
|
|
|
|
|
|
template <class OnSuccess>
|
2021-09-20 15:58:22 +02:00
|
|
|
void get_chat_member(int64 chat_id, int64 user_id, PromisedQueryPtr query, OnSuccess on_success);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-03-16 10:52:34 +01:00
|
|
|
void send_request(object_ptr<td_api::Function> &&f, td::unique_ptr<TdQueryCallback> handler);
|
|
|
|
void do_send_request(object_ptr<td_api::Function> &&f, td::unique_ptr<TdQueryCallback> handler);
|
2020-11-03 17:34:10 +01:00
|
|
|
static object_ptr<td_api::Object> execute(object_ptr<td_api::Function> &&f);
|
|
|
|
void on_update(object_ptr<td_api::Object> result);
|
|
|
|
void on_result(td::uint64 id, object_ptr<td_api::Object> result);
|
|
|
|
|
|
|
|
void on_update_authorization_state();
|
2023-02-22 17:40:25 +01:00
|
|
|
void log_out(int32 error_code, td::Slice error_message);
|
2020-11-03 17:34:10 +01:00
|
|
|
void on_closed();
|
|
|
|
void finish_closing();
|
|
|
|
|
|
|
|
void clear_tqueue();
|
|
|
|
|
|
|
|
bool allow_update_before_authorization(const td_api::Object *update) const;
|
|
|
|
void update_shared_unix_time_difference();
|
|
|
|
|
|
|
|
void on_update_file(object_ptr<td_api::file> file);
|
|
|
|
|
|
|
|
static bool to_bool(td::MutableSlice value);
|
|
|
|
|
2023-11-14 17:34:38 +01:00
|
|
|
static object_ptr<td_api::InputMessageReplyTo> get_input_message_reply_to(CheckedReplyParameters &&reply_parameters);
|
2023-11-14 16:55:55 +01:00
|
|
|
|
2024-03-14 20:51:02 +01:00
|
|
|
static object_ptr<td_api::InputMessageReplyTo> get_input_message_reply_to(InputReplyParameters &&reply_parameters);
|
|
|
|
|
2023-11-14 16:55:55 +01:00
|
|
|
static td::Result<InputReplyParameters> get_reply_parameters(const Query *query);
|
|
|
|
|
|
|
|
static td::Result<InputReplyParameters> get_reply_parameters(td::JsonValue &&value);
|
2023-07-20 16:06:32 +02:00
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static td::Result<object_ptr<td_api::keyboardButton>> get_keyboard_button(td::JsonValue &button);
|
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
static td::Result<object_ptr<td_api::inlineKeyboardButton>> get_inline_keyboard_button(td::JsonValue &button,
|
|
|
|
BotUserIds &bot_user_ids);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
static td::Result<object_ptr<td_api::ReplyMarkup>> get_reply_markup(const Query *query, BotUserIds &bot_user_ids);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
static td::Result<object_ptr<td_api::ReplyMarkup>> get_reply_markup(td::JsonValue &&value, BotUserIds &bot_user_ids);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::labeledPricePart>> get_labeled_price_part(td::JsonValue &value);
|
|
|
|
|
|
|
|
static td::Result<td::vector<object_ptr<td_api::labeledPricePart>>> get_labeled_price_parts(td::JsonValue &value);
|
|
|
|
|
2021-04-08 16:42:21 +02:00
|
|
|
static td::Result<td::vector<int64>> get_suggested_tip_amounts(td::JsonValue &value);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static td::Result<object_ptr<td_api::shippingOption>> get_shipping_option(td::JsonValue &option);
|
|
|
|
|
|
|
|
static td::Result<td::vector<object_ptr<td_api::shippingOption>>> get_shipping_options(const Query *query);
|
|
|
|
|
|
|
|
static td::Result<td::vector<object_ptr<td_api::shippingOption>>> get_shipping_options(td::JsonValue &&value);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::InputMessageContent>> get_input_message_content(
|
|
|
|
td::JsonValue &input_message_content, bool is_input_message_content_required);
|
|
|
|
|
|
|
|
static object_ptr<td_api::ChatAction> get_chat_action(const Query *query);
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::string get_local_file_path(td::Slice file_uri);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
object_ptr<td_api::InputFile> get_input_file(const Query *query, td::Slice field_name, bool force_file = false) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
object_ptr<td_api::InputFile> get_input_file(const Query *query, td::Slice field_name, td::Slice file_id,
|
2020-11-03 17:34:10 +01:00
|
|
|
bool force_file) const;
|
|
|
|
|
2023-02-14 11:30:17 +01:00
|
|
|
object_ptr<td_api::inputThumbnail> get_input_thumbnail(const Query *query) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 19:01:05 +01:00
|
|
|
static td::Result<td_api::object_ptr<td_api::inlineQueryResultsButton>> get_inline_query_results_button(
|
|
|
|
td::JsonValue &&value);
|
|
|
|
|
|
|
|
static td::Result<td_api::object_ptr<td_api::inlineQueryResultsButton>> get_inline_query_results_button(
|
|
|
|
td::MutableSlice value);
|
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
static td::Result<object_ptr<td_api::InputInlineQueryResult>> get_inline_query_result(const Query *query,
|
|
|
|
BotUserIds &bot_user_ids);
|
2022-03-24 10:02:15 +01:00
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
static td::Result<object_ptr<td_api::InputInlineQueryResult>> get_inline_query_result(td::JsonValue &&value,
|
|
|
|
BotUserIds &bot_user_ids);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
static td::Result<td::vector<object_ptr<td_api::InputInlineQueryResult>>> get_inline_query_results(
|
|
|
|
const Query *query, BotUserIds &bot_user_ids);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
static td::Result<td::vector<object_ptr<td_api::InputInlineQueryResult>>> get_inline_query_results(
|
|
|
|
td::JsonValue &&value, BotUserIds &bot_user_ids);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-06-23 05:48:24 +02:00
|
|
|
struct BotCommandScope {
|
|
|
|
object_ptr<td_api::BotCommandScope> scope_;
|
|
|
|
td::string chat_id_;
|
2023-02-22 17:50:53 +01:00
|
|
|
int64 user_id_ = 0;
|
2021-06-23 05:48:24 +02:00
|
|
|
|
|
|
|
explicit BotCommandScope(object_ptr<td_api::BotCommandScope> scope, td::string chat_id = td::string(),
|
2023-02-22 17:50:53 +01:00
|
|
|
int64 user_id = 0)
|
2021-06-23 05:48:24 +02:00
|
|
|
: scope_(std::move(scope)), chat_id_(std::move(chat_id)), user_id_(user_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static td::Result<BotCommandScope> get_bot_command_scope(const Query *query);
|
|
|
|
|
|
|
|
static td::Result<BotCommandScope> get_bot_command_scope(td::JsonValue &&value);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static td::Result<object_ptr<td_api::botCommand>> get_bot_command(td::JsonValue &&value);
|
|
|
|
|
|
|
|
static td::Result<td::vector<object_ptr<td_api::botCommand>>> get_bot_commands(const Query *query);
|
|
|
|
|
2022-04-08 03:12:22 +02:00
|
|
|
static td::Result<object_ptr<td_api::botMenuButton>> get_bot_menu_button(const Query *query);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::botMenuButton>> get_bot_menu_button(td::JsonValue &&value);
|
|
|
|
|
2022-04-03 08:33:40 +02:00
|
|
|
static td::Result<object_ptr<td_api::chatAdministratorRights>> get_chat_administrator_rights(td::JsonValue &&value);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::chatAdministratorRights>> get_chat_administrator_rights(const Query *query);
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Result<object_ptr<td_api::maskPosition>> get_mask_position(const Query *query, td::Slice field_name);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::maskPosition>> get_mask_position(td::JsonValue &&value);
|
|
|
|
|
|
|
|
static int32 mask_point_to_index(const object_ptr<td_api::MaskPoint> &mask_point);
|
|
|
|
|
|
|
|
static object_ptr<td_api::MaskPoint> mask_index_to_point(int32 index);
|
|
|
|
|
2023-02-14 12:26:42 +01:00
|
|
|
static td::Result<td::string> get_sticker_emojis(td::JsonValue &&value);
|
|
|
|
|
2023-02-14 15:43:08 +01:00
|
|
|
static td::Result<td::string> get_sticker_emojis(td::MutableSlice emoji_list);
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Result<object_ptr<td_api::StickerFormat>> get_sticker_format(td::Slice sticker_format);
|
2023-02-14 14:34:10 +01:00
|
|
|
|
2024-03-18 10:52:17 +01:00
|
|
|
td::Result<object_ptr<td_api::inputSticker>> get_legacy_input_sticker(const Query *query) const;
|
|
|
|
|
2023-02-14 12:26:42 +01:00
|
|
|
td::Result<object_ptr<td_api::inputSticker>> get_input_sticker(const Query *query) const;
|
|
|
|
|
2024-03-14 12:47:41 +01:00
|
|
|
td::Result<object_ptr<td_api::inputSticker>> get_input_sticker(const Query *query, td::JsonValue &&value,
|
|
|
|
td::Slice default_sticker_format) const;
|
2023-02-14 12:26:42 +01:00
|
|
|
|
2024-03-14 12:47:41 +01:00
|
|
|
td::Result<td::vector<object_ptr<td_api::inputSticker>>> get_input_stickers(const Query *query) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-14 15:40:32 +01:00
|
|
|
static td::Result<object_ptr<td_api::InputFile>> get_sticker_input_file(const Query *query);
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Result<td::string> get_passport_element_hash(td::Slice encoded_hash);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::InputPassportElementErrorSource>> get_passport_element_error_source(
|
|
|
|
td::JsonObject &object);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::inputPassportElementError>> get_passport_element_error(td::JsonValue &&value);
|
|
|
|
|
|
|
|
static td::Result<td::vector<object_ptr<td_api::inputPassportElementError>>> get_passport_element_errors(
|
|
|
|
const Query *query);
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::JsonValue get_input_entities(const Query *query, td::Slice field_name);
|
2021-02-27 20:32:50 +01:00
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static td::Result<object_ptr<td_api::formattedText>> get_caption(const Query *query);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::TextEntityType>> get_text_entity_type(td::JsonObject &object);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::textEntity>> get_text_entity(td::JsonValue &&value);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::formattedText>> get_formatted_text(td::string text, td::string parse_mode,
|
|
|
|
td::JsonValue &&input_entities);
|
|
|
|
|
2023-11-13 19:19:35 +01:00
|
|
|
static object_ptr<td_api::linkPreviewOptions> get_link_preview_options(bool disable_web_page_preview);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::linkPreviewOptions>> get_link_preview_options(const Query *query);
|
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::linkPreviewOptions>> get_link_preview_options(td::JsonValue &&value);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static td::Result<object_ptr<td_api::inputMessageText>> get_input_message_text(const Query *query);
|
|
|
|
|
2023-11-13 19:19:35 +01:00
|
|
|
static td::Result<object_ptr<td_api::inputMessageText>> get_input_message_text(
|
|
|
|
td::string text, object_ptr<td_api::linkPreviewOptions> link_preview_options, td::string parse_mode,
|
|
|
|
td::JsonValue &&input_entities);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static td::Result<object_ptr<td_api::location>> get_location(const Query *query);
|
|
|
|
|
2023-02-01 02:00:16 +01:00
|
|
|
static td::Result<object_ptr<td_api::chatPermissions>> get_chat_permissions(const Query *query, bool &allow_legacy,
|
|
|
|
bool use_independent_chat_permissions);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
td::Result<object_ptr<td_api::InputMessageContent>> get_input_media(const Query *query, td::JsonValue &&input_media,
|
|
|
|
bool for_album) const;
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Result<object_ptr<td_api::InputMessageContent>> get_input_media(const Query *query, td::Slice field_name) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents(
|
|
|
|
const Query *query, td::Slice field_name) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents(
|
|
|
|
const Query *query, td::JsonValue &&value) const;
|
|
|
|
|
2022-09-23 19:29:42 +02:00
|
|
|
td::Result<object_ptr<td_api::inputMessageInvoice>> get_input_message_invoice(const Query *query) const;
|
2022-05-09 20:49:26 +02:00
|
|
|
|
2021-12-30 12:41:30 +01:00
|
|
|
static object_ptr<td_api::messageSendOptions> get_message_send_options(bool disable_notification,
|
|
|
|
bool protect_content);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static td::Result<td::vector<td::string>> get_poll_options(const Query *query);
|
|
|
|
|
2023-12-20 15:57:39 +01:00
|
|
|
static td::Result<object_ptr<td_api::ReactionType>> get_reaction_type(td::JsonValue &&value);
|
|
|
|
|
|
|
|
static td::Result<td::vector<object_ptr<td_api::ReactionType>>> get_reaction_types(const Query *query);
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static int32 get_integer_arg(const Query *query, td::Slice field_name, int32 default_value,
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 min_value = std::numeric_limits<int32>::min(),
|
|
|
|
int32 max_value = std::numeric_limits<int32>::max());
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Result<td::MutableSlice> get_required_string_arg(const Query *query, td::Slice field_name);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static int64 get_message_id(const Query *query, td::Slice field_name = td::Slice("message_id"));
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-12-11 18:55:10 +01:00
|
|
|
static td::Result<td::vector<int64>> get_message_ids(const Query *query, size_t max_count,
|
|
|
|
td::Slice field_name = td::Slice("message_ids"));
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Result<td::Slice> get_inline_message_id(const Query *query,
|
|
|
|
td::Slice field_name = td::Slice("inline_message_id"));
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Result<int64> get_user_id(const Query *query, td::Slice field_name = td::Slice("user_id"));
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-11-22 19:31:04 +01:00
|
|
|
void decrease_yet_unsent_message_count(int64 chat_id, int32 count);
|
|
|
|
|
2023-07-20 15:25:42 +02:00
|
|
|
int64 extract_yet_unsent_message_query_id(int64 chat_id, int64 message_id);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
void on_message_send_succeeded(object_ptr<td_api::message> &&message, int64 old_message_id);
|
2023-09-19 18:26:43 +02:00
|
|
|
|
|
|
|
void on_message_send_failed(int64 chat_id, int64 old_message_id, int64 new_message_id,
|
|
|
|
object_ptr<td_api::error> &&error);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static bool init_methods();
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static bool is_local_method(td::Slice method);
|
2022-09-18 09:19:58 +02:00
|
|
|
|
2023-09-25 18:39:51 +02:00
|
|
|
void on_cmd(PromisedQueryPtr query, bool force = false);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_get_me_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_my_commands_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_my_commands_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_delete_my_commands_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_my_default_administrator_rights_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_my_default_administrator_rights_query(PromisedQueryPtr &query);
|
2023-04-07 13:48:34 +02:00
|
|
|
td::Status process_get_my_name_query(PromisedQueryPtr &query);
|
2023-04-07 13:52:10 +02:00
|
|
|
td::Status process_set_my_name_query(PromisedQueryPtr &query);
|
2023-02-27 19:32:38 +01:00
|
|
|
td::Status process_get_my_description_query(PromisedQueryPtr &query);
|
2023-02-27 00:19:10 +01:00
|
|
|
td::Status process_set_my_description_query(PromisedQueryPtr &query);
|
2023-03-04 20:12:34 +01:00
|
|
|
td::Status process_get_my_short_description_query(PromisedQueryPtr &query);
|
2023-03-04 20:13:39 +01:00
|
|
|
td::Status process_set_my_short_description_query(PromisedQueryPtr &query);
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_get_chat_menu_button_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_chat_menu_button_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_user_profile_photos_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_message_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_animation_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_audio_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_dice_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_document_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_photo_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_sticker_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_video_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_video_note_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_voice_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_game_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_invoice_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_location_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_venue_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_contact_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_poll_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_stop_poll_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_copy_message_query(PromisedQueryPtr &query);
|
2023-12-12 12:48:35 +01:00
|
|
|
td::Status process_copy_messages_query(PromisedQueryPtr &query);
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_forward_message_query(PromisedQueryPtr &query);
|
2023-12-12 12:37:51 +01:00
|
|
|
td::Status process_forward_messages_query(PromisedQueryPtr &query);
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_send_media_group_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_chat_action_query(PromisedQueryPtr &query);
|
2023-12-20 15:57:39 +01:00
|
|
|
td::Status process_set_message_reaction_query(PromisedQueryPtr &query);
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_edit_message_text_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_edit_message_live_location_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_edit_message_media_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_edit_message_caption_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_edit_message_reply_markup_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_delete_message_query(PromisedQueryPtr &query);
|
2023-12-11 18:55:10 +01:00
|
|
|
td::Status process_delete_messages_query(PromisedQueryPtr &query);
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_create_invoice_link_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_game_score_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_game_high_scores_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_answer_web_app_query_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_answer_inline_query_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_answer_callback_query_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_answer_shipping_query_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_answer_pre_checkout_query_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_export_chat_invite_link_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_create_chat_invite_link_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_edit_chat_invite_link_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_revoke_chat_invite_link_query(PromisedQueryPtr &query);
|
2024-03-18 16:31:52 +01:00
|
|
|
td::Status process_get_business_connection_query(PromisedQueryPtr &query);
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_get_chat_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_chat_photo_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_delete_chat_photo_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_chat_title_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_chat_permissions_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_chat_description_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_pin_chat_message_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_unpin_chat_message_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_unpin_all_chat_messages_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_chat_sticker_set_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_delete_chat_sticker_set_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_forum_topic_icon_stickers_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_create_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_edit_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_close_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_reopen_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_delete_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_unpin_all_forum_topic_messages_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_edit_general_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_close_general_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_reopen_general_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_hide_general_forum_topic_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_unhide_general_forum_topic_query(PromisedQueryPtr &query);
|
2023-07-24 16:19:14 +02:00
|
|
|
td::Status process_unpin_all_general_forum_topic_messages_query(PromisedQueryPtr &query);
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_get_chat_member_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_chat_administrators_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_chat_member_count_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_leave_chat_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_promote_chat_member_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_chat_administrator_custom_title_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_ban_chat_member_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_restrict_chat_member_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_unban_chat_member_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_ban_chat_sender_chat_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_unban_chat_sender_chat_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_approve_chat_join_request_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_decline_chat_join_request_query(PromisedQueryPtr &query);
|
2023-11-13 18:16:11 +01:00
|
|
|
td::Status process_get_user_chat_boosts_query(PromisedQueryPtr &query);
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status process_get_sticker_set_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_custom_emoji_stickers_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_upload_sticker_file_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_create_new_sticker_set_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_add_sticker_to_set_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_sticker_set_title_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_sticker_set_thumbnail_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_custom_emoji_sticker_set_thumbnail_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_delete_sticker_set_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_sticker_position_in_set_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_delete_sticker_from_set_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_sticker_emoji_list_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_sticker_keywords_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_sticker_mask_position_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_passport_data_errors_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_send_custom_request_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_answer_custom_query_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_updates_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_set_webhook_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_webhook_info_query(PromisedQueryPtr &query);
|
|
|
|
td::Status process_get_file_query(PromisedQueryPtr &query);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
void webhook_verified(td::string cached_ip_address) final;
|
|
|
|
void webhook_success() final;
|
2023-02-22 17:40:25 +01:00
|
|
|
void webhook_error(td::Status status) final;
|
|
|
|
void webhook_closed(td::Status status) final;
|
2022-01-25 16:18:44 +01:00
|
|
|
void hangup_shared() final;
|
2022-05-13 17:24:18 +02:00
|
|
|
const td::HttpFile *get_webhook_certificate(const Query *query) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 get_webhook_max_connections(const Query *query) const;
|
|
|
|
static bool get_webhook_fix_ip_address(const Query *query);
|
|
|
|
void do_set_webhook(PromisedQueryPtr query, bool was_deleted);
|
2023-02-22 17:40:25 +01:00
|
|
|
void on_webhook_certificate_copied(td::Status status);
|
2022-10-04 15:26:51 +02:00
|
|
|
void finish_set_webhook(PromisedQueryPtr query);
|
2020-11-03 17:34:10 +01:00
|
|
|
void save_webhook() const;
|
|
|
|
td::string get_webhook_certificate_path() const;
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
void on_webhook_closed(td::Status status);
|
2022-07-01 12:58:28 +02:00
|
|
|
|
2023-07-06 13:47:31 +02:00
|
|
|
void delete_last_send_message_time(td::int64 file_size, double max_delay);
|
|
|
|
|
|
|
|
void do_send_message(object_ptr<td_api::InputMessageContent> input_message_content, PromisedQueryPtr query,
|
|
|
|
bool force = false);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
int64 get_send_message_query_id(PromisedQueryPtr query, bool is_multisend);
|
|
|
|
|
|
|
|
void on_sent_message(object_ptr<td_api::message> &&message, int64 query_id);
|
|
|
|
|
|
|
|
void do_get_file(object_ptr<td_api::file> file, PromisedQueryPtr query);
|
|
|
|
|
|
|
|
bool is_file_being_downloaded(int32 file_id) const;
|
|
|
|
void on_file_download(int32 file_id, td::Result<object_ptr<td_api::file>> r_file);
|
|
|
|
|
2022-07-21 18:00:58 +02:00
|
|
|
void return_stickers(object_ptr<td_api::stickers> stickers, PromisedQueryPtr query);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
void fix_reply_markup_bot_user_ids(object_ptr<td_api::ReplyMarkup> &reply_markup) const;
|
|
|
|
void fix_inline_query_results_bot_user_ids(td::vector<object_ptr<td_api::InputInlineQueryResult>> &results) const;
|
|
|
|
|
|
|
|
void resolve_bot_usernames(PromisedQueryPtr query, td::Promise<PromisedQueryPtr> on_success);
|
2021-09-20 15:58:22 +02:00
|
|
|
void on_resolve_bot_username(const td::string &username, int64 user_id);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
void abort_long_poll(bool from_set_webhook);
|
|
|
|
|
2022-12-12 15:57:22 +01:00
|
|
|
void fail_query_closing(PromisedQueryPtr &&query);
|
2022-10-04 16:05:35 +02:00
|
|
|
|
2023-02-13 13:52:15 +01:00
|
|
|
void fail_query_flood_limit_exceeded(PromisedQueryPtr &&query);
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
void fail_query_conflict(td::Slice message, PromisedQueryPtr &&query);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-12-12 15:57:22 +01:00
|
|
|
struct ClosingError {
|
|
|
|
int code;
|
2022-12-12 17:33:35 +01:00
|
|
|
int retry_after;
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Slice message;
|
2022-12-12 15:57:22 +01:00
|
|
|
};
|
|
|
|
ClosingError get_closing_error();
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static int get_retry_after_time(td::Slice error_message);
|
2022-12-11 21:26:23 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static void fail_query_with_error(PromisedQueryPtr query, int32 error_code, td::Slice error_message,
|
|
|
|
td::Slice default_message = td::Slice());
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static void fail_query_with_error(PromisedQueryPtr &&query, object_ptr<td_api::error> error,
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Slice default_message = td::Slice());
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
class JsonUpdates;
|
|
|
|
void do_get_updates(int32 offset, int32 limit, int32 timeout, PromisedQueryPtr query);
|
|
|
|
|
|
|
|
void long_poll_wakeup(bool force_flag);
|
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
void start_up() final;
|
2020-11-07 17:34:08 +01:00
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
void raw_event(const td::Event::Raw &event) final;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
void loop() final;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-01-25 16:18:44 +01:00
|
|
|
void timeout_expired() final;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
struct UserInfo {
|
|
|
|
enum class Type { Regular, Deleted, Bot, Unknown };
|
|
|
|
Type type = Type::Unknown;
|
|
|
|
|
|
|
|
td::string first_name;
|
|
|
|
td::string last_name;
|
2022-10-31 10:30:11 +01:00
|
|
|
td::vector<td::string> active_usernames;
|
|
|
|
td::string editable_username;
|
2020-11-03 17:34:10 +01:00
|
|
|
td::string language_code;
|
|
|
|
|
2022-03-16 12:49:38 +01:00
|
|
|
object_ptr<td_api::chatPhoto> photo;
|
2020-11-03 17:34:10 +01:00
|
|
|
td::string bio;
|
2024-03-19 14:03:04 +01:00
|
|
|
object_ptr<td_api::businessIntro> business_intro;
|
2024-03-18 12:26:39 +01:00
|
|
|
object_ptr<td_api::businessLocation> business_location;
|
2024-03-18 15:04:42 +01:00
|
|
|
object_ptr<td_api::businessOpeningHours> business_opening_hours;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
bool have_access = false;
|
|
|
|
bool can_join_groups = false;
|
|
|
|
bool can_read_all_group_messages = false;
|
|
|
|
bool is_inline_bot = false;
|
2021-12-07 11:40:47 +01:00
|
|
|
bool has_private_forwards = false;
|
2022-07-21 18:12:28 +02:00
|
|
|
bool has_restricted_voice_and_video_messages = false;
|
2022-05-24 15:56:53 +02:00
|
|
|
bool is_premium = false;
|
2022-05-11 18:46:07 +02:00
|
|
|
bool added_to_attachment_menu = false;
|
2020-11-03 17:34:10 +01:00
|
|
|
};
|
2022-03-16 10:41:12 +01:00
|
|
|
static void add_user(UserInfo *user_info, object_ptr<td_api::user> &&user);
|
|
|
|
UserInfo *add_user_info(int64 user_id);
|
2021-09-20 15:58:22 +02:00
|
|
|
const UserInfo *get_user_info(int64 user_id) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
struct GroupInfo {
|
2022-03-16 12:49:38 +01:00
|
|
|
object_ptr<td_api::chatPhoto> photo;
|
2020-11-03 17:34:10 +01:00
|
|
|
td::string description;
|
|
|
|
td::string invite_link;
|
|
|
|
int32 member_count = 0;
|
|
|
|
bool left = false;
|
|
|
|
bool kicked = false;
|
|
|
|
bool is_active = false;
|
2021-09-20 15:58:22 +02:00
|
|
|
int64 upgraded_to_supergroup_id = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
};
|
2022-03-16 10:41:12 +01:00
|
|
|
static void add_group(GroupInfo *group_info, object_ptr<td_api::basicGroup> &&group);
|
|
|
|
GroupInfo *add_group_info(int64 group_id);
|
2021-09-20 15:58:22 +02:00
|
|
|
const GroupInfo *get_group_info(int64 group_id) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
struct SupergroupInfo {
|
2022-10-31 10:30:11 +01:00
|
|
|
td::vector<td::string> active_usernames;
|
|
|
|
td::string editable_username;
|
2022-03-16 12:49:38 +01:00
|
|
|
object_ptr<td_api::chatPhoto> photo;
|
2020-11-03 17:34:10 +01:00
|
|
|
td::string description;
|
|
|
|
td::string invite_link;
|
|
|
|
int64 sticker_set_id = 0;
|
2024-02-14 16:43:33 +01:00
|
|
|
int64 custom_emoji_sticker_set_id = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 date = 0;
|
|
|
|
int32 slow_mode_delay = 0;
|
2024-02-14 16:16:48 +01:00
|
|
|
int32 unrestrict_boost_count = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
int64 linked_chat_id = 0;
|
|
|
|
object_ptr<td_api::chatLocation> location;
|
|
|
|
object_ptr<td_api::ChatMemberStatus> status;
|
|
|
|
bool is_supergroup = false;
|
2022-10-31 13:36:42 +01:00
|
|
|
bool is_forum = false;
|
2020-11-03 17:34:10 +01:00
|
|
|
bool can_set_sticker_set = false;
|
2023-11-13 16:56:15 +01:00
|
|
|
bool is_all_history_available = false;
|
2020-11-03 17:34:10 +01:00
|
|
|
bool has_location = false;
|
2022-05-13 15:41:12 +02:00
|
|
|
bool join_to_send_messages = false;
|
|
|
|
bool join_by_request = false;
|
2022-12-29 19:06:38 +01:00
|
|
|
bool has_hidden_members = false;
|
2022-12-29 19:11:42 +01:00
|
|
|
bool has_aggressive_anti_spam_enabled = false;
|
2020-11-03 17:34:10 +01:00
|
|
|
};
|
2022-03-16 10:41:12 +01:00
|
|
|
static void add_supergroup(SupergroupInfo *supergroup_info, object_ptr<td_api::supergroup> &&supergroup);
|
|
|
|
SupergroupInfo *add_supergroup_info(int64 supergroup_id);
|
2021-09-20 15:58:22 +02:00
|
|
|
const SupergroupInfo *get_supergroup_info(int64 supergroup_id) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
struct ChatInfo {
|
|
|
|
enum class Type { Private, Group, Supergroup, Unknown };
|
|
|
|
Type type = Type::Unknown;
|
|
|
|
td::string title;
|
2021-02-25 20:00:17 +01:00
|
|
|
int32 message_auto_delete_time = 0;
|
2023-12-21 20:30:01 +01:00
|
|
|
int64 emoji_status_custom_emoji_id = 0;
|
|
|
|
int32 emoji_status_expiration_date = 0;
|
2023-11-13 17:08:21 +01:00
|
|
|
int32 accent_color_id = -1;
|
2023-12-20 14:09:15 +01:00
|
|
|
int32 profile_accent_color_id = -1;
|
2023-11-13 17:15:19 +01:00
|
|
|
int64 background_custom_emoji_id = 0;
|
2023-12-20 14:09:15 +01:00
|
|
|
int64 profile_background_custom_emoji_id = 0;
|
2021-12-07 11:33:44 +01:00
|
|
|
bool has_protected_content = false;
|
2023-12-20 13:14:10 +01:00
|
|
|
object_ptr<td_api::chatAvailableReactionsSome> available_reactions;
|
2022-03-16 12:49:38 +01:00
|
|
|
object_ptr<td_api::chatPhotoInfo> photo_info;
|
2020-11-03 17:34:10 +01:00
|
|
|
object_ptr<td_api::chatPermissions> permissions;
|
|
|
|
union {
|
2021-09-20 15:58:22 +02:00
|
|
|
int64 user_id;
|
|
|
|
int64 group_id;
|
|
|
|
int64 supergroup_id;
|
2020-11-03 17:34:10 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
ChatInfo *add_chat(int64 chat_id);
|
|
|
|
const ChatInfo *get_chat(int64 chat_id) const;
|
|
|
|
|
|
|
|
enum class ChatType { Private, Group, Supergroup, Channel, Unknown };
|
|
|
|
|
|
|
|
ChatType get_chat_type(int64 chat_id) const;
|
|
|
|
|
|
|
|
td::string get_chat_description(int64 chat_id) const;
|
|
|
|
|
|
|
|
struct MessageInfo {
|
|
|
|
int64 id = 0;
|
2021-09-20 15:58:22 +02:00
|
|
|
int64 sender_user_id = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
int64 sender_chat_id = 0;
|
|
|
|
int64 chat_id = 0;
|
2022-10-31 15:09:34 +01:00
|
|
|
int64 message_thread_id = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 date = 0;
|
|
|
|
int32 edit_date = 0;
|
|
|
|
int32 initial_send_date = 0;
|
2024-02-14 15:53:10 +01:00
|
|
|
int32 sender_boost_count = 0;
|
2023-11-13 20:41:02 +01:00
|
|
|
object_ptr<td_api::MessageOrigin> forward_origin;
|
2020-11-03 17:34:10 +01:00
|
|
|
td::string author_signature;
|
2024-03-18 09:21:43 +01:00
|
|
|
td::unique_ptr<MessageInfo> business_reply_to_message;
|
2023-11-05 19:54:58 +01:00
|
|
|
object_ptr<td_api::messageReplyToMessage> reply_to_message;
|
2024-02-15 09:20:57 +01:00
|
|
|
object_ptr<td_api::messageReplyToStory> reply_to_story;
|
2020-11-03 17:34:10 +01:00
|
|
|
int64 media_album_id = 0;
|
2021-09-20 15:58:22 +02:00
|
|
|
int64 via_bot_user_id = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
object_ptr<td_api::MessageContent> content;
|
|
|
|
object_ptr<td_api::ReplyMarkup> reply_markup;
|
2024-03-14 20:51:02 +01:00
|
|
|
td::string business_connection_id;
|
2024-03-18 15:50:16 +01:00
|
|
|
int64 sender_business_bot_user_id = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-12-07 11:25:01 +01:00
|
|
|
bool can_be_saved = false;
|
2021-12-07 10:56:22 +01:00
|
|
|
bool is_automatic_forward = false;
|
2022-10-31 15:14:23 +01:00
|
|
|
bool is_topic_message = false;
|
2020-11-03 17:34:10 +01:00
|
|
|
mutable bool is_content_changed = false;
|
|
|
|
};
|
|
|
|
|
2024-03-14 13:44:44 +01:00
|
|
|
struct BusinessConnection {
|
|
|
|
td::string id_;
|
|
|
|
int64 user_id_ = 0;
|
|
|
|
int64 user_chat_id_ = 0;
|
|
|
|
int32 date_ = 0;
|
|
|
|
bool can_reply_ = false;
|
|
|
|
bool is_enabled_ = false;
|
|
|
|
};
|
|
|
|
const BusinessConnection *add_business_connection(object_ptr<td_api::businessConnection> &&business_connection,
|
|
|
|
bool from_update);
|
|
|
|
const BusinessConnection *get_business_connection(const td::string &connection_id) const;
|
|
|
|
|
2023-11-05 20:08:06 +01:00
|
|
|
static int64 get_same_chat_reply_to_message_id(const td_api::messageReplyToMessage *reply_to,
|
|
|
|
int64 message_thread_id);
|
2023-07-19 22:54:47 +02:00
|
|
|
|
2023-11-05 20:08:06 +01:00
|
|
|
static int64 get_same_chat_reply_to_message_id(const object_ptr<td_api::MessageReplyTo> &reply_to,
|
|
|
|
int64 message_thread_id);
|
2023-11-05 19:54:58 +01:00
|
|
|
|
|
|
|
static int64 get_same_chat_reply_to_message_id(const object_ptr<td_api::message> &message);
|
|
|
|
|
2023-11-09 16:24:50 +01:00
|
|
|
static int64 get_same_chat_reply_to_message_id(const MessageInfo *message_info);
|
|
|
|
|
2023-11-05 19:54:58 +01:00
|
|
|
static void drop_internal_reply_to_message_in_another_chat(object_ptr<td_api::message> &message);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Slice get_sticker_type(const object_ptr<td_api::StickerType> &type);
|
2022-07-21 17:17:23 +02:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Result<object_ptr<td_api::StickerType>> get_sticker_type(td::Slice type);
|
2022-07-21 17:17:23 +02:00
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static td::CSlice get_callback_data(const object_ptr<td_api::InlineKeyboardButtonType> &type);
|
|
|
|
|
|
|
|
static bool are_equal_inline_keyboard_buttons(const td_api::inlineKeyboardButton *lhs,
|
|
|
|
const td_api::inlineKeyboardButton *rhs);
|
|
|
|
|
|
|
|
static bool are_equal_inline_keyboards(const td_api::replyMarkupInlineKeyboard *lhs,
|
|
|
|
const td_api::replyMarkupInlineKeyboard *rhs);
|
|
|
|
|
2024-03-14 14:09:23 +01:00
|
|
|
static void set_message_reply_markup(MessageInfo *message_info, object_ptr<td_api::ReplyMarkup> &&reply_markup);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static int64 get_sticker_set_id(const object_ptr<td_api::MessageContent> &content);
|
|
|
|
|
|
|
|
bool have_sticker_set_name(int64 sticker_set_id) const;
|
|
|
|
|
2022-08-21 13:44:57 +02:00
|
|
|
td::string get_sticker_set_name(int64 sticker_set_id) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
int64 choose_added_member_id(const td_api::messageChatAddMembers *message_add_members) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
bool need_skip_update_message(int64 chat_id, const object_ptr<td_api::message> &message, bool is_edited) const;
|
|
|
|
|
|
|
|
void json_store_file(td::JsonObjectScope &object, const td_api::file *file, bool with_path = false) const;
|
|
|
|
|
|
|
|
void json_store_thumbnail(td::JsonObjectScope &object, const td_api::thumbnail *thumbnail) const;
|
|
|
|
|
|
|
|
static void json_store_callback_query_payload(td::JsonObjectScope &object,
|
|
|
|
const td_api::CallbackQueryPayload *payload);
|
|
|
|
|
2022-04-03 12:29:57 +02:00
|
|
|
static void json_store_administrator_rights(td::JsonObjectScope &object,
|
|
|
|
const td_api::chatAdministratorRights *rights, ChatType chat_type);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static void json_store_permissions(td::JsonObjectScope &object, const td_api::chatPermissions *permissions);
|
|
|
|
|
2022-11-03 18:30:14 +01:00
|
|
|
td::unique_ptr<MessageInfo> delete_message(int64 chat_id, int64 message_id, bool only_from_cache);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
void add_new_message(object_ptr<td_api::message> &&message, bool is_edited);
|
2022-11-22 11:34:16 +01:00
|
|
|
|
|
|
|
void process_new_message_queue(int64 chat_id, int state);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2024-03-18 10:36:19 +01:00
|
|
|
void add_new_business_message(object_ptr<td_api::updateNewBusinessMessage> &&update);
|
|
|
|
|
|
|
|
void add_business_message_edited(object_ptr<td_api::updateBusinessMessageEdited> &&update);
|
|
|
|
|
|
|
|
void process_new_business_message_queue(const td::string &connection_id);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
struct FullMessageId {
|
|
|
|
int64 chat_id;
|
|
|
|
int64 message_id;
|
|
|
|
|
|
|
|
FullMessageId() : chat_id(0), message_id(0) {
|
|
|
|
}
|
|
|
|
FullMessageId(int64 chat_id, int64 message_id) : chat_id(chat_id), message_id(message_id) {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const FullMessageId &other) const {
|
|
|
|
return chat_id == other.chat_id && message_id == other.message_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FullMessageIdHash {
|
2022-11-23 21:43:05 +01:00
|
|
|
td::uint32 operator()(FullMessageId full_message_id) const {
|
2023-02-22 17:50:53 +01:00
|
|
|
return td::Hash<int64>()(full_message_id.chat_id) * 2023654985u + td::Hash<int64>()(full_message_id.message_id);
|
2020-11-03 17:34:10 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
FullMessageId add_message(object_ptr<td_api::message> &&message, bool force_update_content = false);
|
2024-03-14 14:09:23 +01:00
|
|
|
void init_message(MessageInfo *message_info, object_ptr<td_api::message> &&message, bool force_update_content);
|
2022-11-22 11:34:16 +01:00
|
|
|
const MessageInfo *get_message(int64 chat_id, int64 message_id, bool force_cache) const;
|
2020-11-03 17:34:10 +01:00
|
|
|
MessageInfo *get_message_editable(int64 chat_id, int64 message_id);
|
|
|
|
|
2024-03-14 20:51:02 +01:00
|
|
|
td::unique_ptr<MessageInfo> create_business_message(td::string business_connection_id,
|
|
|
|
object_ptr<td_api::businessMessage> &&message);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
void update_message_content(int64 chat_id, int64 message_id, object_ptr<td_api::MessageContent> &&content);
|
|
|
|
|
|
|
|
void on_update_message_edited(int64 chat_id, int64 message_id, int32 edit_date,
|
|
|
|
object_ptr<td_api::ReplyMarkup> &&reply_markup);
|
|
|
|
|
|
|
|
int32 get_unix_time() const;
|
|
|
|
|
|
|
|
static int64 as_tdlib_message_id(int32 message_id);
|
|
|
|
|
|
|
|
static int32 as_client_message_id(int64 message_id);
|
|
|
|
|
2023-11-13 17:51:05 +01:00
|
|
|
static int32 as_client_message_id_unchecked(int64 message_id);
|
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
static int64 get_supergroup_chat_id(int64 supergroup_id);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
static int64 get_basic_group_chat_id(int64 basic_group_id);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
void add_update_poll(object_ptr<td_api::updatePoll> &&update);
|
|
|
|
|
|
|
|
void add_update_poll_answer(object_ptr<td_api::updatePollAnswer> &&update);
|
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
void add_new_inline_query(int64 inline_query_id, int64 sender_user_id, object_ptr<td_api::location> location,
|
2020-12-08 01:57:25 +01:00
|
|
|
object_ptr<td_api::ChatType> chat_type, const td::string &query, const td::string &offset);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
void add_new_chosen_inline_result(int64 sender_user_id, object_ptr<td_api::location> location,
|
2020-11-03 17:34:10 +01:00
|
|
|
const td::string &query, const td::string &result_id,
|
|
|
|
const td::string &inline_message_id);
|
|
|
|
|
|
|
|
void add_new_callback_query(object_ptr<td_api::updateNewCallbackQuery> &&query);
|
2022-11-22 11:34:16 +01:00
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
void process_new_callback_query_queue(int64 user_id, int state);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
void add_new_inline_callback_query(object_ptr<td_api::updateNewInlineCallbackQuery> &&query);
|
|
|
|
|
|
|
|
void add_new_shipping_query(object_ptr<td_api::updateNewShippingQuery> &&query);
|
|
|
|
|
|
|
|
void add_new_pre_checkout_query(object_ptr<td_api::updateNewPreCheckoutQuery> &&query);
|
|
|
|
|
|
|
|
void add_new_custom_event(object_ptr<td_api::updateNewCustomEvent> &&event);
|
|
|
|
|
|
|
|
void add_new_custom_query(object_ptr<td_api::updateNewCustomQuery> &&query);
|
|
|
|
|
2021-02-26 01:02:26 +01:00
|
|
|
void add_update_chat_member(object_ptr<td_api::updateChatMember> &&update);
|
|
|
|
|
2021-11-04 11:35:43 +01:00
|
|
|
void add_update_chat_join_request(object_ptr<td_api::updateNewChatJoinRequest> &&update);
|
|
|
|
|
2023-11-13 17:51:05 +01:00
|
|
|
void add_update_chat_boost(object_ptr<td_api::updateChatBoost> &&update);
|
|
|
|
|
2023-12-20 15:35:18 +01:00
|
|
|
void add_update_message_reaction(object_ptr<td_api::updateMessageReaction> &&update);
|
|
|
|
|
2023-12-20 15:45:26 +01:00
|
|
|
void add_update_message_reaction_count(object_ptr<td_api::updateMessageReactions> &&update);
|
|
|
|
|
2024-03-14 13:09:47 +01:00
|
|
|
void add_update_business_connection(object_ptr<td_api::updateBusinessConnection> &&update);
|
|
|
|
|
2024-03-18 11:58:44 +01:00
|
|
|
void add_update_business_messages_deleted(object_ptr<td_api::updateBusinessMessagesDeleted> &&update);
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
// append only before Size
|
|
|
|
enum class UpdateType : int32 {
|
|
|
|
Message,
|
|
|
|
EditedMessage,
|
|
|
|
ChannelPost,
|
|
|
|
EditedChannelPost,
|
|
|
|
InlineQuery,
|
|
|
|
ChosenInlineResult,
|
|
|
|
CallbackQuery,
|
|
|
|
CustomEvent,
|
|
|
|
CustomQuery,
|
|
|
|
ShippingQuery,
|
|
|
|
PreCheckoutQuery,
|
|
|
|
Poll,
|
|
|
|
PollAnswer,
|
2021-02-27 01:40:58 +01:00
|
|
|
MyChatMember,
|
2021-02-26 01:02:26 +01:00
|
|
|
ChatMember,
|
2021-11-04 11:35:43 +01:00
|
|
|
ChatJoinRequest,
|
2023-11-13 17:51:05 +01:00
|
|
|
ChatBoostUpdated,
|
|
|
|
ChatBoostRemoved,
|
2023-12-20 15:35:18 +01:00
|
|
|
MessageReaction,
|
2023-12-20 15:45:26 +01:00
|
|
|
MessageReactionCount,
|
2024-03-14 13:09:47 +01:00
|
|
|
BusinessConnection,
|
2024-03-18 10:36:19 +01:00
|
|
|
BusinessMessage,
|
|
|
|
EditedBusinessMessage,
|
2024-03-18 11:58:44 +01:00
|
|
|
BusinessMessagesDeleted,
|
2020-11-03 17:34:10 +01:00
|
|
|
Size
|
|
|
|
};
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::Slice get_update_type_name(UpdateType update_type);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static td::uint32 get_allowed_update_types(td::MutableSlice allowed_updates, bool is_internal);
|
|
|
|
|
|
|
|
bool update_allowed_update_types(const Query *query);
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void add_update(UpdateType update_type, const T &update, int32 timeout, int64 webhook_queue_id);
|
|
|
|
|
|
|
|
void add_update_impl(UpdateType update_type, const td::VirtuallyJsonable &update, int32 timeout,
|
|
|
|
int64 webhook_queue_id);
|
|
|
|
|
|
|
|
std::size_t get_pending_update_count() const;
|
|
|
|
|
2022-03-18 12:03:14 +01:00
|
|
|
void update_last_synchronization_error_date();
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
static bool is_chat_member(const object_ptr<td_api::ChatMemberStatus> &status);
|
|
|
|
|
|
|
|
static td::string get_chat_member_status(const object_ptr<td_api::ChatMemberStatus> &status);
|
|
|
|
|
|
|
|
static td::string get_passport_element_type(int32 id);
|
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static object_ptr<td_api::PassportElementType> get_passport_element_type(td::Slice type);
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
bool have_message_access(int64 chat_id) const;
|
|
|
|
|
2023-12-20 15:45:26 +01:00
|
|
|
// by default ChatMember, MessageReaction, and MessageReactionCount updates are disabled
|
|
|
|
static constexpr td::uint32 DEFAULT_ALLOWED_UPDATE_TYPES =
|
|
|
|
(1 << static_cast<int32>(UpdateType::Size)) - 1 - (1 << static_cast<int32>(UpdateType::ChatMember)) -
|
|
|
|
(1 << static_cast<int32>(UpdateType::MessageReaction)) -
|
|
|
|
(1 << static_cast<int32>(UpdateType::MessageReactionCount));
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
object_ptr<td_api::AuthorizationState> authorization_state_;
|
|
|
|
bool was_authorized_ = false;
|
|
|
|
bool closing_ = false;
|
|
|
|
bool logging_out_ = false;
|
2021-02-01 13:44:32 +01:00
|
|
|
bool is_api_id_invalid_ = false;
|
2020-11-03 17:34:10 +01:00
|
|
|
bool need_close_ = false;
|
|
|
|
bool clear_tqueue_ = false;
|
|
|
|
|
|
|
|
td::ActorShared<> parent_;
|
|
|
|
td::string bot_token_;
|
|
|
|
td::string bot_token_with_dc_;
|
|
|
|
td::string bot_token_id_;
|
|
|
|
bool is_test_dc_;
|
|
|
|
int64 tqueue_id_;
|
2020-11-21 15:38:11 +01:00
|
|
|
double start_time_ = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
int64 my_id_ = -1;
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 authorization_date_ = -1;
|
2022-12-12 17:33:35 +01:00
|
|
|
double next_authorization_time_ = 0;
|
|
|
|
|
|
|
|
int32 prev_retry_after = 0;
|
|
|
|
td::string retry_after_error_message;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2021-09-20 15:58:22 +02:00
|
|
|
int64 group_anonymous_bot_user_id_ = 0;
|
2021-12-09 16:48:39 +01:00
|
|
|
int64 channel_bot_user_id_ = 0;
|
2021-09-20 15:58:22 +02:00
|
|
|
int64 service_notifications_user_id_ = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-02-22 17:40:25 +01:00
|
|
|
static td::FlatHashMap<td::string, td::Status (Client::*)(PromisedQueryPtr &query)> methods_;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-08-21 13:44:57 +02:00
|
|
|
td::WaitFreeHashMap<FullMessageId, td::unique_ptr<MessageInfo>, FullMessageIdHash> messages_;
|
|
|
|
td::WaitFreeHashMap<int64, td::unique_ptr<UserInfo>> users_;
|
|
|
|
td::WaitFreeHashMap<int64, td::unique_ptr<GroupInfo>> groups_;
|
|
|
|
td::WaitFreeHashMap<int64, td::unique_ptr<SupergroupInfo>> supergroups_;
|
|
|
|
td::WaitFreeHashMap<int64, td::unique_ptr<ChatInfo>> chats_;
|
2024-03-14 13:44:44 +01:00
|
|
|
td::WaitFreeHashMap<td::string, td::unique_ptr<BusinessConnection>> business_connections_;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-03-16 10:41:12 +01:00
|
|
|
td::FlatHashMap<int32, td::vector<PromisedQueryPtr>> file_download_listeners_;
|
|
|
|
td::FlatHashSet<int32> download_started_file_ids_;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
struct YetUnsentMessage {
|
|
|
|
int64 send_message_query_id = 0;
|
|
|
|
};
|
2022-03-16 10:41:12 +01:00
|
|
|
td::FlatHashMap<FullMessageId, YetUnsentMessage, FullMessageIdHash> yet_unsent_messages_;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-03-16 10:41:12 +01:00
|
|
|
td::FlatHashMap<int64, int32> yet_unsent_message_count_; // chat_id -> count
|
2021-10-01 13:52:47 +02:00
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
struct PendingSendMessageQuery {
|
|
|
|
PromisedQueryPtr query;
|
|
|
|
bool is_multisend = false;
|
2022-05-30 20:32:01 +02:00
|
|
|
int32 total_message_count = 0;
|
2021-09-20 15:58:22 +02:00
|
|
|
int32 awaited_message_count = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
td::vector<td::string> messages;
|
|
|
|
object_ptr<td_api::error> error;
|
|
|
|
};
|
2022-03-16 10:41:12 +01:00
|
|
|
td::FlatHashMap<int64, td::unique_ptr<PendingSendMessageQuery>>
|
2020-11-03 17:34:10 +01:00
|
|
|
pending_send_message_queries_; // query_id -> PendingSendMessageQuery
|
|
|
|
int64 current_send_message_query_id_ = 1;
|
|
|
|
|
|
|
|
struct NewMessage {
|
|
|
|
object_ptr<td_api::message> message;
|
|
|
|
bool is_edited = false;
|
|
|
|
|
|
|
|
NewMessage(object_ptr<td_api::message> &&message, bool is_edited)
|
|
|
|
: message(std::move(message)), is_edited(is_edited) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
struct NewMessageQueue {
|
|
|
|
std::queue<NewMessage> queue_;
|
|
|
|
bool has_active_request_ = false;
|
|
|
|
};
|
2022-03-16 10:41:12 +01:00
|
|
|
td::FlatHashMap<int64, NewMessageQueue> new_message_queues_; // chat_id -> queue
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2024-03-18 10:36:19 +01:00
|
|
|
struct NewBusinessMessage {
|
|
|
|
object_ptr<td_api::businessMessage> message_;
|
|
|
|
bool is_edited_ = false;
|
|
|
|
|
|
|
|
NewBusinessMessage(object_ptr<td_api::businessMessage> &&message, bool is_edited)
|
|
|
|
: message_(std::move(message)), is_edited_(is_edited) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
struct NewBusinessMessageQueue {
|
|
|
|
std::queue<NewBusinessMessage> queue_;
|
|
|
|
bool has_active_request_ = false;
|
|
|
|
};
|
|
|
|
td::FlatHashMap<td::string, NewBusinessMessageQueue> new_business_message_queues_; // connection_id -> queue
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
struct NewCallbackQueryQueue {
|
|
|
|
std::queue<object_ptr<td_api::updateNewCallbackQuery>> queue_;
|
|
|
|
bool has_active_request_ = false;
|
|
|
|
};
|
2022-03-16 10:41:12 +01:00
|
|
|
td::FlatHashMap<int64, NewCallbackQueryQueue> new_callback_query_queues_; // sender_user_id -> queue
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2022-08-21 13:44:57 +02:00
|
|
|
td::WaitFreeHashMap<int64, td::string> sticker_set_names_;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-07-06 13:47:31 +02:00
|
|
|
td::WaitFreeHashMap<int64, double> last_send_message_time_;
|
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
struct BotUserIds {
|
|
|
|
int64 default_bot_user_id_ = 0;
|
|
|
|
int64 cur_temp_bot_user_id_ = 1;
|
|
|
|
td::FlatHashMap<td::string, int64> bot_user_ids_;
|
|
|
|
td::FlatHashSet<td::string> unresolved_bot_usernames_;
|
|
|
|
};
|
|
|
|
BotUserIds bot_user_ids_;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
struct PendingBotResolveQuery {
|
|
|
|
std::size_t pending_resolve_count = 0;
|
|
|
|
PromisedQueryPtr query;
|
|
|
|
td::Promise<PromisedQueryPtr> on_success;
|
|
|
|
};
|
2022-03-16 10:41:12 +01:00
|
|
|
td::FlatHashMap<int64, PendingBotResolveQuery> pending_bot_resolve_queries_;
|
2020-11-03 17:34:10 +01:00
|
|
|
int64 current_bot_resolve_query_id_ = 1;
|
|
|
|
|
2023-07-06 13:01:14 +02:00
|
|
|
td::FlatHashMap<td::string, td::vector<int64>> awaiting_bot_resolve_queries_;
|
|
|
|
td::FlatHashMap<int64, int64> temp_to_real_bot_user_id_;
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
td::string dir_;
|
|
|
|
td::ActorOwn<td::ClientActor> td_client_;
|
|
|
|
td::ActorContext context_;
|
|
|
|
std::queue<PromisedQueryPtr> cmd_queue_;
|
|
|
|
td::vector<object_ptr<td_api::Object>> pending_updates_;
|
2022-03-16 10:52:34 +01:00
|
|
|
td::Container<td::unique_ptr<TdQueryCallback>> handlers_;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
|
|
|
static constexpr int32 LONG_POLL_MAX_TIMEOUT = 50;
|
2022-03-24 09:49:55 +01:00
|
|
|
static constexpr double LONG_POLL_MAX_DELAY = 0.002;
|
|
|
|
static constexpr double LONG_POLL_WAIT_AFTER = 0.001;
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 long_poll_limit_ = 0;
|
|
|
|
int32 long_poll_offset_ = 0;
|
|
|
|
bool long_poll_was_wakeup_ = false;
|
|
|
|
double long_poll_hard_timeout_ = 0;
|
|
|
|
td::Slot long_poll_slot_;
|
|
|
|
PromisedQueryPtr long_poll_query_;
|
|
|
|
|
|
|
|
static constexpr int32 BOT_UPDATES_WARNING_DELAY = 30;
|
2020-11-21 15:38:11 +01:00
|
|
|
double next_bot_updates_warning_time_ = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
bool was_bot_updates_warning_ = false;
|
|
|
|
|
|
|
|
td::uint32 allowed_update_types_ = DEFAULT_ALLOWED_UPDATE_TYPES;
|
|
|
|
|
|
|
|
bool has_webhook_certificate_ = false;
|
|
|
|
enum class WebhookQueryType { Cancel, Verify };
|
|
|
|
WebhookQueryType webhook_query_type_ = WebhookQueryType::Cancel;
|
|
|
|
td::ActorOwn<WebhookActor> webhook_id_;
|
|
|
|
PromisedQueryPtr webhook_set_query_;
|
2022-10-04 15:26:51 +02:00
|
|
|
PromisedQueryPtr active_webhook_set_query_;
|
2020-11-03 17:34:10 +01:00
|
|
|
td::string webhook_url_;
|
2020-11-21 15:38:11 +01:00
|
|
|
double webhook_set_time_ = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 webhook_max_connections_ = 0;
|
|
|
|
td::string webhook_ip_address_;
|
|
|
|
bool webhook_fix_ip_address_ = false;
|
2022-05-13 15:39:32 +02:00
|
|
|
td::string webhook_secret_token_;
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 last_webhook_error_date_ = 0;
|
2023-02-22 17:40:25 +01:00
|
|
|
td::Status last_webhook_error_;
|
2020-11-21 15:38:11 +01:00
|
|
|
double next_allowed_set_webhook_time_ = 0;
|
|
|
|
double next_set_webhook_logging_time_ = 0;
|
|
|
|
double next_webhook_is_not_modified_warning_time_ = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
std::size_t last_pending_update_count_ = MIN_PENDING_UPDATES_WARNING;
|
|
|
|
|
|
|
|
double local_unix_time_difference_ = 0; // Unix time - now()
|
|
|
|
|
2022-03-18 12:03:14 +01:00
|
|
|
double disconnection_time_ = 0; // the time when Connection state changed from "Ready", or 0 if it is "Ready"
|
|
|
|
double last_update_creation_time_ = 0; // the time when the last update was added
|
|
|
|
int32 last_synchronization_error_date_ = 0; // the date of the last connection error
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
int32 previous_get_updates_offset_ = -1;
|
2020-11-21 15:38:11 +01:00
|
|
|
double previous_get_updates_start_time_ = 0;
|
|
|
|
double previous_get_updates_finish_time_ = 0;
|
2021-01-15 14:54:14 +01:00
|
|
|
double next_get_updates_conflict_time_ = 0;
|
2020-11-03 17:34:10 +01:00
|
|
|
|
2023-07-24 20:41:15 +02:00
|
|
|
int32 log_in_date_ = 0;
|
|
|
|
|
2022-11-30 15:37:35 +01:00
|
|
|
int32 flood_limited_query_count_ = 0;
|
|
|
|
double next_flood_limit_warning_time_ = 0;
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
td::uint64 webhook_generation_ = 1;
|
|
|
|
|
2022-09-29 19:28:44 +02:00
|
|
|
UpdateType delayed_update_type_ = UpdateType::Size;
|
|
|
|
int64 delayed_chat_id_ = 0;
|
|
|
|
int32 delayed_min_date_ = 0;
|
|
|
|
int32 delayed_max_date_ = 0;
|
|
|
|
int32 delayed_max_time_ = 0;
|
|
|
|
size_t delayed_update_count_ = 0;
|
|
|
|
|
2020-11-03 17:34:10 +01:00
|
|
|
std::shared_ptr<const ClientParameters> parameters_;
|
|
|
|
|
|
|
|
td::ActorId<BotStatActor> stat_actor_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace telegram_bot_api
|