Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Giuseppe Marino 2023-03-11 12:05:34 +01:00
commit 76e5967b72
No known key found for this signature in database
GPG Key ID: C26F7A532ADEC25E
9 changed files with 1549 additions and 1056 deletions

View File

@ -4,15 +4,36 @@ Language: Cpp
AccessModifierOffset: -1 AccessModifierOffset: -1
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignArrayOfStructures: None AlignArrayOfStructures: None
AlignConsecutiveMacros: None AlignConsecutiveAssignments:
AlignConsecutiveAssignments: None Enabled: false
AlignConsecutiveBitFields: None AcrossEmptyLines: false
AlignConsecutiveDeclarations: None AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: Left AlignEscapedNewlines: Left
AlignOperands: Align AlignOperands: Align
AlignTrailingComments: true AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
@ -25,6 +46,8 @@ AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes AlwaysBreakTemplateDeclarations: Yes
# AttributeMacros:
# - __capability
BinPackArguments: true BinPackArguments: true
BinPackParameters: true BinPackParameters: true
BitFieldColonSpacing: Both BitFieldColonSpacing: Both
@ -33,12 +56,12 @@ BraceWrapping:
AfterClass: false AfterClass: false
AfterControlStatement: Never AfterControlStatement: Never
AfterEnum: false AfterEnum: false
AfterExternBlock: false
AfterFunction: false AfterFunction: false
AfterNamespace: false AfterNamespace: false
AfterObjCDeclaration: false AfterObjCDeclaration: false
AfterStruct: false AfterStruct: false
AfterUnion: false AfterUnion: false
AfterExternBlock: false
BeforeCatch: false BeforeCatch: false
BeforeElse: false BeforeElse: false
BeforeLambdaBody: false BeforeLambdaBody: false
@ -47,24 +70,23 @@ BraceWrapping:
SplitEmptyFunction: true SplitEmptyFunction: true
SplitEmptyRecord: true SplitEmptyRecord: true
SplitEmptyNamespace: true SplitEmptyNamespace: true
BreakAfterAttributes: Never
# BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach BreakBeforeBraces: Attach
BreakBeforeConceptDeclarations: true BreakBeforeConceptDeclarations: Always
BreakBeforeInheritanceComma: true # false BreakBeforeInlineASMColon: OnlyMultiline
BreakInheritanceList: BeforeComma # BeforeColon
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true # false
BreakConstructorInitializers: BeforeComma # BeforeColon BreakConstructorInitializers: BeforeComma # BeforeColon
# BreakAfterJavaFieldAnnotations: false BreakInheritanceList: BeforeComma # BeforeColon
BreakStringLiterals: true BreakStringLiterals: true
ColumnLimit: 120 # 80 ColumnLimit: 120 # 80
CommentPragmas: '^ IWYU pragma:' CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4 ContinuationIndentWidth: 4
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true DerivePointerAlignment: true
DisableFormat: false DisableFormat: false
EmptyLineAfterAccessModifier: Never EmptyLineAfterAccessModifier: Never
@ -83,14 +105,21 @@ IndentCaseLabels: true
IndentExternBlock: AfterExternBlock IndentExternBlock: AfterExternBlock
IndentGotoLabels: true IndentGotoLabels: true
IndentPPDirectives: None IndentPPDirectives: None
IndentRequires: false IndentRequiresClause: true
IndentWidth: 2 IndentWidth: 2
IndentWrappedFunctionNames: false IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
# InsertTrailingCommas: None # InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
Decimal: 0
Hex: 0
# JavaScriptQuotes: Leave # JavaScriptQuotes: Leave
# JavaScriptWrapImports: true # JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: '' MacroBlockBegin: ''
MacroBlockEnd: '' MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
@ -100,23 +129,31 @@ NamespaceIndentation: None
# ObjCBreakBeforeNestedBlockParam: true # ObjCBreakBeforeNestedBlockParam: true
# ObjCSpaceAfterProperty: false # ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true # ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2 PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1 PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300 PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120 PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000 PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10 PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0 PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200 PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right PointerAlignment: Right # Left
PPIndentWidth: -1 PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer ReferenceAlignment: Pointer
ReflowComments: false # true ReflowComments: false # true
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 0 # 1 ShortNamespaceLines: 0 # 1
SortIncludes: CaseInsensitive # CaseSensitive SortIncludes: CaseInsensitive # CaseSensitive
# SortJavaStaticImport: Before # SortJavaStaticImport: Before
SortUsingDeclarations: false # true SortUsingDeclarations: Lexicographic # LexicographicNumeric
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true SpaceAfterTemplateKeyword: true
@ -127,6 +164,16 @@ SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false SpaceInEmptyBlock: false
@ -143,6 +190,5 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: Auto Standard: Auto
TabWidth: 100 # 8 TabWidth: 100 # 8
UseCRLF: false
UseTab: Never UseTab: Never
... ...

View File

