mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-06-01 19:06:31 +02:00
Compare commits
97 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6f785fd26b | ||
|
0bc23e3830 | ||
|
dd075ae89f | ||
|
faa723716f | ||
|
ffcc85392c | ||
|
d2415a9191 | ||
|
1bf69f7abb | ||
|
a38d9260af | ||
|
baa0546c31 | ||
|
d3300e9ba3 | ||
|
f19e58645e | ||
|
50bb07bc46 | ||
|
668ea399eb | ||
|
fa489a4979 | ||
|
9aedc15f76 | ||
|
7575257ca6 | ||
|
7d84c0a0d8 | ||
|
92b7a6a556 | ||
|
81b2c0e550 | ||
|
9c1ecb749b | ||
|
ce1474d5ab | ||
|
3161f9a00b | ||
|
e6e6cbc72f | ||
|
253d3acddc | ||
|
5dce30bc20 | ||
|
aa0f369132 | ||
|
de0d0ad75d | ||
|
94bfd307f8 | ||
|
19a7da41b2 | ||
|
e117cfa33f | ||
|
1084ebd5c8 | ||
|
49df33acd7 | ||
|
4b13a450ae | ||
|
ab0f7878bb | ||
|
a7f7cd0a7d | ||
|
05d9cd05b7 | ||
|
c3999a2144 | ||
|
ad84bfc214 | ||
|
34f9b8a860 | ||
|
121e2d8a18 | ||
|
d02a9fe5c3 | ||
|
a2a226ac42 | ||
|
0da8d14430 | ||
|
d7d127430f | ||
|
c57bb6830b | ||
|
80406b7028 | ||
|
8fe04fc33a | ||
|
1a34273163 | ||
|
8990b79e9e | ||
|
a35ff4543b | ||
|
b3eb1acc91 | ||
|
c24c0a2dae | ||
|
bf66a41987 | ||
|
96d0d1c668 | ||
|
0566e21f93 | ||
|
34ed6c3512 | ||
|
9447ce07ea | ||
|
f169ae654c | ||
|
9a7a293a84 | ||
|
d836f78e41 | ||
|
f15bc7396e | ||
|
9c413c7f11 | ||
|
5d88023dd1 | ||
|
9e7b09ff0a | ||
|
d5783a1545 | ||
|
2b43e08dca | ||
|
11d19baa2e | ||
|
df1fe4c05f | ||
|
1ec733a3f8 | ||
|
4e8ba65838 | ||
|
e58e8d3989 | ||
|
95ff757c73 | ||
|
70670d7217 | ||
|
87cdeaadb6 | ||
|
18b5f287f7 | ||
|
1cab23c1f1 | ||
|
89383695ed | ||
|
8b2b62bd6f | ||
|
375b5d1b7c | ||
|
980f98299f | ||
|
0868ee6beb | ||
|
a78edf0703 | ||
|
2bbaf87fea | ||
|
9f688af4fb | ||
|
c927614964 | ||
|
ec8e44de5a | ||
|
f4422f5976 | ||
|
afd30f2cfa | ||
|
51fba26f78 | ||
|
736411c113 | ||
|
1fa5c2c31a | ||
|
9ce2f7df4c | ||
|
68dc4f54a5 | ||
|
c8e50b8011 | ||
|
a9a0140476 | ||
|
84e512c2e4 | ||
|
d9c00c452b |
|
@ -6,7 +6,7 @@ if (POLICY CMP0065)
|
||||||
cmake_policy(SET CMP0065 NEW)
|
cmake_policy(SET CMP0065 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(TelegramBotApi VERSION 6.7.1 LANGUAGES CXX)
|
project(TelegramBotApi VERSION 7.0 LANGUAGES CXX)
|
||||||
|
|
||||||
if (POLICY CMP0069)
|
if (POLICY CMP0069)
|
||||||
option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.")
|
option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.")
|
||||||
|
|
22
README.md
22
README.md
|
@ -54,17 +54,6 @@ Get the member list of a supergroup or channel
|
||||||
|
|
||||||
###### Returns `ChatMember`
|
###### Returns `ChatMember`
|
||||||
|
|
||||||
##### Method `deleteMessages`
|
|
||||||
Delete all the messages with message_id in range between `start` and `end`.
|
|
||||||
The `start` parameter MUST be less than the `end` parameter
|
|
||||||
Both `start` and `end` must be positive non zero numbers
|
|
||||||
The method will always return `true` as a result, even if the messages cannot be deleted
|
|
||||||
This method does not work on private chat or normal groups
|
|
||||||
It is not suggested to delete more than 200 messages per call
|
|
||||||
|
|
||||||
**NOTE**
|
|
||||||
The maximum number of messages to be deleted in a single batch is determined by the `max-batch-operations` parameter and is 10000 by default
|
|
||||||
|
|
||||||
###### Parameters
|
###### Parameters
|
||||||
- `chat_id` Chat id
|
- `chat_id` Chat id
|
||||||
- `start` First message id to delete
|
- `start` First message id to delete
|
||||||
|
@ -122,6 +111,17 @@ _For Docker containers, `$TELEGRAM_VERBOSITY` can be set._
|
||||||
##### Method `getChat`
|
##### Method `getChat`
|
||||||
The command `getChat` will also try to resolve the username online, if it can't be found locally
|
The command `getChat` will also try to resolve the username online, if it can't be found locally
|
||||||
|
|
||||||
|
##### Method `deleteMessages`
|
||||||
|
The command `deleteMessages` can also delete all the messages with message_id in range between `start` and `end`.
|
||||||
|
The `start` parameter MUST be less than the `end` parameter
|
||||||
|
Both `start` and `end` must be positive non-zero numbers
|
||||||
|
The method will always return `true` as a result, even if the messages cannot be deleted
|
||||||
|
This method does not work on private chat or normal groups
|
||||||
|
It is not suggested to delete more than 200 messages per call
|
||||||
|
|
||||||
|
**NOTE**
|
||||||
|
The maximum number of messages to be deleted in a single batch is determined by the `max-batch-operations` parameter and is 10000 by default
|
||||||
|
|
||||||
##### Object `Message`
|
##### Object `Message`
|
||||||
The `Message` object now has two new fields:
|
The `Message` object now has two new fields:
|
||||||
- `views`: how many views has the message (usually the views are shown only for channel messages)
|
- `views`: how many views has the message (usually the views are shown only for channel messages)
|
||||||
|
|
2
td
2
td
|
@ -1 +1 @@
|
||||||
Subproject commit 328b8649d859c5ed4088a875cbb059db6029dc0d
|
Subproject commit 27c3eaeb4964bd5f18d8488e354abde1a4383e49
|
|
@ -547,16 +547,23 @@ paths:
|
||||||
/deleteMessages:
|
/deleteMessages:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- added
|
- modified
|
||||||
description: |-
|
description: |-
|
||||||
Delete all the messages with message_id in range between start and end.
|
Use this method to delete multiple messages simultaneously.
|
||||||
The start parameter MUST be less than the end parameter
|
This method can delete a set of message ids, or a range of message ids.
|
||||||
Both start and end must be positive non zero numbers
|
|
||||||
The method will always return true as a result, even if the messages cannot be deleted
|
If you specify "message_ids", this method tries to delete the specified set of ids:
|
||||||
This method does not work on private chat or normal groups It is not suggested to delete more than 200 messages per call.
|
If some of the specified messages can't be found, they are skipped.
|
||||||
|
Returns True on success.
|
||||||
|
|
||||||
*NOTE*
|
If you specify "start" and "end", this method deletes all the messages with message_id in range between start and end:
|
||||||
The maximum number of messages to be deleted in a single batch is determined by the max-batch-operations parameter and is 10000 by default.
|
The start parameter MUST be less than the end parameter
|
||||||
|
Both start and end must be positive non zero numbers
|
||||||
|
The method will always return true as a result, even if the messages cannot be deleted
|
||||||
|
This method does not work on private chat or normal groups It is not suggested to delete more than 200 messages per call.
|
||||||
|
|
||||||
|
*NOTE*
|
||||||
|
The maximum number of messages to be deleted in a single batch is determined by the max-batch-operations parameter and is 10000 by default.
|
||||||
requestBody:
|
requestBody:
|
||||||
content:
|
content:
|
||||||
application/x-www-form-urlencoded:
|
application/x-www-form-urlencoded:
|
||||||
|
@ -568,6 +575,10 @@ paths:
|
||||||
anyOf:
|
anyOf:
|
||||||
- type: integer
|
- type: integer
|
||||||
- type: string
|
- type: string
|
||||||
|
message_ids:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
start:
|
start:
|
||||||
description: First message id to delete
|
description: First message id to delete
|
||||||
type: integer
|
type: integer
|
||||||
|
@ -576,8 +587,6 @@ paths:
|
||||||
type: integer
|
type: integer
|
||||||
required:
|
required:
|
||||||
- chat_id
|
- chat_id
|
||||||
- start
|
|
||||||
- end
|
|
||||||
multipart/form-data:
|
multipart/form-data:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
|
@ -587,6 +596,10 @@ paths:
|
||||||
anyOf:
|
anyOf:
|
||||||
- type: integer
|
- type: integer
|
||||||
- type: string
|
- type: string
|
||||||
|
message_ids:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
start:
|
start:
|
||||||
description: First message id to delete
|
description: First message id to delete
|
||||||
type: integer
|
type: integer
|
||||||
|
@ -595,8 +608,6 @@ paths:
|
||||||
type: integer
|
type: integer
|
||||||
required:
|
required:
|
||||||
- chat_id
|
- chat_id
|
||||||
- start
|
|
||||||
- end
|
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
|
@ -606,6 +617,10 @@ paths:
|
||||||
anyOf:
|
anyOf:
|
||||||
- type: integer
|
- type: integer
|
||||||
- type: string
|
- type: string
|
||||||
|
message_ids:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
start:
|
start:
|
||||||
description: First message id to delete
|
description: First message id to delete
|
||||||
type: integer
|
type: integer
|
||||||
|
@ -614,12 +629,10 @@ paths:
|
||||||
type: integer
|
type: integer
|
||||||
required:
|
required:
|
||||||
- chat_id
|
- chat_id
|
||||||
- start
|
|
||||||
- end
|
|
||||||
required: true
|
required: true
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: ''
|
description: 'Request was successful, the result is returned.'
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -70,7 +70,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
static constexpr int32 MAX_CERTIFICATE_FILE_SIZE = 3 << 20;
|
static constexpr int32 MAX_CERTIFICATE_FILE_SIZE = 3 << 20;
|
||||||
static constexpr int32 MAX_DOWNLOAD_FILE_SIZE = 20 << 20;
|
static constexpr int32 MAX_DOWNLOAD_FILE_SIZE = 20 << 20;
|
||||||
|
|
||||||
static constexpr int32 MAX_CONCURRENTLY_SENT_CHAT_MESSAGES = 250; // some unreasonably big value
|
static constexpr int32 MAX_CONCURRENTLY_SENT_CHAT_MESSAGES = 310; // some unreasonably big value
|
||||||
|
|
||||||
static constexpr std::size_t MIN_PENDING_UPDATES_WARNING = 200;
|
static constexpr std::size_t MIN_PENDING_UPDATES_WARNING = 200;
|
||||||
|
|
||||||
|
@ -104,12 +104,18 @@ class Client final : public WebhookActor::Callback {
|
||||||
class JsonDatedFiles;
|
class JsonDatedFiles;
|
||||||
class JsonUser;
|
class JsonUser;
|
||||||
class JsonUsers;
|
class JsonUsers;
|
||||||
|
class JsonReactionType;
|
||||||
|
class JsonReactionCount;
|
||||||
class JsonChatPermissions;
|
class JsonChatPermissions;
|
||||||
class JsonChatPhotoInfo;
|
class JsonChatPhotoInfo;
|
||||||
class JsonChatLocation;
|
class JsonChatLocation;
|
||||||
class JsonChatInviteLink;
|
class JsonChatInviteLink;
|
||||||
class JsonChat;
|
class JsonChat;
|
||||||
class JsonMessageSender;
|
class JsonMessageSender;
|
||||||
|
class JsonMessageOrigin;
|
||||||
|
class JsonExternalReplyInfo;
|
||||||
|
class JsonTextQuote;
|
||||||
|
class JsonLinkPreviewOptions;
|
||||||
class JsonAnimation;
|
class JsonAnimation;
|
||||||
class JsonAudio;
|
class JsonAudio;
|
||||||
class JsonDocument;
|
class JsonDocument;
|
||||||
|
@ -140,7 +146,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
class JsonReplyMarkup;
|
class JsonReplyMarkup;
|
||||||
class JsonMessage;
|
class JsonMessage;
|
||||||
class JsonMessages;
|
class JsonMessages;
|
||||||
class JsonDeletedMessage;
|
class JsonInaccessibleMessage;
|
||||||
class JsonMessageId;
|
class JsonMessageId;
|
||||||
class JsonInlineQuery;
|
class JsonInlineQuery;
|
||||||
class JsonChosenInlineResult;
|
class JsonChosenInlineResult;
|
||||||
|
@ -159,10 +165,17 @@ class Client final : public WebhookActor::Callback {
|
||||||
class JsonChatMembers;
|
class JsonChatMembers;
|
||||||
class JsonChatMemberUpdated;
|
class JsonChatMemberUpdated;
|
||||||
class JsonChatJoinRequest;
|
class JsonChatJoinRequest;
|
||||||
|
class JsonChatBoostSource;
|
||||||
|
class JsonChatBoost;
|
||||||
|
class JsonChatBoostUpdated;
|
||||||
|
class JsonChatBoostRemoved;
|
||||||
|
class JsonChatBoosts;
|
||||||
class JsonForumTopicCreated;
|
class JsonForumTopicCreated;
|
||||||
class JsonForumTopicEdited;
|
class JsonForumTopicEdited;
|
||||||
class JsonForumTopicInfo;
|
class JsonForumTopicInfo;
|
||||||
class JsonGameHighScore;
|
class JsonGameHighScore;
|
||||||
|
class JsonMessageReactionUpdated;
|
||||||
|
class JsonMessageReactionCountUpdated;
|
||||||
class JsonAddress;
|
class JsonAddress;
|
||||||
class JsonOrderInfo;
|
class JsonOrderInfo;
|
||||||
class JsonSuccessfulPaymentBot;
|
class JsonSuccessfulPaymentBot;
|
||||||
|
@ -177,7 +190,11 @@ class Client final : public WebhookActor::Callback {
|
||||||
class JsonChatSetMessageAutoDeleteTime;
|
class JsonChatSetMessageAutoDeleteTime;
|
||||||
class JsonWriteAccessAllowed;
|
class JsonWriteAccessAllowed;
|
||||||
class JsonUserShared;
|
class JsonUserShared;
|
||||||
|
class JsonUsersShared;
|
||||||
class JsonChatShared;
|
class JsonChatShared;
|
||||||
|
class JsonGiveaway;
|
||||||
|
class JsonGiveawayWinners;
|
||||||
|
class JsonGiveawayCompleted;
|
||||||
class JsonUpdateTypes;
|
class JsonUpdateTypes;
|
||||||
class JsonWebhookInfo;
|
class JsonWebhookInfo;
|
||||||
class JsonStickerSet;
|
class JsonStickerSet;
|
||||||
|
@ -202,6 +219,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
class TdOnGetUserProfilePhotosCallback;
|
class TdOnGetUserProfilePhotosCallback;
|
||||||
class TdOnSendMessageCallback;
|
class TdOnSendMessageCallback;
|
||||||
class TdOnSendMessageAlbumCallback;
|
class TdOnSendMessageAlbumCallback;
|
||||||
|
class TdOnForwardMessagesCallback;
|
||||||
class TdOnDeleteFailedToSendMessageCallback;
|
class TdOnDeleteFailedToSendMessageCallback;
|
||||||
class TdOnEditMessageCallback;
|
class TdOnEditMessageCallback;
|
||||||
class TdOnEditInlineMessageCallback;
|
class TdOnEditInlineMessageCallback;
|
||||||
|
@ -224,7 +242,8 @@ class Client final : public WebhookActor::Callback {
|
||||||
class TdOnGetChatPinnedMessageToUnpinCallback;
|
class TdOnGetChatPinnedMessageToUnpinCallback;
|
||||||
class TdOnGetGroupMembersCallback;
|
class TdOnGetGroupMembersCallback;
|
||||||
class TdOnGetSupergroupMembersCallback;
|
class TdOnGetSupergroupMembersCallback;
|
||||||
class TdOnGetSupergroupMembersCountCallback;
|
class TdOnGetSupergroupMemberCountCallback;
|
||||||
|
class TdOnGetUserChatBoostsCallback;
|
||||||
class TdOnCreateInvoiceLinkCallback;
|
class TdOnCreateInvoiceLinkCallback;
|
||||||
class TdOnReplacePrimaryChatInviteLinkCallback;
|
class TdOnReplacePrimaryChatInviteLinkCallback;
|
||||||
class TdOnGetChatInviteLinkCallback;
|
class TdOnGetChatInviteLinkCallback;
|
||||||
|
@ -274,9 +293,23 @@ class Client final : public WebhookActor::Callback {
|
||||||
virtual ~TdQueryCallback() = default;
|
virtual ~TdQueryCallback() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct InputReplyParameters {
|
||||||
|
td::string reply_in_chat_id;
|
||||||
|
int64 reply_to_message_id = 0;
|
||||||
|
bool allow_sending_without_reply = false;
|
||||||
|
object_ptr<td_api::inputTextQuote> quote;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CheckedReplyParameters {
|
||||||
|
int64 reply_in_chat_id = 0;
|
||||||
|
int64 reply_to_message_id = 0;
|
||||||
|
object_ptr<td_api::inputTextQuote> quote;
|
||||||
|
};
|
||||||
|
|
||||||
struct UserInfo;
|
struct UserInfo;
|
||||||
struct ChatInfo;
|
struct ChatInfo;
|
||||||
struct BotCommandScope;
|
struct BotCommandScope;
|
||||||
|
struct BotUserIds;
|
||||||
|
|
||||||
enum class AccessRights { Read, ReadMembers, Edit, Write };
|
enum class AccessRights { Read, ReadMembers, Edit, Write };
|
||||||
|
|
||||||
|
@ -297,6 +330,8 @@ class Client final : public WebhookActor::Callback {
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
class TdOnCheckMessageCallback;
|
class TdOnCheckMessageCallback;
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
|
class TdOnCheckMessagesCallback;
|
||||||
|
template <class OnSuccess>
|
||||||
class TdOnCheckMessageThreadCallback;
|
class TdOnCheckMessageThreadCallback;
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
class TdOnCheckRemoteFileIdCallback;
|
class TdOnCheckRemoteFileIdCallback;
|
||||||
|
@ -338,8 +373,12 @@ class Client final : public WebhookActor::Callback {
|
||||||
td::Slice message_type, PromisedQueryPtr query, OnSuccess on_success);
|
td::Slice message_type, PromisedQueryPtr query, OnSuccess on_success);
|
||||||
|
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
void check_message_thread(int64 chat_id, int64 message_thread_id, int64 reply_to_message_id, PromisedQueryPtr query,
|
void check_messages(td::Slice chat_id_str, td::vector<int64> message_ids, bool allow_empty,
|
||||||
OnSuccess on_success);
|
AccessRights access_rights, td::Slice message_type, PromisedQueryPtr query, OnSuccess on_success);
|
||||||
|
|
||||||
|
template <class OnSuccess>
|
||||||
|
void check_reply_parameters(td::Slice chat_id_str, InputReplyParameters &&reply_parameters, int64 message_thread_id,
|
||||||
|
PromisedQueryPtr query, OnSuccess on_success);
|
||||||
|
|
||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
void resolve_sticker_set(const td::string &sticker_set_name, PromisedQueryPtr query, OnSuccess on_success);
|
void resolve_sticker_set(const td::string &sticker_set_name, PromisedQueryPtr query, OnSuccess on_success);
|
||||||
|
@ -375,13 +414,20 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
static bool to_bool(td::MutableSlice value);
|
static bool to_bool(td::MutableSlice value);
|
||||||
|
|
||||||
|
static object_ptr<td_api::InputMessageReplyTo> get_input_message_reply_to(CheckedReplyParameters &&reply_parameters);
|
||||||
|
|
||||||
|
static td::Result<InputReplyParameters> get_reply_parameters(const Query *query);
|
||||||
|
|
||||||
|
static td::Result<InputReplyParameters> get_reply_parameters(td::JsonValue &&value);
|
||||||
|
|
||||||
static td::Result<object_ptr<td_api::keyboardButton>> get_keyboard_button(td::JsonValue &button);
|
static td::Result<object_ptr<td_api::keyboardButton>> get_keyboard_button(td::JsonValue &button);
|
||||||
|
|
||||||
td::Result<object_ptr<td_api::inlineKeyboardButton>> get_inline_keyboard_button(td::JsonValue &button);
|
static td::Result<object_ptr<td_api::inlineKeyboardButton>> get_inline_keyboard_button(td::JsonValue &button,
|
||||||
|
BotUserIds &bot_user_ids);
|
||||||
|
|
||||||
td::Result<object_ptr<td_api::ReplyMarkup>> get_reply_markup(const Query *query);
|
static td::Result<object_ptr<td_api::ReplyMarkup>> get_reply_markup(const Query *query, BotUserIds &bot_user_ids);
|
||||||
|
|
||||||
td::Result<object_ptr<td_api::ReplyMarkup>> get_reply_markup(td::JsonValue &&value);
|
static td::Result<object_ptr<td_api::ReplyMarkup>> get_reply_markup(td::JsonValue &&value, BotUserIds &bot_user_ids);
|
||||||
|
|
||||||
static td::Result<object_ptr<td_api::labeledPricePart>> get_labeled_price_part(td::JsonValue &value);
|
static td::Result<object_ptr<td_api::labeledPricePart>> get_labeled_price_part(td::JsonValue &value);
|
||||||
|
|
||||||
|
@ -415,13 +461,17 @@ class Client final : public WebhookActor::Callback {
|
||||||
static td::Result<td_api::object_ptr<td_api::inlineQueryResultsButton>> get_inline_query_results_button(
|
static td::Result<td_api::object_ptr<td_api::inlineQueryResultsButton>> get_inline_query_results_button(
|
||||||
td::MutableSlice value);
|
td::MutableSlice value);
|
||||||
|
|
||||||
td::Result<object_ptr<td_api::InputInlineQueryResult>> get_inline_query_result(const Query *query);
|
static td::Result<object_ptr<td_api::InputInlineQueryResult>> get_inline_query_result(const Query *query,
|
||||||
|
BotUserIds &bot_user_ids);
|
||||||
|
|
||||||
td::Result<object_ptr<td_api::InputInlineQueryResult>> get_inline_query_result(td::JsonValue &&value);
|
static td::Result<object_ptr<td_api::InputInlineQueryResult>> get_inline_query_result(td::JsonValue &&value,
|
||||||
|
BotUserIds &bot_user_ids);
|
||||||
|
|
||||||
td::Result<td::vector<object_ptr<td_api::InputInlineQueryResult>>> get_inline_query_results(const Query *query);
|
static td::Result<td::vector<object_ptr<td_api::InputInlineQueryResult>>> get_inline_query_results(
|
||||||
|
const Query *query, BotUserIds &bot_user_ids);
|
||||||
|
|
||||||
td::Result<td::vector<object_ptr<td_api::InputInlineQueryResult>>> get_inline_query_results(td::JsonValue &&value);
|
static td::Result<td::vector<object_ptr<td_api::InputInlineQueryResult>>> get_inline_query_results(
|
||||||
|
td::JsonValue &&value, BotUserIds &bot_user_ids);
|
||||||
|
|
||||||
struct BotCommandScope {
|
struct BotCommandScope {
|
||||||
object_ptr<td_api::BotCommandScope> scope_;
|
object_ptr<td_api::BotCommandScope> scope_;
|
||||||
|
@ -494,12 +544,17 @@ class Client final : public WebhookActor::Callback {
|
||||||
static td::Result<object_ptr<td_api::formattedText>> get_formatted_text(td::string text, td::string parse_mode,
|
static td::Result<object_ptr<td_api::formattedText>> get_formatted_text(td::string text, td::string parse_mode,
|
||||||
td::JsonValue &&input_entities);
|
td::JsonValue &&input_entities);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
static td::Result<object_ptr<td_api::inputMessageText>> get_input_message_text(const Query *query);
|
static td::Result<object_ptr<td_api::inputMessageText>> get_input_message_text(const Query *query);
|
||||||
|
|
||||||
static td::Result<object_ptr<td_api::inputMessageText>> get_input_message_text(td::string text,
|
static td::Result<object_ptr<td_api::inputMessageText>> get_input_message_text(
|
||||||
bool disable_web_page_preview,
|
td::string text, object_ptr<td_api::linkPreviewOptions> link_preview_options, td::string parse_mode,
|
||||||
td::string parse_mode,
|
td::JsonValue &&input_entities);
|
||||||
td::JsonValue &&input_entities);
|
|
||||||
|
|
||||||
static td::Result<object_ptr<td_api::location>> get_location(const Query *query);
|
static td::Result<object_ptr<td_api::location>> get_location(const Query *query);
|
||||||
|
|
||||||
|
@ -525,6 +580,10 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
static td::Result<td::vector<td::string>> get_poll_options(const Query *query);
|
static td::Result<td::vector<td::string>> get_poll_options(const Query *query);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
static int32 get_integer_arg(const Query *query, td::Slice field_name, int32 default_value,
|
static int32 get_integer_arg(const Query *query, td::Slice field_name, int32 default_value,
|
||||||
int32 min_value = std::numeric_limits<int32>::min(),
|
int32 min_value = std::numeric_limits<int32>::min(),
|
||||||
int32 max_value = std::numeric_limits<int32>::max());
|
int32 max_value = std::numeric_limits<int32>::max());
|
||||||
|
@ -533,6 +592,9 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
static int64 get_message_id(const Query *query, td::Slice field_name = td::Slice("message_id"));
|
static int64 get_message_id(const Query *query, td::Slice field_name = td::Slice("message_id"));
|
||||||
|
|
||||||
|
static td::Result<td::vector<int64>> get_message_ids(const Query *query, size_t max_count,
|
||||||
|
td::Slice field_name = td::Slice("message_ids"));
|
||||||
|
|
||||||
static td::Result<td::Slice> get_inline_message_id(const Query *query,
|
static td::Result<td::Slice> get_inline_message_id(const Query *query,
|
||||||
td::Slice field_name = td::Slice("inline_message_id"));
|
td::Slice field_name = td::Slice("inline_message_id"));
|
||||||
|
|
||||||
|
@ -540,7 +602,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
void decrease_yet_unsent_message_count(int64 chat_id, int32 count);
|
void decrease_yet_unsent_message_count(int64 chat_id, int32 count);
|
||||||
|
|
||||||
int64 extract_yet_unsent_message_query_id(int64 chat_id, int64 message_id, bool *is_reply_to_message_deleted);
|
int64 extract_yet_unsent_message_query_id(int64 chat_id, int64 message_id);
|
||||||
|
|
||||||
// start custom helper methods
|
// start custom helper methods
|
||||||
|
|
||||||
|
@ -552,7 +614,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
static int64 get_int64_arg(const Query *query, td::Slice field_name, int64 default_value,
|
static int64 get_int64_arg(const Query *query, td::Slice field_name, int64 default_value,
|
||||||
int64 min_value = std::numeric_limits<int64>::min(),
|
int64 min_value = std::numeric_limits<int64>::min(),
|
||||||
int64 max_value = std::numeric_limits<int64>::max());
|
int64 max_value = std::numeric_limits<int64>::max());
|
||||||
static td::Result<td_api::object_ptr<td_api::ChatReportReason>> get_report_reason(const Query *query,
|
static td::Result<td_api::object_ptr<td_api::ReportReason>> get_report_reason(const Query *query,
|
||||||
td::Slice field_name = td::Slice("reason"));
|
td::Slice field_name = td::Slice("reason"));
|
||||||
|
|
||||||
static td::Result<td_api::object_ptr<td_api::SearchMessagesFilter>> get_search_messages_filter(
|
static td::Result<td_api::object_ptr<td_api::SearchMessagesFilter>> get_search_messages_filter(
|
||||||
|
@ -561,13 +623,15 @@ class Client final : public WebhookActor::Callback {
|
||||||
// end custom helper methods
|
// end custom helper methods
|
||||||
|
|
||||||
void on_message_send_succeeded(object_ptr<td_api::message> &&message, int64 old_message_id);
|
void on_message_send_succeeded(object_ptr<td_api::message> &&message, int64 old_message_id);
|
||||||
void on_message_send_failed(int64 chat_id, int64 old_message_id, int64 new_message_id, td::Status result);
|
|
||||||
|
void on_message_send_failed(int64 chat_id, int64 old_message_id, int64 new_message_id,
|
||||||
|
object_ptr<td_api::error> &&error);
|
||||||
|
|
||||||
static bool init_methods();
|
static bool init_methods();
|
||||||
|
|
||||||
static bool is_local_method(td::Slice method);
|
static bool is_local_method(td::Slice method);
|
||||||
|
|
||||||
void on_cmd(PromisedQueryPtr query);
|
void on_cmd(PromisedQueryPtr query, bool force = false);
|
||||||
|
|
||||||
td::Status process_get_me_query(PromisedQueryPtr &query);
|
td::Status process_get_me_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_my_commands_query(PromisedQueryPtr &query);
|
td::Status process_get_my_commands_query(PromisedQueryPtr &query);
|
||||||
|
@ -602,15 +666,19 @@ class Client final : public WebhookActor::Callback {
|
||||||
td::Status process_send_poll_query(PromisedQueryPtr &query);
|
td::Status process_send_poll_query(PromisedQueryPtr &query);
|
||||||
td::Status process_stop_poll_query(PromisedQueryPtr &query);
|
td::Status process_stop_poll_query(PromisedQueryPtr &query);
|
||||||
td::Status process_copy_message_query(PromisedQueryPtr &query);
|
td::Status process_copy_message_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_copy_messages_query(PromisedQueryPtr &query);
|
||||||
td::Status process_forward_message_query(PromisedQueryPtr &query);
|
td::Status process_forward_message_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_forward_messages_query(PromisedQueryPtr &query);
|
||||||
td::Status process_send_media_group_query(PromisedQueryPtr &query);
|
td::Status process_send_media_group_query(PromisedQueryPtr &query);
|
||||||
td::Status process_send_chat_action_query(PromisedQueryPtr &query);
|
td::Status process_send_chat_action_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_set_message_reaction_query(PromisedQueryPtr &query);
|
||||||
td::Status process_edit_message_text_query(PromisedQueryPtr &query);
|
td::Status process_edit_message_text_query(PromisedQueryPtr &query);
|
||||||
td::Status process_edit_message_live_location_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_media_query(PromisedQueryPtr &query);
|
||||||
td::Status process_edit_message_caption_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_edit_message_reply_markup_query(PromisedQueryPtr &query);
|
||||||
td::Status process_delete_message_query(PromisedQueryPtr &query);
|
td::Status process_delete_message_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_delete_messages_query(PromisedQueryPtr &query);
|
||||||
td::Status process_create_invoice_link_query(PromisedQueryPtr &query);
|
td::Status process_create_invoice_link_query(PromisedQueryPtr &query);
|
||||||
td::Status process_set_game_score_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_get_game_high_scores_query(PromisedQueryPtr &query);
|
||||||
|
@ -646,6 +714,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
td::Status process_reopen_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_hide_general_forum_topic_query(PromisedQueryPtr &query);
|
||||||
td::Status process_unhide_general_forum_topic_query(PromisedQueryPtr &query);
|
td::Status process_unhide_general_forum_topic_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_unpin_all_general_forum_topic_messages_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_chat_member_query(PromisedQueryPtr &query);
|
td::Status process_get_chat_member_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_chat_administrators_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_get_chat_member_count_query(PromisedQueryPtr &query);
|
||||||
|
@ -659,6 +728,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
td::Status process_unban_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_approve_chat_join_request_query(PromisedQueryPtr &query);
|
||||||
td::Status process_decline_chat_join_request_query(PromisedQueryPtr &query);
|
td::Status process_decline_chat_join_request_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_get_user_chat_boosts_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_sticker_set_query(PromisedQueryPtr &query);
|
td::Status process_get_sticker_set_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_custom_emoji_stickers_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_upload_sticker_file_query(PromisedQueryPtr &query);
|
||||||
|
@ -684,7 +754,6 @@ class Client final : public WebhookActor::Callback {
|
||||||
//custom methods
|
//custom methods
|
||||||
td::Status process_get_message_info_query(PromisedQueryPtr &query);
|
td::Status process_get_message_info_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_chat_members_query(PromisedQueryPtr &query);
|
td::Status process_get_chat_members_query(PromisedQueryPtr &query);
|
||||||
td::Status process_delete_messages_query(PromisedQueryPtr &query);
|
|
||||||
td::Status process_toggle_group_invites_query(PromisedQueryPtr &query);
|
td::Status process_toggle_group_invites_query(PromisedQueryPtr &query);
|
||||||
td::Status process_ping_query(PromisedQueryPtr &query);
|
td::Status process_ping_query(PromisedQueryPtr &query);
|
||||||
td::Status process_get_memory_stats_query(PromisedQueryPtr &query);
|
td::Status process_get_memory_stats_query(PromisedQueryPtr &query);
|
||||||
|
@ -693,6 +762,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
td::Status process_delete_proxy_query(PromisedQueryPtr &query);
|
td::Status process_delete_proxy_query(PromisedQueryPtr &query);
|
||||||
td::Status process_enable_proxy_query(PromisedQueryPtr &query);
|
td::Status process_enable_proxy_query(PromisedQueryPtr &query);
|
||||||
td::Status process_disable_proxy_query(PromisedQueryPtr &query);
|
td::Status process_disable_proxy_query(PromisedQueryPtr &query);
|
||||||
|
td::Status process_delete_messages_range_query(PromisedQueryPtr &query);
|
||||||
|
|
||||||
//custom user methods
|
//custom user methods
|
||||||
td::Status process_get_chats_query(PromisedQueryPtr &query);
|
td::Status process_get_chats_query(PromisedQueryPtr &query);
|
||||||
|
@ -735,7 +805,10 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
void on_webhook_closed(td::Status status);
|
void on_webhook_closed(td::Status status);
|
||||||
|
|
||||||
void do_send_message(object_ptr<td_api::InputMessageContent> input_message_content, PromisedQueryPtr query);
|
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);
|
||||||
|
|
||||||
int64 get_send_message_query_id(PromisedQueryPtr query, bool is_multisend);
|
int64 get_send_message_query_id(PromisedQueryPtr query, bool is_multisend);
|
||||||
|
|
||||||
|
@ -799,7 +872,6 @@ class Client final : public WebhookActor::Callback {
|
||||||
td::vector<td::string> active_usernames;
|
td::vector<td::string> active_usernames;
|
||||||
td::string editable_username;
|
td::string editable_username;
|
||||||
td::string language_code;
|
td::string language_code;
|
||||||
int64 emoji_status_custom_emoji_id;
|
|
||||||
|
|
||||||
object_ptr<td_api::chatPhoto> photo;
|
object_ptr<td_api::chatPhoto> photo;
|
||||||
td::string bio;
|
td::string bio;
|
||||||
|
@ -820,16 +892,11 @@ class Client final : public WebhookActor::Callback {
|
||||||
bool added_to_attachment_menu = false;
|
bool added_to_attachment_menu = false;
|
||||||
};
|
};
|
||||||
static void add_user(UserInfo *user_info, object_ptr<td_api::user> &&user);
|
static void add_user(UserInfo *user_info, object_ptr<td_api::user> &&user);
|
||||||
void set_user_photo(int64 user_id, object_ptr<td_api::chatPhoto> &&photo);
|
|
||||||
void set_user_bio(int64 user_id, td::string &&bio);
|
|
||||||
void set_user_has_private_forwards(int64 user_id, bool has_private_forwards);
|
|
||||||
void set_user_has_restricted_voice_and_video_messages(int64 user_id, bool has_restricted_voice_and_video_messages);
|
|
||||||
|
|
||||||
void set_user_status(int64 user_id, object_ptr<td_api::UserStatus> &&status);
|
|
||||||
|
|
||||||
UserInfo *add_user_info(int64 user_id);
|
UserInfo *add_user_info(int64 user_id);
|
||||||
const UserInfo *get_user_info(int64 user_id) const;
|
const UserInfo *get_user_info(int64 user_id) const;
|
||||||
|
|
||||||
|
void set_user_status(int64 user_id, object_ptr<td_api::UserStatus> &&status);
|
||||||
|
|
||||||
struct GroupInfo {
|
struct GroupInfo {
|
||||||
object_ptr<td_api::chatPhoto> photo;
|
object_ptr<td_api::chatPhoto> photo;
|
||||||
td::string description;
|
td::string description;
|
||||||
|
@ -841,9 +908,6 @@ class Client final : public WebhookActor::Callback {
|
||||||
int64 upgraded_to_supergroup_id = 0;
|
int64 upgraded_to_supergroup_id = 0;
|
||||||
};
|
};
|
||||||
static void add_group(GroupInfo *group_info, object_ptr<td_api::basicGroup> &&group);
|
static void add_group(GroupInfo *group_info, object_ptr<td_api::basicGroup> &&group);
|
||||||
void set_group_photo(int64 group_id, object_ptr<td_api::chatPhoto> &&photo);
|
|
||||||
void set_group_description(int64 group_id, td::string &&descripton);
|
|
||||||
void set_group_invite_link(int64 group_id, td::string &&invite_link);
|
|
||||||
GroupInfo *add_group_info(int64 group_id);
|
GroupInfo *add_group_info(int64 group_id);
|
||||||
const GroupInfo *get_group_info(int64 group_id) const;
|
const GroupInfo *get_group_info(int64 group_id) const;
|
||||||
|
|
||||||
|
@ -862,6 +926,7 @@ class Client final : public WebhookActor::Callback {
|
||||||
bool is_supergroup = false;
|
bool is_supergroup = false;
|
||||||
bool is_forum = false;
|
bool is_forum = false;
|
||||||
bool can_set_sticker_set = false;
|
bool can_set_sticker_set = false;
|
||||||
|
bool is_all_history_available = false;
|
||||||
bool has_location = false;
|
bool has_location = false;
|
||||||
bool join_to_send_messages = false;
|
bool join_to_send_messages = false;
|
||||||
bool join_by_request = false;
|
bool join_by_request = false;
|
||||||
|
@ -874,16 +939,6 @@ class Client final : public WebhookActor::Callback {
|
||||||
// end custom properties
|
// end custom properties
|
||||||
};
|
};
|
||||||
static void add_supergroup(SupergroupInfo *supergroup_info, object_ptr<td_api::supergroup> &&supergroup);
|
static void add_supergroup(SupergroupInfo *supergroup_info, object_ptr<td_api::supergroup> &&supergroup);
|
||||||
void set_supergroup_photo(int64 supergroup_id, object_ptr<td_api::chatPhoto> &&photo);
|
|
||||||
void set_supergroup_description(int64 supergroup_id, td::string &&descripton);
|
|
||||||
void set_supergroup_invite_link(int64 supergroup_id, td::string &&invite_link);
|
|
||||||
void set_supergroup_sticker_set_id(int64 supergroup_id, int64 sticker_set_id);
|
|
||||||
void set_supergroup_can_set_sticker_set(int64 supergroup_id, bool can_set_sticker_set);
|
|
||||||
void set_supergroup_slow_mode_delay(int64 supergroup_id, int32 slow_mode_delay);
|
|
||||||
void set_supergroup_linked_chat_id(int64 supergroup_id, int64 linked_chat_id);
|
|
||||||
void set_supergroup_location(int64 supergroup_id, object_ptr<td_api::chatLocation> location);
|
|
||||||
void set_supergroup_has_hidden_members(int64 supergroup_id, bool has_hidden_members);
|
|
||||||
void set_supergroup_has_aggressive_anti_spam_enabled(int64 supergroup_id, bool has_aggressive_anti_spam_enabled);
|
|
||||||
SupergroupInfo *add_supergroup_info(int64 supergroup_id);
|
SupergroupInfo *add_supergroup_info(int64 supergroup_id);
|
||||||
const SupergroupInfo *get_supergroup_info(int64 supergroup_id) const;
|
const SupergroupInfo *get_supergroup_info(int64 supergroup_id) const;
|
||||||
|
|
||||||
|
@ -892,7 +947,14 @@ class Client final : public WebhookActor::Callback {
|
||||||
Type type = Type::Unknown;
|
Type type = Type::Unknown;
|
||||||
td::string title;
|
td::string title;
|
||||||
int32 message_auto_delete_time = 0;
|
int32 message_auto_delete_time = 0;
|
||||||
|
int64 emoji_status_custom_emoji_id = 0;
|
||||||
|
int32 emoji_status_expiration_date = 0;
|
||||||
|
int32 accent_color_id = -1;
|
||||||
|
int32 profile_accent_color_id = -1;
|
||||||
|
int64 background_custom_emoji_id = 0;
|
||||||
|
int64 profile_background_custom_emoji_id = 0;
|
||||||
bool has_protected_content = false;
|
bool has_protected_content = false;
|
||||||
|
object_ptr<td_api::chatAvailableReactionsSome> available_reactions;
|
||||||
object_ptr<td_api::chatPhotoInfo> photo_info;
|
object_ptr<td_api::chatPhotoInfo> photo_info;
|
||||||
object_ptr<td_api::chatPermissions> permissions;
|
object_ptr<td_api::chatPermissions> permissions;
|
||||||
union {
|
union {
|
||||||
|
@ -918,15 +980,10 @@ class Client final : public WebhookActor::Callback {
|
||||||
int64 message_thread_id = 0;
|
int64 message_thread_id = 0;
|
||||||
int32 date = 0;
|
int32 date = 0;
|
||||||
int32 edit_date = 0;
|
int32 edit_date = 0;
|
||||||
int64 initial_chat_id = 0;
|
|
||||||
int64 initial_sender_user_id = 0;
|
|
||||||
int64 initial_sender_chat_id = 0;
|
|
||||||
int32 initial_send_date = 0;
|
int32 initial_send_date = 0;
|
||||||
int64 initial_message_id = 0;
|
object_ptr<td_api::MessageOrigin> forward_origin;
|
||||||
td::string initial_author_signature;
|
|
||||||
td::string initial_sender_name;
|
|
||||||
td::string author_signature;
|
td::string author_signature;
|
||||||
int64 reply_to_message_id = 0;
|
object_ptr<td_api::messageReplyToMessage> reply_to_message;
|
||||||
int64 media_album_id = 0;
|
int64 media_album_id = 0;
|
||||||
int64 via_bot_user_id = 0;
|
int64 via_bot_user_id = 0;
|
||||||
object_ptr<td_api::MessageContent> content;
|
object_ptr<td_api::MessageContent> content;
|
||||||
|
@ -943,13 +1000,20 @@ class Client final : public WebhookActor::Callback {
|
||||||
bool can_be_saved = false;
|
bool can_be_saved = false;
|
||||||
bool is_automatic_forward = false;
|
bool is_automatic_forward = false;
|
||||||
bool is_topic_message = false;
|
bool is_topic_message = false;
|
||||||
mutable bool is_reply_to_message_deleted = false;
|
|
||||||
mutable bool is_content_changed = false;
|
mutable bool is_content_changed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int64 &get_reply_to_message_id(object_ptr<td_api::message> &message);
|
static int64 get_same_chat_reply_to_message_id(const td_api::messageReplyToMessage *reply_to,
|
||||||
|
int64 message_thread_id);
|
||||||
|
|
||||||
void set_message_reply_to_message_id(MessageInfo *message_info, int64 reply_to_message_id);
|
static int64 get_same_chat_reply_to_message_id(const object_ptr<td_api::MessageReplyTo> &reply_to,
|
||||||
|
int64 message_thread_id);
|
||||||
|
|
||||||
|
static int64 get_same_chat_reply_to_message_id(const object_ptr<td_api::message> &message);
|
||||||
|
|
||||||
|
static int64 get_same_chat_reply_to_message_id(const MessageInfo *message_info);
|
||||||
|
|
||||||
|
static void drop_internal_reply_to_message_in_another_chat(object_ptr<td_api::message> &message);
|
||||||
|
|
||||||
static td::Slice get_sticker_type(const object_ptr<td_api::StickerType> &type);
|
static td::Slice get_sticker_type(const object_ptr<td_api::StickerType> &type);
|
||||||
|
|
||||||
|
@ -1034,6 +1098,8 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
static int32 as_scheduled_message_id(int64 message_id);
|
static int32 as_scheduled_message_id(int64 message_id);
|
||||||
|
|
||||||
|
static int32 as_client_message_id_unchecked(int64 message_id);
|
||||||
|
|
||||||
static int64 get_supergroup_chat_id(int64 supergroup_id);
|
static int64 get_supergroup_chat_id(int64 supergroup_id);
|
||||||
|
|
||||||
static int64 get_basic_group_chat_id(int64 basic_group_id);
|
static int64 get_basic_group_chat_id(int64 basic_group_id);
|
||||||
|
@ -1067,6 +1133,12 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
void add_update_chat_join_request(object_ptr<td_api::updateNewChatJoinRequest> &&update);
|
void add_update_chat_join_request(object_ptr<td_api::updateNewChatJoinRequest> &&update);
|
||||||
|
|
||||||
|
void add_update_chat_boost(object_ptr<td_api::updateChatBoost> &&update);
|
||||||
|
|
||||||
|
void add_update_message_reaction(object_ptr<td_api::updateMessageReaction> &&update);
|
||||||
|
|
||||||
|
void add_update_message_reaction_count(object_ptr<td_api::updateMessageReactions> &&update);
|
||||||
|
|
||||||
// append only before Size
|
// append only before Size
|
||||||
enum class UpdateType : int32 {
|
enum class UpdateType : int32 {
|
||||||
Message,
|
Message,
|
||||||
|
@ -1085,6 +1157,10 @@ class Client final : public WebhookActor::Callback {
|
||||||
MyChatMember,
|
MyChatMember,
|
||||||
ChatMember,
|
ChatMember,
|
||||||
ChatJoinRequest,
|
ChatJoinRequest,
|
||||||
|
ChatBoostUpdated,
|
||||||
|
ChatBoostRemoved,
|
||||||
|
MessageReaction,
|
||||||
|
MessageReactionCount,
|
||||||
Size
|
Size
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1114,9 +1190,11 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
bool have_message_access(int64 chat_id) const;
|
bool have_message_access(int64 chat_id) const;
|
||||||
|
|
||||||
// by default ChatMember updates are disabled
|
// by default ChatMember, MessageReaction, and MessageReactionCount updates are disabled
|
||||||
static constexpr td::uint32 DEFAULT_ALLOWED_UPDATE_TYPES =
|
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::Size)) - 1 - (1 << static_cast<int32>(UpdateType::ChatMember)) -
|
||||||
|
(1 << static_cast<int32>(UpdateType::MessageReaction)) -
|
||||||
|
(1 << static_cast<int32>(UpdateType::MessageReactionCount));
|
||||||
|
|
||||||
object_ptr<td_api::AuthorizationState> authorization_state_;
|
object_ptr<td_api::AuthorizationState> authorization_state_;
|
||||||
bool was_authorized_ = false;
|
bool was_authorized_ = false;
|
||||||
|
@ -1155,17 +1233,10 @@ class Client final : public WebhookActor::Callback {
|
||||||
td::WaitFreeHashMap<int64, td::unique_ptr<SupergroupInfo>> supergroups_;
|
td::WaitFreeHashMap<int64, td::unique_ptr<SupergroupInfo>> supergroups_;
|
||||||
td::WaitFreeHashMap<int64, td::unique_ptr<ChatInfo>> chats_;
|
td::WaitFreeHashMap<int64, td::unique_ptr<ChatInfo>> chats_;
|
||||||
|
|
||||||
td::FlatHashMap<FullMessageId, td::FlatHashSet<int64>, FullMessageIdHash>
|
|
||||||
reply_message_ids_; // message -> replies to it
|
|
||||||
td::FlatHashMap<FullMessageId, td::FlatHashSet<int64>, FullMessageIdHash>
|
|
||||||
yet_unsent_reply_message_ids_; // message -> replies to it
|
|
||||||
|
|
||||||
td::FlatHashMap<int32, td::vector<PromisedQueryPtr>> file_download_listeners_;
|
td::FlatHashMap<int32, td::vector<PromisedQueryPtr>> file_download_listeners_;
|
||||||
td::FlatHashSet<int32> download_started_file_ids_;
|
td::FlatHashSet<int32> download_started_file_ids_;
|
||||||
|
|
||||||
struct YetUnsentMessage {
|
struct YetUnsentMessage {
|
||||||
int64 reply_to_message_id = 0;
|
|
||||||
bool is_reply_to_message_deleted = false;
|
|
||||||
int64 send_message_query_id = 0;
|
int64 send_message_query_id = 0;
|
||||||
};
|
};
|
||||||
td::FlatHashMap<FullMessageId, YetUnsentMessage, FullMessageIdHash> yet_unsent_messages_;
|
td::FlatHashMap<FullMessageId, YetUnsentMessage, FullMessageIdHash> yet_unsent_messages_;
|
||||||
|
@ -1206,11 +1277,15 @@ class Client final : public WebhookActor::Callback {
|
||||||
|
|
||||||
td::WaitFreeHashMap<int64, td::string> sticker_set_names_;
|
td::WaitFreeHashMap<int64, td::string> sticker_set_names_;
|
||||||
|
|
||||||
int64 cur_temp_bot_user_id_ = 1;
|
td::WaitFreeHashMap<int64, double> last_send_message_time_;
|
||||||
td::FlatHashMap<td::string, int64> bot_user_ids_;
|
|
||||||
td::FlatHashSet<td::string> unresolved_bot_usernames_;
|
struct BotUserIds {
|
||||||
td::FlatHashMap<int64, int64> temp_to_real_bot_user_id_;
|
int64 default_bot_user_id_ = 0;
|
||||||
td::FlatHashMap<td::string, td::vector<int64>> awaiting_bot_resolve_queries_;
|
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_;
|
||||||
|
|
||||||
struct PendingBotResolveQuery {
|
struct PendingBotResolveQuery {
|
||||||
std::size_t pending_resolve_count = 0;
|
std::size_t pending_resolve_count = 0;
|
||||||
|
@ -1220,6 +1295,9 @@ class Client final : public WebhookActor::Callback {
|
||||||
td::FlatHashMap<int64, PendingBotResolveQuery> pending_bot_resolve_queries_;
|
td::FlatHashMap<int64, PendingBotResolveQuery> pending_bot_resolve_queries_;
|
||||||
int64 current_bot_resolve_query_id_ = 1;
|
int64 current_bot_resolve_query_id_ = 1;
|
||||||
|
|
||||||
|
td::FlatHashMap<td::string, td::vector<int64>> awaiting_bot_resolve_queries_;
|
||||||
|
td::FlatHashMap<int64, int64> temp_to_real_bot_user_id_;
|
||||||
|
|
||||||
td::string dir_;
|
td::string dir_;
|
||||||
td::ActorOwn<td::ClientActor> td_client_;
|
td::ActorOwn<td::ClientActor> td_client_;
|
||||||
td::ActorContext context_;
|
td::ActorContext context_;
|
||||||
|
@ -1273,6 +1351,8 @@ class Client final : public WebhookActor::Callback {
|
||||||
double previous_get_updates_finish_time_ = 0;
|
double previous_get_updates_finish_time_ = 0;
|
||||||
double next_get_updates_conflict_time_ = 0;
|
double next_get_updates_conflict_time_ = 0;
|
||||||
|
|
||||||
|
int32 log_in_date_ = 0;
|
||||||
|
|
||||||
int32 flood_limited_query_count_ = 0;
|
int32 flood_limited_query_count_ = 0;
|
||||||
double next_flood_limit_warning_time_ = 0;
|
double next_flood_limit_warning_time_ = 0;
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ void ClientManager::get_stats(td::Promise<td::BufferSlice> promise,
|
||||||
auto top_clients = get_top_clients(50, id_filter);
|
auto top_clients = get_top_clients(50, id_filter);
|
||||||
|
|
||||||
if(!as_json) {
|
if(!as_json) {
|
||||||
sb << stat_.get_description() << '\n';
|
sb << BotStatActor::get_description() << '\n';
|
||||||
}
|
}
|
||||||
if (id_filter.empty()) {
|
if (id_filter.empty()) {
|
||||||
if(as_json) {
|
if(as_json) {
|
||||||
|
@ -448,9 +448,6 @@ td::int64 ClientManager::get_tqueue_id(td::int64 user_id, bool is_test_dc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientManager::start_up() {
|
void ClientManager::start_up() {
|
||||||
//NB: the same scheduler as for database in Td
|
|
||||||
auto scheduler_id = 1;
|
|
||||||
|
|
||||||
// init tqueue
|
// init tqueue
|
||||||
{
|
{
|
||||||
auto load_start_time = td::Time::now();
|
auto load_start_time = td::Time::now();
|
||||||
|
@ -478,7 +475,8 @@ void ClientManager::start_up() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto concurrent_binlog = std::make_shared<td::ConcurrentBinlog>(std::move(binlog), scheduler_id);
|
auto concurrent_binlog =
|
||||||
|
std::make_shared<td::ConcurrentBinlog>(std::move(binlog), SharedData::get_binlog_scheduler_id());
|
||||||
auto concurrent_tqueue_binlog = td::make_unique<td::TQueueBinlog<td::BinlogInterface>>();
|
auto concurrent_tqueue_binlog = td::make_unique<td::TQueueBinlog<td::BinlogInterface>>();
|
||||||
concurrent_tqueue_binlog->set_binlog(std::move(concurrent_binlog));
|
concurrent_tqueue_binlog->set_binlog(std::move(concurrent_binlog));
|
||||||
tqueue->set_callback(std::move(concurrent_tqueue_binlog));
|
tqueue->set_callback(std::move(concurrent_tqueue_binlog));
|
||||||
|
@ -493,18 +491,18 @@ void ClientManager::start_up() {
|
||||||
// init webhook_db and user_db
|
// init webhook_db and user_db
|
||||||
auto concurrent_webhook_db = td::make_unique<td::BinlogKeyValue<td::ConcurrentBinlog>>();
|
auto concurrent_webhook_db = td::make_unique<td::BinlogKeyValue<td::ConcurrentBinlog>>();
|
||||||
auto status = concurrent_webhook_db->init(parameters_->working_directory_ + "webhooks_db.binlog", td::DbKey::empty(),
|
auto status = concurrent_webhook_db->init(parameters_->working_directory_ + "webhooks_db.binlog", td::DbKey::empty(),
|
||||||
scheduler_id);
|
SharedData::get_binlog_scheduler_id());
|
||||||
LOG_IF(FATAL, status.is_error()) << "Can't open webhooks_db.binlog " << status;
|
LOG_IF(FATAL, status.is_error()) << "Can't open webhooks_db.binlog " << status;
|
||||||
parameters_->shared_data_->webhook_db_ = std::move(concurrent_webhook_db);
|
parameters_->shared_data_->webhook_db_ = std::move(concurrent_webhook_db);
|
||||||
|
|
||||||
auto concurrent_user_db = td::make_unique<td::BinlogKeyValue<td::ConcurrentBinlog>>();
|
auto concurrent_user_db = td::make_unique<td::BinlogKeyValue<td::ConcurrentBinlog>>();
|
||||||
status = concurrent_user_db->init(parameters_->working_directory_ + "user_db.binlog", td::DbKey::empty(), scheduler_id);
|
status = concurrent_user_db->init(parameters_->working_directory_ + "user_db.binlog", td::DbKey::empty(), SharedData::get_binlog_scheduler_id());
|
||||||
LOG_IF(FATAL, status.is_error()) << "Can't open user_db.binlog " << status.error();
|
LOG_IF(FATAL, status.is_error()) << "Can't open user_db.binlog " << status.error();
|
||||||
parameters_->shared_data_->user_db_ = std::move(concurrent_user_db);
|
parameters_->shared_data_->user_db_ = std::move(concurrent_user_db);
|
||||||
|
|
||||||
auto &webhook_db = *parameters_->shared_data_->webhook_db_;
|
auto &webhook_db = *parameters_->shared_data_->webhook_db_;
|
||||||
auto &user_db = *parameters_->shared_data_->user_db_;
|
auto &user_db = *parameters_->shared_data_->user_db_;
|
||||||
for (auto key_value : webhook_db.get_all()) {
|
for (const auto &key_value : webhook_db.get_all()) {
|
||||||
if (!token_range_(td::to_integer<td::uint64>(key_value.first))) {
|
if (!token_range_(td::to_integer<td::uint64>(key_value.first))) {
|
||||||
LOG(WARNING) << "DROP WEBHOOK: " << key_value.first << " ---> " << key_value.second;
|
LOG(WARNING) << "DROP WEBHOOK: " << key_value.first << " ---> " << key_value.second;
|
||||||
webhook_db.erase(key_value.first);
|
webhook_db.erase(key_value.first);
|
||||||
|
@ -516,8 +514,8 @@ void ClientManager::start_up() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// launch watchdog
|
// launch watchdog
|
||||||
watchdog_id_ = td::create_actor_on_scheduler<Watchdog>(
|
watchdog_id_ = td::create_actor_on_scheduler<Watchdog>("ManagerWatchdog", SharedData::get_watchdog_scheduler_id(),
|
||||||
"ManagerWatchdog", td::Scheduler::instance()->sched_count() - 3, td::this_thread::get_id(), WATCHDOG_TIMEOUT);
|
td::this_thread::get_id(), WATCHDOG_TIMEOUT);
|
||||||
set_timeout_in(600.0);
|
set_timeout_in(600.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,7 +682,7 @@ void ClientManager::raw_event(const td::Event::Raw &event) {
|
||||||
|
|
||||||
void ClientManager::timeout_expired() {
|
void ClientManager::timeout_expired() {
|
||||||
send_closure(watchdog_id_, &Watchdog::kick);
|
send_closure(watchdog_id_, &Watchdog::kick);
|
||||||
set_timeout_in(WATCHDOG_TIMEOUT / 2);
|
set_timeout_in(WATCHDOG_TIMEOUT / 10);
|
||||||
|
|
||||||
double now = td::Time::now();
|
double now = td::Time::now();
|
||||||
if (now > next_tqueue_gc_time_) {
|
if (now > next_tqueue_gc_time_) {
|
||||||
|
|
|
@ -54,15 +54,54 @@ struct SharedData {
|
||||||
return static_cast<td::int32>(result);
|
return static_cast<td::int32>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static td::int32 get_database_scheduler_id() {
|
|
||||||
// the same scheduler as for database in Td
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static td::int32 get_file_gc_scheduler_id() {
|
static td::int32 get_file_gc_scheduler_id() {
|
||||||
// the same scheduler as for file GC in Td
|
// the same scheduler as for file GC in Td
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static td::int32 get_client_scheduler_id() {
|
||||||
|
// the thread for ClientManager and all Clients
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
static td::int32 get_watchdog_scheduler_id() {
|
||||||
|
// the thread for watchdogs
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
static td::int32 get_slow_incoming_http_scheduler_id() {
|
||||||
|
// the thread for slow incoming HTTP connections
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
static td::int32 get_slow_outgoing_http_scheduler_id() {
|
||||||
|
// the thread for slow outgoing HTTP connections
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
static td::int32 get_dns_resolver_scheduler_id() {
|
||||||
|
// the thread for DNS resolving
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
static td::int32 get_binlog_scheduler_id() {
|
||||||
|
// the thread for TQueue and webhook binlogs
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
static td::int32 get_webhook_certificate_scheduler_id() {
|
||||||
|
// the thread for webhook certificate processing
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
static td::int32 get_statistics_thread_id() {
|
||||||
|
// the thread for CPU usage updating
|
||||||
|
return 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
static td::int32 get_thread_count() {
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ClientParameters {
|
struct ClientParameters {
|
||||||
|
@ -72,7 +111,7 @@ struct ClientParameters {
|
||||||
bool local_mode_ = false;
|
bool local_mode_ = false;
|
||||||
bool allow_http_ = false;
|
bool allow_http_ = false;
|
||||||
bool use_relative_path_ = false;
|
bool use_relative_path_ = false;
|
||||||
bool no_file_limit_ = true;
|
bool no_file_limit_ = false;
|
||||||
bool allow_users_ = false;
|
bool allow_users_ = false;
|
||||||
bool allow_users_registration_ = false;
|
bool allow_users_registration_ = false;
|
||||||
bool stats_hide_sensible_data_ = false;
|
bool stats_hide_sensible_data_ = false;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "telegram-bot-api/ClientParameters.h"
|
||||||
|
|
||||||
#include "td/net/HttpInboundConnection.h"
|
#include "td/net/HttpInboundConnection.h"
|
||||||
#include "td/net/TcpListener.h"
|
#include "td/net/TcpListener.h"
|
||||||
|
|
||||||
|
@ -61,13 +63,8 @@ class HttpServer final : public td::TcpListener::Callback {
|
||||||
}
|
}
|
||||||
|
|
||||||
void accept(td::SocketFd fd) final {
|
void accept(td::SocketFd fd) final {
|
||||||
auto scheduler_count = td::Scheduler::instance()->sched_count();
|
|
||||||
auto scheduler_id = scheduler_count - 1;
|
|
||||||
if (scheduler_id > 0) {
|
|
||||||
scheduler_id--;
|
|
||||||
}
|
|
||||||
td::create_actor<td::HttpInboundConnection>("HttpInboundConnection", td::BufferedFd<td::SocketFd>(std::move(fd)), 0,
|
td::create_actor<td::HttpInboundConnection>("HttpInboundConnection", td::BufferedFd<td::SocketFd>(std::move(fd)), 0,
|
||||||
50, 500, creator_(), scheduler_id)
|
50, 500, creator_(), SharedData::get_slow_incoming_http_scheduler_id())
|
||||||
.release();
|
.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ Query::Query(td::vector<td::BufferSlice> &&container, td::Slice token, bool is_u
|
||||||
}
|
}
|
||||||
td::to_lower_inplace(method_);
|
td::to_lower_inplace(method_);
|
||||||
start_timestamp_ = td::Time::now();
|
start_timestamp_ = td::Time::now();
|
||||||
LOG(INFO) << "QUERY: create " << td::tag("ptr", this) << *this;
|
LOG(INFO) << "Query " << this << ": " << *this;
|
||||||
if (shared_data_) {
|
if (shared_data_) {
|
||||||
shared_data_->query_count_.fetch_add(1, std::memory_order_relaxed);
|
shared_data_->query_count_.fetch_add(1, std::memory_order_relaxed);
|
||||||
if (method_ != "getupdates") {
|
if (method_ != "getupdates") {
|
||||||
|
@ -86,7 +86,7 @@ void Query::set_stat_actor(td::ActorId<BotStatActor> stat_actor) {
|
||||||
|
|
||||||
void Query::set_ok(td::BufferSlice result) {
|
void Query::set_ok(td::BufferSlice result) {
|
||||||
CHECK(state_ == State::Query);
|
CHECK(state_ == State::Query);
|
||||||
LOG(INFO) << "QUERY: got ok " << td::tag("ptr", this) << td::tag("text", result.as_slice());
|
LOG(INFO) << "Query " << this << ": " << td::tag("method", method_) << td::tag("text", result.as_slice());
|
||||||
answer_ = std::move(result);
|
answer_ = std::move(result);
|
||||||
state_ = State::OK;
|
state_ = State::OK;
|
||||||
http_status_code_ = 200;
|
http_status_code_ = 200;
|
||||||
|
@ -94,7 +94,7 @@ void Query::set_ok(td::BufferSlice result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Query::set_error(int http_status_code, td::BufferSlice result) {
|
void Query::set_error(int http_status_code, td::BufferSlice result) {
|
||||||
LOG(INFO) << "QUERY: got error " << td::tag("ptr", this) << td::tag("code", http_status_code)
|
LOG(INFO) << "Query " << this << ": " << td::tag("method", method_) << td::tag("code", http_status_code)
|
||||||
<< td::tag("text", result.as_slice());
|
<< td::tag("text", result.as_slice());
|
||||||
CHECK(state_ == State::Query);
|
CHECK(state_ == State::Query);
|
||||||
answer_ = std::move(result);
|
answer_ = std::move(result);
|
||||||
|
@ -116,9 +116,25 @@ td::StringBuilder &operator<<(td::StringBuilder &sb, const Query &query) {
|
||||||
auto padded_time =
|
auto padded_time =
|
||||||
td::lpad(PSTRING() << td::format::as_time(td::Time::now_cached() - query.start_timestamp()), 10, ' ');
|
td::lpad(PSTRING() << td::format::as_time(td::Time::now_cached() - query.start_timestamp()), 10, ' ');
|
||||||
sb << "[bot" << td::rpad(query.token().str(), 46, ' ') << "][time:" << padded_time << ']'
|
sb << "[bot" << td::rpad(query.token().str(), 46, ' ') << "][time:" << padded_time << ']'
|
||||||
<< td::tag("method", td::lpad(query.method().str(), 20, ' '));
|
<< td::tag("method", td::lpad(query.method().str(), 25, ' '));
|
||||||
if (!query.args().empty()) {
|
if (!query.args().empty()) {
|
||||||
sb << td::oneline(PSLICE() << query.args());
|
sb << '{';
|
||||||
|
for (const auto &arg : query.args()) {
|
||||||
|
sb << '[';
|
||||||
|
if (arg.first.size() > 128) {
|
||||||
|
sb << '<' << arg.first.size() << '>' << td::oneline(arg.first.substr(0, 128)) << "...";
|
||||||
|
} else {
|
||||||
|
sb << td::oneline(arg.first);
|
||||||
|
}
|
||||||
|
sb << ':';
|
||||||
|
if (arg.second.size() > 4096) {
|
||||||
|
sb << '<' << arg.second.size() << '>' << td::oneline(arg.second.substr(0, 4096)) << "...";
|
||||||
|
} else {
|
||||||
|
sb << td::oneline(arg.second);
|
||||||
|
}
|
||||||
|
sb << ']';
|
||||||
|
}
|
||||||
|
sb << '}';
|
||||||
}
|
}
|
||||||
if (!query.files().empty()) {
|
if (!query.files().empty()) {
|
||||||
sb << query.files();
|
sb << query.files();
|
||||||
|
|
|
@ -38,41 +38,52 @@ class Query final : public td::ListNode {
|
||||||
td::Slice token() const {
|
td::Slice token() const {
|
||||||
return token_;
|
return token_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_user() const {
|
bool is_user() const {
|
||||||
return is_user_;
|
return is_user_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_test_dc() const {
|
bool is_test_dc() const {
|
||||||
return is_test_dc_;
|
return is_test_dc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Slice method() const {
|
td::Slice method() const {
|
||||||
return method_;
|
return method_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_arg(td::Slice key) const {
|
bool has_arg(td::Slice key) const {
|
||||||
auto it = std::find_if(args_.begin(), args_.end(),
|
auto it = std::find_if(args_.begin(), args_.end(),
|
||||||
[&key](const std::pair<td::MutableSlice, td::MutableSlice> &s) { return s.first == key; });
|
[&key](const std::pair<td::MutableSlice, td::MutableSlice> &s) { return s.first == key; });
|
||||||
return it != args_.end();
|
return it != args_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
td::MutableSlice arg(td::Slice key) const {
|
td::MutableSlice arg(td::Slice key) const {
|
||||||
auto it = std::find_if(args_.begin(), args_.end(),
|
auto it = std::find_if(args_.begin(), args_.end(),
|
||||||
[&key](const std::pair<td::MutableSlice, td::MutableSlice> &s) { return s.first == key; });
|
[&key](const std::pair<td::MutableSlice, td::MutableSlice> &s) { return s.first == key; });
|
||||||
return it == args_.end() ? td::MutableSlice() : it->second;
|
return it == args_.end() ? td::MutableSlice() : it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const td::vector<std::pair<td::MutableSlice, td::MutableSlice>> &args() const {
|
const td::vector<std::pair<td::MutableSlice, td::MutableSlice>> &args() const {
|
||||||
return args_;
|
return args_;
|
||||||
}
|
}
|
||||||
|
|
||||||
td::Slice get_header(td::Slice key) const {
|
td::Slice get_header(td::Slice key) const {
|
||||||
auto it = std::find_if(headers_.begin(), headers_.end(),
|
auto it = std::find_if(headers_.begin(), headers_.end(),
|
||||||
[&key](const std::pair<td::MutableSlice, td::MutableSlice> &s) { return s.first == key; });
|
[&key](const std::pair<td::MutableSlice, td::MutableSlice> &s) { return s.first == key; });
|
||||||
return it == headers_.end() ? td::Slice() : it->second;
|
return it == headers_.end() ? td::Slice() : it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const td::HttpFile *file(td::Slice key) const {
|
const td::HttpFile *file(td::Slice key) const {
|
||||||
auto it = std::find_if(files_.begin(), files_.end(), [&key](const td::HttpFile &f) { return f.field_name == key; });
|
auto it = std::find_if(files_.begin(), files_.end(), [&key](const td::HttpFile &f) { return f.field_name == key; });
|
||||||
return it == files_.end() ? nullptr : &*it;
|
return it == files_.end() ? nullptr : &*it;
|
||||||
}
|
}
|
||||||
|
|
||||||
const td::vector<td::HttpFile> &files() const {
|
const td::vector<td::HttpFile> &files() const {
|
||||||
return files_;
|
return files_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td::int64 files_size() const;
|
||||||
|
|
||||||
td::string get_peer_ip_address() const;
|
td::string get_peer_ip_address() const;
|
||||||
|
|
||||||
td::BufferSlice &answer() {
|
td::BufferSlice &answer() {
|
||||||
|
@ -156,8 +167,6 @@ class Query final : public td::ListNode {
|
||||||
|
|
||||||
td::int64 query_size() const;
|
td::int64 query_size() const;
|
||||||
|
|
||||||
td::int64 files_size() const;
|
|
||||||
|
|
||||||
td::int64 files_max_size() const;
|
td::int64 files_max_size() const;
|
||||||
|
|
||||||
void send_request_stat() const;
|
void send_request_stat() const;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "telegram-bot-api/Stats.h"
|
#include "telegram-bot-api/Stats.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/port/thread.h"
|
#include "td/utils/port/thread.h"
|
||||||
#include "td/utils/SliceBuilder.h"
|
#include "td/utils/SliceBuilder.h"
|
||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
|
@ -19,17 +20,24 @@ ServerCpuStat::ServerCpuStat() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerCpuStat::add_event(const td::CpuStat &cpu_stat, double now) {
|
void ServerCpuStat::update(double now) {
|
||||||
std::lock_guard<std::mutex> guard(mutex_);
|
auto r_cpu_stat = td::cpu_stat();
|
||||||
for (auto &stat : stat_) {
|
if (r_cpu_stat.is_error()) {
|
||||||
stat.add_event(cpu_stat, now);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto &cpu_stat = instance();
|
||||||
|
std::lock_guard<std::mutex> guard(cpu_stat.mutex_);
|
||||||
|
for (auto &stat : cpu_stat.stat_) {
|
||||||
|
stat.add_event(r_cpu_stat.ok(), now);
|
||||||
|
}
|
||||||
|
LOG(WARNING) << "CPU usage: " << cpu_stat.stat_[1].get_stat(now).as_vector()[0].value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
td::string ServerCpuStat::get_description() const {
|
td::string ServerCpuStat::get_description() {
|
||||||
td::string res = "DURATION";
|
td::string res = "DURATION";
|
||||||
for (auto &descr : DESCR) {
|
for (auto &descr : DESCR) {
|
||||||
res += "\t";
|
res += '\t';
|
||||||
res += descr;
|
res += descr;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -37,7 +45,7 @@ td::string ServerCpuStat::get_description() const {
|
||||||
|
|
||||||
static td::string to_percentage(td::uint64 ticks, td::uint64 total_ticks) {
|
static td::string to_percentage(td::uint64 ticks, td::uint64 total_ticks) {
|
||||||
static double multiplier = 100.0 * (td::thread::hardware_concurrency() ? td::thread::hardware_concurrency() : 1);
|
static double multiplier = 100.0 * (td::thread::hardware_concurrency() ? td::thread::hardware_concurrency() : 1);
|
||||||
return PSTRING() << (static_cast<double>(ticks) / static_cast<double>(total_ticks) * multiplier) << "%";
|
return PSTRING() << (static_cast<double>(ticks) / static_cast<double>(total_ticks) * multiplier) << '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
td::vector<StatItem> CpuStat::as_vector() const {
|
td::vector<StatItem> CpuStat::as_vector() const {
|
||||||
|
@ -167,7 +175,7 @@ td::vector<ServerBotStat> BotStatActor::as_json_ready_vector(double now) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
td::string BotStatActor::get_description() const {
|
td::string BotStatActor::get_description() {
|
||||||
td::string res = "DURATION";
|
td::string res = "DURATION";
|
||||||
for (auto &descr : DESCR) {
|
for (auto &descr : DESCR) {
|
||||||
res += "\t";
|
res += "\t";
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/logging.h"
|
|
||||||
#include "td/utils/port/Stat.h"
|
#include "td/utils/port/Stat.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
#include "td/utils/TimedStat.h"
|
#include "td/utils/TimedStat.h"
|
||||||
|
@ -49,16 +48,10 @@ class ServerCpuStat {
|
||||||
static ServerCpuStat stat;
|
static ServerCpuStat stat;
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
static void update(double now) {
|
|
||||||
auto r_event = td::cpu_stat();
|
|
||||||
if (r_event.is_error()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
instance().add_event(r_event.ok(), now);
|
|
||||||
LOG(WARNING) << "CPU usage: " << instance().stat_[1].get_stat(now).as_vector()[0].value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
td::string get_description() const;
|
static void update(double now);
|
||||||
|
|
||||||
|
static td::string get_description();
|
||||||
|
|
||||||
td::vector<StatItem> as_vector(double now);
|
td::vector<StatItem> as_vector(double now);
|
||||||
td::vector<td::vector<StatItem>> as_json_ready_vector(double now);
|
td::vector<td::vector<StatItem>> as_json_ready_vector(double now);
|
||||||
|
@ -72,8 +65,6 @@ class ServerCpuStat {
|
||||||
td::TimedStat<CpuStat> stat_[SIZE];
|
td::TimedStat<CpuStat> stat_[SIZE];
|
||||||
|
|
||||||
ServerCpuStat();
|
ServerCpuStat();
|
||||||
|
|
||||||
void add_event(const td::CpuStat &stat, double now);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ServerBotInfo {
|
class ServerBotInfo {
|
||||||
|
@ -157,7 +148,7 @@ class BotStatActor final : public td::Actor {
|
||||||
}
|
}
|
||||||
|
|
||||||
BotStatActor(const BotStatActor &) = delete;
|
BotStatActor(const BotStatActor &) = delete;
|
||||||
BotStatActor &operator=(const BotStatActor &other) = delete;
|
BotStatActor &operator=(const BotStatActor &) = delete;
|
||||||
BotStatActor(BotStatActor &&) = default;
|
BotStatActor(BotStatActor &&) = default;
|
||||||
BotStatActor &operator=(BotStatActor &&other) noexcept {
|
BotStatActor &operator=(BotStatActor &&other) noexcept {
|
||||||
if (!empty()) {
|
if (!empty()) {
|
||||||
|
@ -185,8 +176,8 @@ class BotStatActor final : public td::Actor {
|
||||||
td::vector<StatItem> as_vector(double now);
|
td::vector<StatItem> as_vector(double now);
|
||||||
td::vector<ServerBotStat> as_json_ready_vector(double now);
|
td::vector<ServerBotStat> as_json_ready_vector(double now);
|
||||||
|
|
||||||
td::string get_description() const;
|
|
||||||
td::vector<td::string> get_jsonable_description() const;
|
td::vector<td::string> get_jsonable_description() const;
|
||||||
|
static td::string get_description();
|
||||||
|
|
||||||
double get_score(double now);
|
double get_score(double now);
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,8 @@ WebhookActor::WebhookActor(td::ActorShared<Callback> callback, td::int64 tqueue_
|
||||||
, fix_ip_address_(fix_ip_address)
|
, fix_ip_address_(fix_ip_address)
|
||||||
, from_db_flag_(from_db_flag)
|
, from_db_flag_(from_db_flag)
|
||||||
, max_connections_(max_connections)
|
, max_connections_(max_connections)
|
||||||
, secret_token_(std::move(secret_token))
|
, secret_token_(std::move(secret_token)) {
|
||||||
, slow_scheduler_id_(td::Scheduler::instance()->sched_count() - 2) {
|
|
||||||
CHECK(max_connections_ > 0);
|
CHECK(max_connections_ > 0);
|
||||||
CHECK(slow_scheduler_id_ > 0);
|
|
||||||
|
|
||||||
if (!cached_ip_address.empty()) {
|
if (!cached_ip_address.empty()) {
|
||||||
auto r_ip_address = td::IPAddress::get_ip_address(cached_ip_address);
|
auto r_ip_address = td::IPAddress::get_ip_address(cached_ip_address);
|
||||||
|
@ -73,7 +71,7 @@ WebhookActor::WebhookActor(td::ActorShared<Callback> callback, td::int64 tqueue_
|
||||||
|
|
||||||
WebhookActor::~WebhookActor() {
|
WebhookActor::~WebhookActor() {
|
||||||
td::Scheduler::instance()->destroy_on_scheduler(SharedData::get_file_gc_scheduler_id(), update_map_, queue_updates_,
|
td::Scheduler::instance()->destroy_on_scheduler(SharedData::get_file_gc_scheduler_id(), update_map_, queue_updates_,
|
||||||
queues_);
|
queues_, ssl_ctx_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebhookActor::relax_wakeup_at(double wakeup_at, const char *source) {
|
void WebhookActor::relax_wakeup_at(double wakeup_at, const char *source) {
|
||||||
|
@ -230,7 +228,8 @@ td::Status WebhookActor::create_connection(td::BufferedFd<td::SocketFd> fd) {
|
||||||
auto *conn = connections_.get(id);
|
auto *conn = connections_.get(id);
|
||||||
conn->actor_id_ = td::create_actor<td::HttpOutboundConnection>(
|
conn->actor_id_ = td::create_actor<td::HttpOutboundConnection>(
|
||||||
PSLICE() << "Connect:" << id, std::move(fd), std::move(ssl_stream), 0, 50, 60,
|
PSLICE() << "Connect:" << id, std::move(fd), std::move(ssl_stream), 0, 50, 60,
|
||||||
td::ActorShared<td::HttpOutboundConnection::Callback>(actor_id(this), id), slow_scheduler_id_);
|
td::ActorShared<td::HttpOutboundConnection::Callback>(actor_id(this), id),
|
||||||
|
SharedData::get_slow_outgoing_http_scheduler_id());
|
||||||
conn->ip_generation_ = ip_generation_;
|
conn->ip_generation_ = ip_generation_;
|
||||||
conn->event_id_ = {};
|
conn->event_id_ = {};
|
||||||
conn->id_ = id;
|
conn->id_ = id;
|
||||||
|
@ -623,10 +622,12 @@ void WebhookActor::handle(td::unique_ptr<td::HttpQuery> response) {
|
||||||
if (!method.empty() && method != "deletewebhook" && method != "setwebhook" && method != "close" &&
|
if (!method.empty() && method != "deletewebhook" && method != "setwebhook" && method != "close" &&
|
||||||
method != "logout" && !td::begins_with(method, "get")) {
|
method != "logout" && !td::begins_with(method, "get")) {
|
||||||
VLOG(webhook) << "Receive request " << method << " in response to webhook";
|
VLOG(webhook) << "Receive request " << method << " in response to webhook";
|
||||||
auto query = td::make_unique<Query>(std::move(response->container_), td::MutableSlice(), false, false,
|
response->container_.emplace_back(PSLICE() << (tqueue_id_ & ((static_cast<td::int64>(1) << 54) - 1)));
|
||||||
td::MutableSlice(), std::move(response->args_),
|
auto token = response->container_.back().as_slice();
|
||||||
std::move(response->headers_), std::move(response->files_),
|
auto query = td::make_unique<Query>(
|
||||||
parameters_->shared_data_, response->peer_address_, false);
|
std::move(response->container_), token, tqueue_id_ >= (static_cast<td::int64>(1) << 54), false,
|
||||||
|
td::MutableSlice(), std::move(response->args_), std::move(response->headers_),
|
||||||
|
std::move(response->files_), parameters_->shared_data_, response->peer_address_, false);
|
||||||
auto promised_query = PromisedQueryPtr(query.release(), PromiseDeleter(td::Promise<td::unique_ptr<Query>>()));
|
auto promised_query = PromisedQueryPtr(query.release(), PromiseDeleter(td::Promise<td::unique_ptr<Query>>()));
|
||||||
send_closure(callback_, &Callback::send, std::move(promised_query));
|
send_closure(callback_, &Callback::send, std::move(promised_query));
|
||||||
}
|
}
|
||||||
|
@ -690,7 +691,12 @@ void WebhookActor::handle(td::unique_ptr<td::HttpQuery> response) {
|
||||||
void WebhookActor::start_up() {
|
void WebhookActor::start_up() {
|
||||||
max_loaded_updates_ = max_connections_ * 2;
|
max_loaded_updates_ = max_connections_ * 2;
|
||||||
|
|
||||||
next_ip_address_resolve_time_ = last_success_time_ = td::Time::now() - 3600;
|
last_success_time_ = td::Time::now() - 2 * IP_ADDRESS_CACHE_TIME;
|
||||||
|
if (from_db_flag_) {
|
||||||
|
next_ip_address_resolve_time_ = td::Time::now() + td::Random::fast(0, IP_ADDRESS_CACHE_TIME);
|
||||||
|
} else {
|
||||||
|
next_ip_address_resolve_time_ = last_success_time_;
|
||||||
|
}
|
||||||
|
|
||||||
active_new_connection_flood_.add_limit(0.5, 10);
|
active_new_connection_flood_.add_limit(0.5, 10);
|
||||||
|
|
||||||
|
@ -723,11 +729,12 @@ void WebhookActor::start_up() {
|
||||||
|
|
||||||
if (url_.protocol_ != td::HttpUrl::Protocol::Http && !stop_flag_) {
|
if (url_.protocol_ != td::HttpUrl::Protocol::Http && !stop_flag_) {
|
||||||
// asynchronously create SSL context
|
// asynchronously create SSL context
|
||||||
td::Scheduler::instance()->run_on_scheduler(
|
td::Scheduler::instance()->run_on_scheduler(SharedData::get_webhook_certificate_scheduler_id(),
|
||||||
SharedData::get_database_scheduler_id(), [actor_id = actor_id(this), cert_path = cert_path_](td::Unit) mutable {
|
[actor_id = actor_id(this), cert_path = cert_path_](td::Unit) mutable {
|
||||||
send_closure(actor_id, &WebhookActor::on_ssl_context_created,
|
send_closure(
|
||||||
td::SslCtx::create(cert_path, td::SslCtx::VerifyPeer::On));
|
actor_id, &WebhookActor::on_ssl_context_created,
|
||||||
});
|
td::SslCtx::create(cert_path, td::SslCtx::VerifyPeer::On));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
yield();
|
yield();
|
||||||
|
|
|
@ -177,7 +177,6 @@ class WebhookActor final : public td::HttpOutboundConnection::Callback {
|
||||||
double last_success_time_ = 0;
|
double last_success_time_ = 0;
|
||||||
double wakeup_at_ = 0;
|
double wakeup_at_ = 0;
|
||||||
bool last_update_was_successful_ = true;
|
bool last_update_was_successful_ = true;
|
||||||
td::int32 slow_scheduler_id_ = -1;
|
|
||||||
|
|
||||||
void relax_wakeup_at(double wakeup_at, const char *source);
|
void relax_wakeup_at(double wakeup_at, const char *source);
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ int main(int argc, char *argv[]) {
|
||||||
auto start_time = td::Time::now();
|
auto start_time = td::Time::now();
|
||||||
auto shared_data = std::make_shared<SharedData>();
|
auto shared_data = std::make_shared<SharedData>();
|
||||||
auto parameters = std::make_unique<ClientParameters>();
|
auto parameters = std::make_unique<ClientParameters>();
|
||||||
parameters->version_ = "6.7.1";
|
parameters->version_ = "7.0";
|
||||||
parameters->shared_data_ = shared_data;
|
parameters->shared_data_ = shared_data;
|
||||||
parameters->start_time_ = start_time;
|
parameters->start_time_ = start_time;
|
||||||
auto net_query_stats = td::create_net_query_stats();
|
auto net_query_stats = td::create_net_query_stats();
|
||||||
|
@ -476,27 +476,22 @@ int main(int argc, char *argv[]) {
|
||||||
// << (td::GitInfo::is_dirty() ? "(dirty)" : "") << " started";
|
// << (td::GitInfo::is_dirty() ? "(dirty)" : "") << " started";
|
||||||
LOG(WARNING) << "TDLight Bot API " << parameters->version_ << " server started";
|
LOG(WARNING) << "TDLight Bot API " << parameters->version_ << " server started";
|
||||||
|
|
||||||
// +3 threads for Td
|
td::ConcurrentScheduler sched(SharedData::get_thread_count() - 1, cpu_affinity);
|
||||||
// one thread for ClientManager and all Clients
|
|
||||||
// one thread for watchdogs
|
|
||||||
// one thread for slow HTTP connections
|
|
||||||
// one thread for DNS resolving
|
|
||||||
const int thread_count = 7;
|
|
||||||
td::ConcurrentScheduler sched(thread_count, cpu_affinity);
|
|
||||||
|
|
||||||
td::GetHostByNameActor::Options get_host_by_name_options;
|
td::GetHostByNameActor::Options get_host_by_name_options;
|
||||||
get_host_by_name_options.scheduler_id = thread_count;
|
get_host_by_name_options.scheduler_id = SharedData::get_dns_resolver_scheduler_id();
|
||||||
parameters->get_host_by_name_actor_id_ =
|
parameters->get_host_by_name_actor_id_ =
|
||||||
sched.create_actor_unsafe<td::GetHostByNameActor>(0, "GetHostByName", std::move(get_host_by_name_options))
|
sched.create_actor_unsafe<td::GetHostByNameActor>(0, "GetHostByName", std::move(get_host_by_name_options))
|
||||||
.release();
|
.release();
|
||||||
|
|
||||||
auto client_manager =
|
auto client_manager = sched
|
||||||
sched.create_actor_unsafe<ClientManager>(thread_count - 3, "ClientManager", std::move(parameters), token_range)
|
.create_actor_unsafe<ClientManager>(SharedData::get_client_scheduler_id(), "ClientManager",
|
||||||
.release();
|
std::move(parameters), token_range)
|
||||||
|
.release();
|
||||||
|
|
||||||
sched
|
sched
|
||||||
.create_actor_unsafe<HttpServer>(
|
.create_actor_unsafe<HttpServer>(
|
||||||
thread_count - 3, "HttpServer", http_ip_address, http_port,
|
SharedData::get_client_scheduler_id(), "HttpServer", http_ip_address, http_port,
|
||||||
[client_manager, shared_data] {
|
[client_manager, shared_data] {
|
||||||
return td::ActorOwn<td::HttpInboundConnection::Callback>(
|
return td::ActorOwn<td::HttpInboundConnection::Callback>(
|
||||||
td::create_actor<HttpConnection>("HttpConnection", client_manager, shared_data));
|
td::create_actor<HttpConnection>("HttpConnection", client_manager, shared_data));
|
||||||
|
@ -506,7 +501,7 @@ int main(int argc, char *argv[]) {
|
||||||
if (http_stat_port != 0) {
|
if (http_stat_port != 0) {
|
||||||
sched
|
sched
|
||||||
.create_actor_unsafe<HttpServer>(
|
.create_actor_unsafe<HttpServer>(
|
||||||
thread_count - 3, "HttpStatsServer", http_stat_ip_address, http_stat_port,
|
SharedData::get_client_scheduler_id(), "HttpStatsServer", http_stat_ip_address, http_stat_port,
|
||||||
[client_manager] {
|
[client_manager] {
|
||||||
return td::ActorOwn<td::HttpInboundConnection::Callback>(
|
return td::ActorOwn<td::HttpInboundConnection::Callback>(
|
||||||
td::create_actor<HttpStatConnection>("HttpStatConnection", client_manager));
|
td::create_actor<HttpStatConnection>("HttpStatConnection", client_manager));
|
||||||
|
@ -515,8 +510,8 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr double WATCHDOG_TIMEOUT = 0.25;
|
constexpr double WATCHDOG_TIMEOUT = 0.25;
|
||||||
auto watchdog_id =
|
auto watchdog_id = sched.create_actor_unsafe<Watchdog>(SharedData::get_watchdog_scheduler_id(), "Watchdog",
|
||||||
sched.create_actor_unsafe<Watchdog>(thread_count - 2, "Watchdog", td::this_thread::get_id(), WATCHDOG_TIMEOUT);
|
td::this_thread::get_id(), WATCHDOG_TIMEOUT);
|
||||||
|
|
||||||
sched.start();
|
sched.start();
|
||||||
|
|
||||||
|
@ -578,13 +573,15 @@ int main(int argc, char *argv[]) {
|
||||||
next_cron_time = now;
|
next_cron_time = now;
|
||||||
}
|
}
|
||||||
next_cron_time += 1.0;
|
next_cron_time += 1.0;
|
||||||
ServerCpuStat::update(now);
|
auto guard = sched.get_main_guard();
|
||||||
|
td::Scheduler::instance()->run_on_scheduler(SharedData::get_statistics_thread_id(),
|
||||||
|
[](td::Unit) { ServerCpuStat::update(td::Time::now()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now >= start_time + 600) {
|
if (now >= start_time + 600) {
|
||||||
auto guard = sched.get_main_guard();
|
auto guard = sched.get_main_guard();
|
||||||
send_closure(watchdog_id, &Watchdog::kick);
|
send_closure(watchdog_id, &Watchdog::kick);
|
||||||
next_watchdog_kick_time = now + WATCHDOG_TIMEOUT / 2;
|
next_watchdog_kick_time = now + WATCHDOG_TIMEOUT / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!need_dump_statistics.test_and_set() || now > last_dump_time + 300.0) {
|
if (!need_dump_statistics.test_and_set() || now > last_dump_time + 300.0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user