@ -6,7 +6,7 @@ if (POLICY CMP0065)
cmake_policy(SET CMP0065 NEW) cmake_policy(SET CMP0065 NEW)
endif() endif()
project(TelegramBotApi VERSION 6.5 LANGUAGES CXX) project(TelegramBotApi VERSION 6.6 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.")

2
td

@ -1 +1 @@
Subproject commit 3179d35694a28267a0b6273fc9b5bdce3b6b1235 Subproject commit 70bee089d492437ce931aa78446d89af3da182fc

File diff suppressed because it is too large Load Diff

View File

@ -60,9 +60,6 @@ class Client final : public WebhookActor::Callback {
using int32 = td::int32; using int32 = td::int32;
using int64 = td::int64; using int64 = td::int64;
using Slice = td::Slice;
using Status = td::Status;
template <class T> template <class T>
using object_ptr = td_api::object_ptr<T>; using object_ptr = td_api::object_ptr<T>;
@ -78,26 +75,28 @@ class Client final : public WebhookActor::Callback {
static constexpr std::size_t MIN_PENDING_UPDATES_WARNING = 200; static constexpr std::size_t MIN_PENDING_UPDATES_WARNING = 200;
static constexpr int64 GREAT_MINDS_SET_ID = 1842540969984001; static constexpr int64 GREAT_MINDS_SET_ID = 1842540969984001;
static constexpr Slice GREAT_MINDS_SET_NAME = "TelegramGreatMinds"; static constexpr td::Slice GREAT_MINDS_SET_NAME = "TelegramGreatMinds";
static constexpr int32 MASK_POINTS_SIZE = 4; static constexpr int32 MASK_POINTS_SIZE = 4;
static constexpr Slice MASK_POINTS[MASK_POINTS_SIZE] = {"forehead", "eyes", "mouth", "chin"}; static constexpr td::Slice MASK_POINTS[MASK_POINTS_SIZE] = {"forehead", "eyes", "mouth", "chin"};
static constexpr int32 MAX_LENGTH = 10000; // max width or height static constexpr int32 MAX_LENGTH = 10000; // max width or height
static constexpr int32 MAX_DURATION = 24 * 60 * 60; static constexpr int32 MAX_DURATION = 24 * 60 * 60;
static constexpr std::size_t MAX_STICKER_EMOJI_COUNT = 20;
static constexpr int LOGGING_OUT_ERROR_CODE = 401; static constexpr int LOGGING_OUT_ERROR_CODE = 401;
static constexpr Slice LOGGING_OUT_ERROR_DESCRIPTION = "Unauthorized"; static constexpr td::Slice LOGGING_OUT_ERROR_DESCRIPTION = "Unauthorized";
static constexpr Slice API_ID_INVALID_ERROR_DESCRIPTION = "Unauthorized: invalid api-id/api-hash"; static constexpr td::Slice API_ID_INVALID_ERROR_DESCRIPTION = "Unauthorized: invalid api-id/api-hash";
static constexpr int CLOSING_ERROR_CODE = 500; static constexpr int CLOSING_ERROR_CODE = 500;
static constexpr Slice CLOSING_ERROR_DESCRIPTION = "Internal Server Error: restart"; static constexpr td::Slice CLOSING_ERROR_DESCRIPTION = "Internal Server Error: restart";
static constexpr int BOT_ONLY_ERROR_CODE = 405; static constexpr int BOT_ONLY_ERROR_CODE = 405;
static constexpr Slice BOT_ONLY_ERROR_DESCRIPTION = "Method Not Allowed: You can only use this method as a bot"; static constexpr td::Slice BOT_ONLY_ERROR_DESCRIPTION = "Method Not Allowed: You can only use this method as a bot";
static constexpr int USER_ONLY_ERROR_CODE = 405; static constexpr int USER_ONLY_ERROR_CODE = 405;
static constexpr Slice USER_ONLY_ERROR_DESCRIPTION = "Method Not Allowed: You can only use this method as a user"; static constexpr td::Slice USER_ONLY_ERROR_DESCRIPTION = "Method Not Allowed: You can only use this method as a user";
class JsonEmptyObject; class JsonEmptyObject;
class JsonFile; class JsonFile;
@ -151,6 +150,8 @@ class Client final : public WebhookActor::Callback {
class JsonPreCheckoutQuery; class JsonPreCheckoutQuery;
class JsonBotCommand; class JsonBotCommand;
class JsonBotMenuButton; class JsonBotMenuButton;
class JsonBotInfoDescription;
class JsonBotInfoShortDescription;
class JsonChatAdministratorRights; class JsonChatAdministratorRights;
class JsonChatPhotos; class JsonChatPhotos;
class JsonChatMember; class JsonChatMember;
@ -173,6 +174,7 @@ class Client final : public WebhookActor::Callback {
class JsonVideoChatEnded; class JsonVideoChatEnded;
class JsonInviteVideoChatParticipants; class JsonInviteVideoChatParticipants;
class JsonChatSetMessageAutoDeleteTime; class JsonChatSetMessageAutoDeleteTime;
class JsonWriteAccessAllowed;
class JsonUserShared; class JsonUserShared;
class JsonChatShared; class JsonChatShared;
class JsonUpdateTypes; class JsonUpdateTypes;
@ -212,6 +214,8 @@ class Client final : public WebhookActor::Callback {
class TdOnGetMenuButtonCallback; class TdOnGetMenuButtonCallback;
class TdOnGetMyCommandsCallback; class TdOnGetMyCommandsCallback;
class TdOnGetMyDefaultAdministratorRightsCallback; class TdOnGetMyDefaultAdministratorRightsCallback;
class TdOnGetMyDescriptionCallback;
class TdOnGetMyShortDescriptionCallback;
class TdOnGetChatFullInfoCallback; class TdOnGetChatFullInfoCallback;
class TdOnGetChatStickerSetCallback; class TdOnGetChatStickerSetCallback;
class TdOnGetChatPinnedMessageCallback; class TdOnGetChatPinnedMessageCallback;
@ -316,18 +320,10 @@ class Client final : public WebhookActor::Callback {
OnSuccess on_success) const; OnSuccess on_success) const;
template <class OnSuccess> template <class OnSuccess>
void check_chat(Slice chat_id_str, AccessRights access_rights, PromisedQueryPtr query, OnSuccess on_success); void check_chat(td::Slice chat_id_str, AccessRights access_rights, PromisedQueryPtr query, OnSuccess on_success);
template <class OnSuccess> template <class OnSuccess>
void disable_internet_connection(PromisedQueryPtr query, OnSuccess on_success); void check_chat_no_fail(td::Slice chat_id_str, PromisedQueryPtr query, OnSuccess on_success);
template <class OnSuccess>
void optimize_memory(PromisedQueryPtr query, OnSuccess on_success);
void enable_internet_connection(PromisedQueryPtr query);
template <class OnSuccess>
void check_chat_no_fail(Slice chat_id_str, PromisedQueryPtr query, OnSuccess on_success);
template <class OnSuccess> template <class OnSuccess>
void check_bot_command_scope(BotCommandScope &&scope, PromisedQueryPtr query, OnSuccess on_success); void check_bot_command_scope(BotCommandScope &&scope, PromisedQueryPtr query, OnSuccess on_success);
@ -336,8 +332,8 @@ class Client final : public WebhookActor::Callback {
void check_remote_file_id(td::string file_id, PromisedQueryPtr query, OnSuccess on_success); void check_remote_file_id(td::string file_id, PromisedQueryPtr query, OnSuccess on_success);
template <class OnSuccess> template <class OnSuccess>
void check_message(Slice chat_id_str, int64 message_id, bool allow_empty, AccessRights access_rights, void check_message(td::Slice chat_id_str, int64 message_id, bool allow_empty, AccessRights access_rights,
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_message_thread(int64 chat_id, int64 message_thread_id, int64 reply_to_message_id, PromisedQueryPtr query,
@ -364,7 +360,7 @@ class Client final : public WebhookActor::Callback {
void on_result(td::uint64 id, object_ptr<td_api::Object> result); void on_result(td::uint64 id, object_ptr<td_api::Object> result);
void on_update_authorization_state(); void on_update_authorization_state();
void log_out(int32 error_code, Slice error_message); void log_out(int32 error_code, td::Slice error_message);
void on_closed(); void on_closed();
void finish_closing(); void finish_closing();
@ -402,14 +398,20 @@ class Client final : public WebhookActor::Callback {
static object_ptr<td_api::ChatAction> get_chat_action(const Query *query); static object_ptr<td_api::ChatAction> get_chat_action(const Query *query);
static td::string get_local_file_path(Slice file_uri); static td::string get_local_file_path(td::Slice file_uri);
object_ptr<td_api::InputFile> get_input_file(const Query *query, Slice field_name, bool force_file = false) const; object_ptr<td_api::InputFile> get_input_file(const Query *query, td::Slice field_name, bool force_file = false) const;
object_ptr<td_api::InputFile> get_input_file(const Query *query, Slice field_name, Slice file_id, object_ptr<td_api::InputFile> get_input_file(const Query *query, td::Slice field_name, td::Slice file_id,
bool force_file) const; bool force_file) const;
object_ptr<td_api::inputThumbnail> get_input_thumbnail(const Query *query, Slice field_name) const; object_ptr<td_api::inputThumbnail> get_input_thumbnail(const Query *query) const;
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);
td::Result<object_ptr<td_api::InputInlineQueryResult>> get_inline_query_result(const Query *query); td::Result<object_ptr<td_api::InputInlineQueryResult>> get_inline_query_result(const Query *query);
@ -422,10 +424,10 @@ class Client final : public WebhookActor::Callback {
struct BotCommandScope { struct BotCommandScope {
object_ptr<td_api::BotCommandScope> scope_; object_ptr<td_api::BotCommandScope> scope_;
td::string chat_id_; td::string chat_id_;
td::int64 user_id_ = 0; int64 user_id_ = 0;
explicit BotCommandScope(object_ptr<td_api::BotCommandScope> scope, td::string chat_id = td::string(), explicit BotCommandScope(object_ptr<td_api::BotCommandScope> scope, td::string chat_id = td::string(),
td::int64 user_id = 0) int64 user_id = 0)
: scope_(std::move(scope)), chat_id_(std::move(chat_id)), user_id_(user_id) { : scope_(std::move(scope)), chat_id_(std::move(chat_id)), user_id_(user_id) {
} }
}; };
@ -446,7 +448,7 @@ class Client final : public WebhookActor::Callback {
static td::Result<object_ptr<td_api::chatAdministratorRights>> get_chat_administrator_rights(const Query *query); static td::Result<object_ptr<td_api::chatAdministratorRights>> get_chat_administrator_rights(const Query *query);
static td::Result<object_ptr<td_api::maskPosition>> get_mask_position(const Query *query, Slice field_name); static td::Result<object_ptr<td_api::maskPosition>> get_mask_position(const Query *query, td::Slice field_name);
static td::Result<object_ptr<td_api::maskPosition>> get_mask_position(td::JsonValue &&value); static td::Result<object_ptr<td_api::maskPosition>> get_mask_position(td::JsonValue &&value);
@ -454,9 +456,22 @@ class Client final : public WebhookActor::Callback {
static object_ptr<td_api::MaskPoint> mask_index_to_point(int32 index); static object_ptr<td_api::MaskPoint> mask_index_to_point(int32 index);
td::Result<td::vector<object_ptr<td_api::inputSticker>>> get_input_stickers(const Query *query) const; static td::Result<td::string> get_sticker_emojis(td::JsonValue &&value);
static td::Result<td::string> get_passport_element_hash(Slice encoded_hash); static td::Result<td::string> get_sticker_emojis(td::MutableSlice emoji_list);
static td::Result<object_ptr<td_api::StickerFormat>> get_sticker_format(td::Slice sticker_format);
td::Result<object_ptr<td_api::inputSticker>> get_input_sticker(const Query *query) const;
td::Result<object_ptr<td_api::inputSticker>> get_input_sticker(const Query *query, td::JsonValue &&value) const;
td::Result<td::vector<object_ptr<td_api::inputSticker>>> get_input_stickers(
const Query *query, object_ptr<td_api::StickerFormat> &sticker_format) const;
static td::Result<object_ptr<td_api::InputFile>> get_sticker_input_file(const Query *query);
static td::Result<td::string> get_passport_element_hash(td::Slice encoded_hash);
static td::Result<object_ptr<td_api::InputPassportElementErrorSource>> get_passport_element_error_source( static td::Result<object_ptr<td_api::InputPassportElementErrorSource>> get_passport_element_error_source(
td::JsonObject &object); td::JsonObject &object);
@ -466,7 +481,7 @@ class Client final : public WebhookActor::Callback {
static td::Result<td::vector<object_ptr<td_api::inputPassportElementError>>> get_passport_element_errors( static td::Result<td::vector<object_ptr<td_api::inputPassportElementError>>> get_passport_element_errors(
const Query *query); const Query *query);
static td::JsonValue get_input_entities(const Query *query, Slice field_name); static td::JsonValue get_input_entities(const Query *query, td::Slice field_name);
static td::Result<object_ptr<td_api::formattedText>> get_caption(const Query *query); static td::Result<object_ptr<td_api::formattedText>> get_caption(const Query *query);
@ -492,10 +507,10 @@ class Client final : public WebhookActor::Callback {
td::Result<object_ptr<td_api::InputMessageContent>> get_input_media(const Query *query, td::JsonValue &&input_media, td::Result<object_ptr<td_api::InputMessageContent>> get_input_media(const Query *query, td::JsonValue &&input_media,
bool for_album) const; bool for_album) const;
td::Result<object_ptr<td_api::InputMessageContent>> get_input_media(const Query *query, Slice field_name) const; td::Result<object_ptr<td_api::InputMessageContent>> get_input_media(const Query *query, td::Slice field_name) const;
td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents(const Query *query, td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents(
Slice field_name) const; const Query *query, td::Slice field_name) const;
td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents( td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents(
const Query *query, td::JsonValue &&value) const; const Query *query, td::JsonValue &&value) const;
@ -508,17 +523,18 @@ 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 int32 get_integer_arg(const Query *query, 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());
static td::Result<td::MutableSlice> get_required_string_arg(const Query *query, Slice field_name); static td::Result<td::MutableSlice> get_required_string_arg(const Query *query, td::Slice field_name);
static int64 get_message_id(const Query *query, Slice field_name = Slice("message_id")); static int64 get_message_id(const Query *query, td::Slice field_name = td::Slice("message_id"));
static td::Result<Slice> get_inline_message_id(const Query *query, Slice field_name = Slice("inline_message_id")); static td::Result<td::Slice> get_inline_message_id(const Query *query,
td::Slice field_name = td::Slice("inline_message_id"));
static td::Result<int64> get_user_id(const Query *query, Slice field_name = Slice("user_id")); static td::Result<int64> get_user_id(const Query *query, td::Slice field_name = td::Slice("user_id"));
void decrease_yet_unsent_message_count(int64 chat_id, int32 count); void decrease_yet_unsent_message_count(int64 chat_id, int32 count);
@ -529,159 +545,168 @@ class Client final : public WebhookActor::Callback {
static td::Result<object_ptr<td_api::MessageSchedulingState>> get_message_scheduling_state(const Query *query); static td::Result<object_ptr<td_api::MessageSchedulingState>> get_message_scheduling_state(const Query *query);
template <class T> template <class T>
static td::Result<td::vector<T>> get_int_array_arg(const Query *query, Slice field_name, bool optional = false); static td::Result<td::vector<T>> get_int_array_arg(const Query *query, td::Slice field_name, bool optional = false);
static int64 get_int64_arg(const Query *query, 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::ChatReportReason>> get_report_reason(const Query *query,
Slice field_name = 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(
const Query *query, Slice field_name = Slice("filter")); const Query *query, td::Slice field_name = td::Slice("filter"));
// 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, Status result); void on_message_send_failed(int64 chat_id, int64 old_message_id, int64 new_message_id, td::Status result);
static bool init_methods(); static bool init_methods();
static bool is_local_method(Slice method); static bool is_local_method(td::Slice method);
void on_cmd(PromisedQueryPtr query); void on_cmd(PromisedQueryPtr query);
Status process_get_me_query(PromisedQueryPtr &query); td::Status process_get_me_query(PromisedQueryPtr &query);
Status process_get_my_commands_query(PromisedQueryPtr &query); td::Status process_get_my_commands_query(PromisedQueryPtr &query);
Status process_set_my_commands_query(PromisedQueryPtr &query); td::Status process_set_my_commands_query(PromisedQueryPtr &query);
Status process_delete_my_commands_query(PromisedQueryPtr &query); td::Status process_delete_my_commands_query(PromisedQueryPtr &query);
Status process_get_my_default_administrator_rights_query(PromisedQueryPtr &query); td::Status process_get_my_default_administrator_rights_query(PromisedQueryPtr &query);
Status process_set_my_default_administrator_rights_query(PromisedQueryPtr &query); td::Status process_set_my_default_administrator_rights_query(PromisedQueryPtr &query);
Status process_get_chat_menu_button_query(PromisedQueryPtr &query); td::Status process_get_my_description_query(PromisedQueryPtr &query);
Status process_set_chat_menu_button_query(PromisedQueryPtr &query); td::Status process_set_my_description_query(PromisedQueryPtr &query);
Status process_get_user_profile_photos_query(PromisedQueryPtr &query); td::Status process_get_my_short_description_query(PromisedQueryPtr &query);
Status process_send_message_query(PromisedQueryPtr &query); td::Status process_set_my_short_description_query(PromisedQueryPtr &query);
Status process_send_animation_query(PromisedQueryPtr &query); td::Status process_get_chat_menu_button_query(PromisedQueryPtr &query);
Status process_send_audio_query(PromisedQueryPtr &query); td::Status process_set_chat_menu_button_query(PromisedQueryPtr &query);
Status process_send_dice_query(PromisedQueryPtr &query); td::Status process_get_user_profile_photos_query(PromisedQueryPtr &query);
Status process_send_document_query(PromisedQueryPtr &query); td::Status process_send_message_query(PromisedQueryPtr &query);
Status process_send_photo_query(PromisedQueryPtr &query); td::Status process_send_animation_query(PromisedQueryPtr &query);
Status process_send_sticker_query(PromisedQueryPtr &query); td::Status process_send_audio_query(PromisedQueryPtr &query);
Status process_send_video_query(PromisedQueryPtr &query); td::Status process_send_dice_query(PromisedQueryPtr &query);
Status process_send_video_note_query(PromisedQueryPtr &query); td::Status process_send_document_query(PromisedQueryPtr &query);
Status process_send_voice_query(PromisedQueryPtr &query); td::Status process_send_photo_query(PromisedQueryPtr &query);
Status process_send_game_query(PromisedQueryPtr &query); td::Status process_send_sticker_query(PromisedQueryPtr &query);
Status process_send_invoice_query(PromisedQueryPtr &query); td::Status process_send_video_query(PromisedQueryPtr &query);
Status process_send_location_query(PromisedQueryPtr &query); td::Status process_send_video_note_query(PromisedQueryPtr &query);
Status process_send_venue_query(PromisedQueryPtr &query); td::Status process_send_voice_query(PromisedQueryPtr &query);
Status process_send_contact_query(PromisedQueryPtr &query); td::Status process_send_game_query(PromisedQueryPtr &query);
Status process_send_poll_query(PromisedQueryPtr &query); td::Status process_send_invoice_query(PromisedQueryPtr &query);
Status process_stop_poll_query(PromisedQueryPtr &query); td::Status process_send_location_query(PromisedQueryPtr &query);
Status process_copy_message_query(PromisedQueryPtr &query); td::Status process_send_venue_query(PromisedQueryPtr &query);
Status process_forward_message_query(PromisedQueryPtr &query); td::Status process_send_contact_query(PromisedQueryPtr &query);
Status process_send_media_group_query(PromisedQueryPtr &query); td::Status process_send_poll_query(PromisedQueryPtr &query);
Status process_send_chat_action_query(PromisedQueryPtr &query); td::Status process_stop_poll_query(PromisedQueryPtr &query);
Status process_edit_message_text_query(PromisedQueryPtr &query); td::Status process_copy_message_query(PromisedQueryPtr &query);
Status process_edit_message_live_location_query(PromisedQueryPtr &query); td::Status process_forward_message_query(PromisedQueryPtr &query);
Status process_edit_message_media_query(PromisedQueryPtr &query); td::Status process_send_media_group_query(PromisedQueryPtr &query);
Status process_edit_message_caption_query(PromisedQueryPtr &query); td::Status process_send_chat_action_query(PromisedQueryPtr &query);
Status process_edit_message_reply_markup_query(PromisedQueryPtr &query); td::Status process_edit_message_text_query(PromisedQueryPtr &query);
Status process_delete_message_query(PromisedQueryPtr &query); td::Status process_edit_message_live_location_query(PromisedQueryPtr &query);
Status process_create_invoice_link_query(PromisedQueryPtr &query); td::Status process_edit_message_media_query(PromisedQueryPtr &query);
Status process_set_game_score_query(PromisedQueryPtr &query); td::Status process_edit_message_caption_query(PromisedQueryPtr &query);
Status process_get_game_high_scores_query(PromisedQueryPtr &query); td::Status process_edit_message_reply_markup_query(PromisedQueryPtr &query);
Status process_answer_web_app_query_query(PromisedQueryPtr &query); td::Status process_delete_message_query(PromisedQueryPtr &query);
Status process_answer_inline_query_query(PromisedQueryPtr &query); td::Status process_create_invoice_link_query(PromisedQueryPtr &query);
Status process_answer_callback_query_query(PromisedQueryPtr &query); td::Status process_set_game_score_query(PromisedQueryPtr &query);
Status process_answer_shipping_query_query(PromisedQueryPtr &query); td::Status process_get_game_high_scores_query(PromisedQueryPtr &query);
Status process_answer_pre_checkout_query_query(PromisedQueryPtr &query); td::Status process_answer_web_app_query_query(PromisedQueryPtr &query);
Status process_export_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_answer_inline_query_query(PromisedQueryPtr &query);
Status process_create_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_answer_callback_query_query(PromisedQueryPtr &query);
Status process_edit_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_answer_shipping_query_query(PromisedQueryPtr &query);
Status process_revoke_chat_invite_link_query(PromisedQueryPtr &query); td::Status process_answer_pre_checkout_query_query(PromisedQueryPtr &query);
Status process_get_chat_query(PromisedQueryPtr &query); td::Status process_export_chat_invite_link_query(PromisedQueryPtr &query);
Status process_set_chat_photo_query(PromisedQueryPtr &query); td::Status process_create_chat_invite_link_query(PromisedQueryPtr &query);
Status process_delete_chat_photo_query(PromisedQueryPtr &query); td::Status process_edit_chat_invite_link_query(PromisedQueryPtr &query);
Status process_set_chat_title_query(PromisedQueryPtr &query); td::Status process_revoke_chat_invite_link_query(PromisedQueryPtr &query);
Status process_set_chat_permissions_query(PromisedQueryPtr &query); td::Status process_get_chat_query(PromisedQueryPtr &query);
Status process_set_chat_description_query(PromisedQueryPtr &query); td::Status process_set_chat_photo_query(PromisedQueryPtr &query);
Status process_pin_chat_message_query(PromisedQueryPtr &query); td::Status process_delete_chat_photo_query(PromisedQueryPtr &query);
Status process_unpin_chat_message_query(PromisedQueryPtr &query); td::Status process_set_chat_title_query(PromisedQueryPtr &query);
Status process_unpin_all_chat_messages_query(PromisedQueryPtr &query); td::Status process_set_chat_permissions_query(PromisedQueryPtr &query);
Status process_set_chat_sticker_set_query(PromisedQueryPtr &query); td::Status process_set_chat_description_query(PromisedQueryPtr &query);
Status process_delete_chat_sticker_set_query(PromisedQueryPtr &query); td::Status process_pin_chat_message_query(PromisedQueryPtr &query);
Status process_get_forum_topic_icon_stickers_query(PromisedQueryPtr &query); td::Status process_unpin_chat_message_query(PromisedQueryPtr &query);
Status process_create_forum_topic_query(PromisedQueryPtr &query); td::Status process_unpin_all_chat_messages_query(PromisedQueryPtr &query);
Status process_edit_forum_topic_query(PromisedQueryPtr &query); td::Status process_set_chat_sticker_set_query(PromisedQueryPtr &query);
Status process_close_forum_topic_query(PromisedQueryPtr &query); td::Status process_delete_chat_sticker_set_query(PromisedQueryPtr &query);
Status process_reopen_forum_topic_query(PromisedQueryPtr &query); td::Status process_get_forum_topic_icon_stickers_query(PromisedQueryPtr &query);
Status process_delete_forum_topic_query(PromisedQueryPtr &query); td::Status process_create_forum_topic_query(PromisedQueryPtr &query);
Status process_unpin_all_forum_topic_messages_query(PromisedQueryPtr &query); td::Status process_edit_forum_topic_query(PromisedQueryPtr &query);
Status process_edit_general_forum_topic_query(PromisedQueryPtr &query); td::Status process_close_forum_topic_query(PromisedQueryPtr &query);
Status process_close_general_forum_topic_query(PromisedQueryPtr &query); td::Status process_reopen_forum_topic_query(PromisedQueryPtr &query);
Status process_reopen_general_forum_topic_query(PromisedQueryPtr &query); td::Status process_delete_forum_topic_query(PromisedQueryPtr &query);
Status process_hide_general_forum_topic_query(PromisedQueryPtr &query); td::Status process_unpin_all_forum_topic_messages_query(PromisedQueryPtr &query);
Status process_unhide_general_forum_topic_query(PromisedQueryPtr &query); td::Status process_edit_general_forum_topic_query(PromisedQueryPtr &query);
Status process_get_chat_member_query(PromisedQueryPtr &query); td::Status process_close_general_forum_topic_query(PromisedQueryPtr &query);
Status process_get_chat_administrators_query(PromisedQueryPtr &query); td::Status process_reopen_general_forum_topic_query(PromisedQueryPtr &query);
Status process_get_chat_member_count_query(PromisedQueryPtr &query); td::Status process_hide_general_forum_topic_query(PromisedQueryPtr &query);
Status process_optimize_memory_query(PromisedQueryPtr &query); td::Status process_unhide_general_forum_topic_query(PromisedQueryPtr &query);
Status process_leave_chat_query(PromisedQueryPtr &query); td::Status process_get_chat_member_query(PromisedQueryPtr &query);
Status process_promote_chat_member_query(PromisedQueryPtr &query); td::Status process_get_chat_administrators_query(PromisedQueryPtr &query);
Status process_set_chat_administrator_custom_title_query(PromisedQueryPtr &query); td::Status process_get_chat_member_count_query(PromisedQueryPtr &query);
Status process_ban_chat_member_query(PromisedQueryPtr &query); td::Status process_leave_chat_query(PromisedQueryPtr &query);
Status process_restrict_chat_member_query(PromisedQueryPtr &query); td::Status process_promote_chat_member_query(PromisedQueryPtr &query);
Status process_unban_chat_member_query(PromisedQueryPtr &query); td::Status process_set_chat_administrator_custom_title_query(PromisedQueryPtr &query);
Status process_ban_chat_sender_chat_query(PromisedQueryPtr &query); td::Status process_ban_chat_member_query(PromisedQueryPtr &query);
Status process_unban_chat_sender_chat_query(PromisedQueryPtr &query); td::Status process_restrict_chat_member_query(PromisedQueryPtr &query);
Status process_approve_chat_join_request_query(PromisedQueryPtr &query); td::Status process_unban_chat_member_query(PromisedQueryPtr &query);
Status process_decline_chat_join_request_query(PromisedQueryPtr &query); td::Status process_ban_chat_sender_chat_query(PromisedQueryPtr &query);
Status process_get_sticker_set_query(PromisedQueryPtr &query); td::Status process_unban_chat_sender_chat_query(PromisedQueryPtr &query);
Status process_get_custom_emoji_stickers_query(PromisedQueryPtr &query); td::Status process_approve_chat_join_request_query(PromisedQueryPtr &query);
Status process_upload_sticker_file_query(PromisedQueryPtr &query); td::Status process_decline_chat_join_request_query(PromisedQueryPtr &query);
Status process_create_new_sticker_set_query(PromisedQueryPtr &query); td::Status process_get_sticker_set_query(PromisedQueryPtr &query);
Status process_add_sticker_to_set_query(PromisedQueryPtr &query); td::Status process_get_custom_emoji_stickers_query(PromisedQueryPtr &query);
Status process_set_sticker_set_thumb_query(PromisedQueryPtr &query); td::Status process_upload_sticker_file_query(PromisedQueryPtr &query);
Status process_set_sticker_position_in_set_query(PromisedQueryPtr &query); td::Status process_create_new_sticker_set_query(PromisedQueryPtr &query);
Status process_delete_sticker_from_set_query(PromisedQueryPtr &query); td::Status process_add_sticker_to_set_query(PromisedQueryPtr &query);
Status process_set_passport_data_errors_query(PromisedQueryPtr &query); td::Status process_set_sticker_set_title_query(PromisedQueryPtr &query);
Status process_send_custom_request_query(PromisedQueryPtr &query); td::Status process_set_sticker_set_thumbnail_query(PromisedQueryPtr &query);
Status process_answer_custom_query_query(PromisedQueryPtr &query); td::Status process_set_custom_emoji_sticker_set_thumbnail_query(PromisedQueryPtr &query);
Status process_get_updates_query(PromisedQueryPtr &query); td::Status process_delete_sticker_set_query(PromisedQueryPtr &query);
Status process_set_webhook_query(PromisedQueryPtr &query); td::Status process_set_sticker_position_in_set_query(PromisedQueryPtr &query);
Status process_get_webhook_info_query(PromisedQueryPtr &query); td::Status process_delete_sticker_from_set_query(PromisedQueryPtr &query);
Status process_get_file_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);
//custom methods //custom methods
Status process_get_message_info_query(PromisedQueryPtr &query); td::Status process_get_message_info_query(PromisedQueryPtr &query);
Status process_get_chat_members_query(PromisedQueryPtr &query); td::Status process_get_chat_members_query(PromisedQueryPtr &query);
Status process_delete_messages_query(PromisedQueryPtr &query); td::Status process_delete_messages_query(PromisedQueryPtr &query);
Status process_toggle_group_invites_query(PromisedQueryPtr &query); td::Status process_toggle_group_invites_query(PromisedQueryPtr &query);
Status process_ping_query(PromisedQueryPtr &query); td::Status process_ping_query(PromisedQueryPtr &query);
Status process_get_memory_stats_query(PromisedQueryPtr &query); td::Status process_get_memory_stats_query(PromisedQueryPtr &query);
Status process_get_proxies_query(PromisedQueryPtr &query); td::Status process_get_proxies_query(PromisedQueryPtr &query);
Status process_add_proxy_query(PromisedQueryPtr &query); td::Status process_add_proxy_query(PromisedQueryPtr &query);
Status process_delete_proxy_query(PromisedQueryPtr &query); td::Status process_delete_proxy_query(PromisedQueryPtr &query);
Status process_enable_proxy_query(PromisedQueryPtr &query); td::Status process_enable_proxy_query(PromisedQueryPtr &query);
Status process_disable_proxy_query(PromisedQueryPtr &query); td::Status process_disable_proxy_query(PromisedQueryPtr &query);
//custom user methods //custom user methods
Status process_get_chats_query(PromisedQueryPtr &query); td::Status process_get_chats_query(PromisedQueryPtr &query);
Status process_get_common_chats_query(PromisedQueryPtr &query); td::Status process_get_common_chats_query(PromisedQueryPtr &query);
Status process_get_inactive_chats_query(PromisedQueryPtr &query); td::Status process_get_inactive_chats_query(PromisedQueryPtr &query);
Status process_get_nearby_chats_query(PromisedQueryPtr &query); td::Status process_get_nearby_chats_query(PromisedQueryPtr &query);
Status process_search_public_chats_query(PromisedQueryPtr &query); td::Status process_search_public_chats_query(PromisedQueryPtr &query);
Status process_set_poll_answer_query(PromisedQueryPtr &query); td::Status process_set_poll_answer_query(PromisedQueryPtr &query);
Status process_join_chat_query(PromisedQueryPtr &query); td::Status process_join_chat_query(PromisedQueryPtr &query);
Status process_add_chat_member_query(PromisedQueryPtr &query); td::Status process_add_chat_member_query(PromisedQueryPtr &query);
Status process_report_chat_query(PromisedQueryPtr &query); td::Status process_report_chat_query(PromisedQueryPtr &query);
Status process_create_chat_query(PromisedQueryPtr &query); td::Status process_create_chat_query(PromisedQueryPtr &query);
Status process_search_messages_query(PromisedQueryPtr &query); td::Status process_search_messages_query(PromisedQueryPtr &query);
Status process_search_chat_messages_query(PromisedQueryPtr &query); td::Status process_search_chat_messages_query(PromisedQueryPtr &query);
Status process_get_callback_query_answer_query(PromisedQueryPtr &query); td::Status process_get_callback_query_answer_query(PromisedQueryPtr &query);
Status process_delete_chat_history_query(PromisedQueryPtr &query); td::Status process_delete_chat_history_query(PromisedQueryPtr &query);
Status process_get_scheduled_messages_query(PromisedQueryPtr &query); td::Status process_get_scheduled_messages_query(PromisedQueryPtr &query);
Status process_edit_message_scheduling_query(PromisedQueryPtr &query); td::Status process_edit_message_scheduling_query(PromisedQueryPtr &query);
//custom auth methods //custom auth methods
void process_auth_phone_number_query(PromisedQueryPtr &query); void process_auth_phone_number_query(PromisedQueryPtr &query);
@ -692,19 +717,19 @@ class Client final : public WebhookActor::Callback {
void webhook_verified(td::string cached_ip_address) final; void webhook_verified(td::string cached_ip_address) final;
void webhook_success() final; void webhook_success() final;
void webhook_error(Status status) final; void webhook_error(td::Status status) final;
void webhook_closed(Status status) final; void webhook_closed(td::Status status) final;
void hangup_shared() final; void hangup_shared() final;
const td::HttpFile *get_webhook_certificate(const Query *query) const; const td::HttpFile *get_webhook_certificate(const Query *query) const;
int32 get_webhook_max_connections(const Query *query) const; int32 get_webhook_max_connections(const Query *query) const;
static bool get_webhook_fix_ip_address(const Query *query); static bool get_webhook_fix_ip_address(const Query *query);
void do_set_webhook(PromisedQueryPtr query, bool was_deleted); void do_set_webhook(PromisedQueryPtr query, bool was_deleted);
void on_webhook_certificate_copied(Status status); void on_webhook_certificate_copied(td::Status status);
void finish_set_webhook(PromisedQueryPtr query); void finish_set_webhook(PromisedQueryPtr query);
void save_webhook() const; void save_webhook() const;
td::string get_webhook_certificate_path() const; td::string get_webhook_certificate_path() const;
void on_webhook_closed(Status status); void on_webhook_closed(td::Status status);
void do_send_message(object_ptr<td_api::InputMessageContent> input_message_content, PromisedQueryPtr query); void do_send_message(object_ptr<td_api::InputMessageContent> input_message_content, PromisedQueryPtr query);
@ -729,22 +754,24 @@ class Client final : public WebhookActor::Callback {
void fail_query_closing(PromisedQueryPtr &&query); void fail_query_closing(PromisedQueryPtr &&query);
void fail_query_conflict(Slice message, PromisedQueryPtr &&query); void fail_query_flood_limit_exceeded(PromisedQueryPtr &&query);
void fail_query_conflict(td::Slice message, PromisedQueryPtr &&query);
struct ClosingError { struct ClosingError {
int code; int code;
int retry_after; int retry_after;
Slice message; td::Slice message;
}; };
ClosingError get_closing_error(); ClosingError get_closing_error();
static int get_retry_after_time(Slice error_message); static int get_retry_after_time(td::Slice error_message);
static void fail_query_with_error(PromisedQueryPtr query, int32 error_code, Slice error_message, static void fail_query_with_error(PromisedQueryPtr query, int32 error_code, td::Slice error_message,
Slice default_message = Slice()); td::Slice default_message = td::Slice());
static void fail_query_with_error(PromisedQueryPtr &&query, object_ptr<td_api::error> error, static void fail_query_with_error(PromisedQueryPtr &&query, object_ptr<td_api::error> error,
Slice default_message = Slice()); td::Slice default_message = td::Slice());
class JsonUpdates; class JsonUpdates;
void do_get_updates(int32 offset, int32 limit, int32 timeout, PromisedQueryPtr query); void do_get_updates(int32 offset, int32 limit, int32 timeout, PromisedQueryPtr query);
@ -920,9 +947,9 @@ class Client final : public WebhookActor::Callback {
void set_message_reply_to_message_id(MessageInfo *message_info, int64 reply_to_message_id); void set_message_reply_to_message_id(MessageInfo *message_info, int64 reply_to_message_id);
static Slice get_sticker_type(const object_ptr<td_api::StickerType> &type); static td::Slice get_sticker_type(const object_ptr<td_api::StickerType> &type);
static td::Result<object_ptr<td_api::StickerType>> get_sticker_type(Slice type); static td::Result<object_ptr<td_api::StickerType>> get_sticker_type(td::Slice type);
static td::CSlice get_callback_data(const object_ptr<td_api::InlineKeyboardButtonType> &type); static td::CSlice get_callback_data(const object_ptr<td_api::InlineKeyboardButtonType> &type);
@ -982,8 +1009,7 @@ class Client final : public WebhookActor::Callback {
struct FullMessageIdHash { struct FullMessageIdHash {
td::uint32 operator()(FullMessageId full_message_id) const { td::uint32 operator()(FullMessageId full_message_id) const {
return td::Hash<td::int64>()(full_message_id.chat_id) * 2023654985u + return td::Hash<int64>()(full_message_id.chat_id) * 2023654985u + td::Hash<int64>()(full_message_id.message_id);
td::Hash<td::int64>()(full_message_id.message_id);
} }
}; };
@ -1058,7 +1084,7 @@ class Client final : public WebhookActor::Callback {
Size Size
}; };
static Slice get_update_type_name(UpdateType update_type); static td::Slice get_update_type_name(UpdateType update_type);
static td::uint32 get_allowed_update_types(td::MutableSlice allowed_updates, bool is_internal); static td::uint32 get_allowed_update_types(td::MutableSlice allowed_updates, bool is_internal);
@ -1080,7 +1106,7 @@ class Client final : public WebhookActor::Callback {
static td::string get_passport_element_type(int32 id); static td::string get_passport_element_type(int32 id);
static object_ptr<td_api::PassportElementType> get_passport_element_type(Slice type); static object_ptr<td_api::PassportElementType> get_passport_element_type(td::Slice type);
bool have_message_access(int64 chat_id) const; bool have_message_access(int64 chat_id) const;
@ -1117,7 +1143,7 @@ class Client final : public WebhookActor::Callback {
int64 channel_bot_user_id_ = 0; int64 channel_bot_user_id_ = 0;
int64 service_notifications_user_id_ = 0; int64 service_notifications_user_id_ = 0;
static td::FlatHashMap<td::string, Status (Client::*)(PromisedQueryPtr &query)> methods_; static td::FlatHashMap<td::string, td::Status (Client::*)(PromisedQueryPtr &query)> methods_;
td::WaitFreeHashMap<FullMessageId, td::unique_ptr<MessageInfo>, FullMessageIdHash> messages_; td::WaitFreeHashMap<FullMessageId, td::unique_ptr<MessageInfo>, FullMessageIdHash> messages_;
td::WaitFreeHashMap<int64, td::unique_ptr<UserInfo>> users_; td::WaitFreeHashMap<int64, td::unique_ptr<UserInfo>> users_;
@ -1226,7 +1252,7 @@ class Client final : public WebhookActor::Callback {
bool webhook_fix_ip_address_ = false; bool webhook_fix_ip_address_ = false;
td::string webhook_secret_token_; td::string webhook_secret_token_;
int32 last_webhook_error_date_ = 0; int32 last_webhook_error_date_ = 0;
Status last_webhook_error_; td::Status last_webhook_error_;
double next_allowed_set_webhook_time_ = 0; double next_allowed_set_webhook_time_ = 0;
double next_set_webhook_logging_time_ = 0; double next_set_webhook_logging_time_ = 0;
double next_webhook_is_not_modified_warning_time_ = 0; double next_webhook_is_not_modified_warning_time_ = 0;

View File

@ -12,6 +12,7 @@
#include "td/actor/actor.h" #include "td/actor/actor.h"
#include "td/utils/BufferedFd.h" #include "td/utils/BufferedFd.h"
#include "td/utils/common.h"
#include "td/utils/FloodControlFast.h" #include "td/utils/FloodControlFast.h"
#include "td/utils/format.h" #include "td/utils/format.h"
#include "td/utils/logging.h" #include "td/utils/logging.h"
@ -47,7 +48,7 @@ class HttpServer final : public td::TcpListener::Callback {
return; return;
} }
flood_control_.add_event(now); flood_control_.add_event(now);
LOG(INFO) << "Create tcp listener " << td::tag("address", ip_address_) << td::tag("port", port_); LOG(INFO) << "Create TCP listener " << td::tag("address", ip_address_) << td::tag("port", port_);
listener_ = td::create_actor<td::TcpListener>( listener_ = td::create_actor<td::TcpListener>(
PSLICE() << "TcpListener" << td::tag("address", ip_address_) << td::tag("port", port_), port_, PSLICE() << "TcpListener" << td::tag("address", ip_address_) << td::tag("port", port_), port_,
actor_shared(this, 1), ip_address_); actor_shared(this, 1), ip_address_);
@ -66,7 +67,7 @@ class HttpServer final : public td::TcpListener::Callback {
scheduler_id--; 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,
20, 500, creator_(), scheduler_id) 50, 500, creator_(), scheduler_id)
.release(); .release();
} }

View File

@ -187,13 +187,18 @@ td::vector<td::string> BotStatActor::get_jsonable_description() const {
double BotStatActor::get_score(double now) { double BotStatActor::get_score(double now) {
auto minute_stat = stat_[2].stat_duration(now); auto minute_stat = stat_[2].stat_duration(now);
double result = minute_stat.first.request_count_ + minute_stat.first.update_count_; double minute_score = minute_stat.first.request_count_ + minute_stat.first.update_count_;
if (minute_stat.second != 0) { if (minute_stat.second != 0) {
result /= minute_stat.second; minute_score /= minute_stat.second;
} }
result += td::max(static_cast<double>(get_active_request_count() - 10), static_cast<double>(0)); auto all_time_stat = stat_[0].stat_duration(now);
result += static_cast<double>(get_active_file_upload_bytes()) * 1e-8; double all_time_score = 0.01 * (all_time_stat.first.request_count_ + all_time_stat.first.update_count_);
return result; if (all_time_stat.second != 0) {
all_time_score /= all_time_stat.second;
}
auto active_request_score = static_cast<double>(td::max(get_active_request_count() - 10, static_cast<td::int64>(0)));
auto active_file_upload_score = static_cast<double>(get_active_file_upload_bytes()) * 1e-8;
return minute_score + all_time_score + active_request_score + active_file_upload_score;
} }
double BotStatActor::get_minute_update_count(double now) { double BotStatActor::get_minute_update_count(double now) {

View File

@ -229,7 +229,7 @@ td::Status WebhookActor::create_connection(td::BufferedFd<td::SocketFd> fd) {
auto id = connections_.create(Connection()); auto id = connections_.create(Connection());
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, 20, 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), slow_scheduler_id_);
conn->ip_generation_ = ip_generation_; conn->ip_generation_ = ip_generation_;
conn->event_id_ = {}; conn->event_id_ = {};
@ -399,7 +399,7 @@ void WebhookActor::load_updates() {
CHECK(update.id.is_valid()); CHECK(update.id.is_valid());
auto &dest_ptr = update_map_[update.id]; auto &dest_ptr = update_map_[update.id];
if (dest_ptr != nullptr) { if (dest_ptr != nullptr) {
LOG(ERROR) << "Receive duplicated event " << update.id << " from TQueue"; LOG(ERROR) << "Receive duplicate event " << update.id << " from TQueue";
continue; continue;
} }
dest_ptr = td::make_unique<Update>(); dest_ptr = td::make_unique<Update>();

View File

@ -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.5"; parameters->version_ = "6.6";
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();