From efb4951436cd6ed3aa88e1b201246968a4bd147a Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 13 Oct 2025 21:24:09 +0300 Subject: [PATCH] Minor improvements. --- telegram-bot-api/Client.cpp | 15 +++++++-------- telegram-bot-api/Client.h | 8 ++++---- telegram-bot-api/Stats.h | 4 ++-- telegram-bot-api/WebhookActor.cpp | 2 +- telegram-bot-api/WebhookActor.h | 6 +++--- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 7cf0276..1634ed8 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -699,8 +699,8 @@ class Client::JsonStickers final : public td::Jsonable { class Client::JsonLocation final : public td::Jsonable { public: - explicit JsonLocation(const td_api::location *location, double expires_in = 0.0, int32 live_period = 0, - int32 heading = 0, int32 proximity_alert_radius = 0) + JsonLocation(const td_api::location *location, double expires_in = 0.0, int32 live_period = 0, int32 heading = 0, + int32 proximity_alert_radius = 0) : location_(location) , expires_in_(expires_in) , live_period_(live_period) @@ -1358,8 +1358,7 @@ class Client::JsonGift final : public td::Jsonable { class Client::JsonGifts final : public td::Jsonable { public: - JsonGifts(const td::vector> &gifts, const Client *client) - : gifts_(gifts), client_(client) { + JsonGifts(const td::vector> &gifts, const Client *client) : gifts_(gifts), client_(client) { } void store(td::JsonValueScope *scope) const { auto object = scope->enter_object(); @@ -1367,7 +1366,7 @@ class Client::JsonGifts final : public td::Jsonable { } private: - const td::vector> &gifts_; + const td::vector> &gifts_; const Client *client_; }; @@ -16279,7 +16278,7 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptris_supergroup && message->content_->get_id() == td_api::messageSupergroupChatCreate::ID) { - // don't send message about channel creation, even the bot was added at exactly the same time + // don't send message about channel creation, even if the bot was added at exactly the same time return true; } } @@ -17160,7 +17159,7 @@ td::int32 Client::get_unix_time() const { } td::int64 Client::get_implicit_reply_to_message_id(int64 chat_id, int64 message_id, - const td_api::object_ptr &topic_id) const { + const object_ptr &topic_id) const { if (topic_id == nullptr) { return 0; } @@ -17190,7 +17189,7 @@ td::int64 Client::get_implicit_reply_to_message_id(int64 chat_id, int64 message_ return implicit_reply_to_message_id < message_id ? implicit_reply_to_message_id : 0; } -td::int32 Client::get_forum_topic_id(const td_api::object_ptr &topic_id) { +td::int32 Client::get_forum_topic_id(const object_ptr &topic_id) { if (topic_id == nullptr) { return 0; } diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 2614918..b37f4c9 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -522,10 +522,10 @@ class Client final : public WebhookActor::Callback { object_ptr get_input_thumbnail(const Query *query) const; - static td::Result> get_inline_query_results_button( + static td::Result> get_inline_query_results_button( td::JsonValue &&value); - static td::Result> get_inline_query_results_button( + static td::Result> get_inline_query_results_button( td::MutableSlice value); static td::Result> get_inline_query_result(const Query *query, @@ -1232,9 +1232,9 @@ class Client final : public WebhookActor::Callback { int32 get_unix_time() const; int64 get_implicit_reply_to_message_id(int64 chat_id, int64 message_id, - const td_api::object_ptr &topic_id) const; + const object_ptr &topic_id) const; - static int32 get_forum_topic_id(const td_api::object_ptr &topic_id); + static int32 get_forum_topic_id(const object_ptr &topic_id); static int64 as_tdlib_message_id(int32 message_id); diff --git a/telegram-bot-api/Stats.h b/telegram-bot-api/Stats.h index 33d306a..7020968 100644 --- a/telegram-bot-api/Stats.h +++ b/telegram-bot-api/Stats.h @@ -58,7 +58,7 @@ class ServerCpuStat { private: static constexpr std::size_t SIZE = 4; static constexpr const char *DESCR[SIZE] = {"inf", "5sec", "1min", "1hour"}; - static constexpr int DURATIONS[SIZE] = {0, 5, 60, 60 * 60}; + static constexpr td::int32 DURATIONS[SIZE] = {0, 5, 60, 60 * 60}; std::mutex mutex_; td::TimedStat stat_[SIZE]; @@ -191,7 +191,7 @@ class BotStatActor final : public td::Actor { private: static constexpr std::size_t SIZE = 4; static constexpr const char *DESCR[SIZE] = {"inf", "5sec", "1min", "1hour"}; - static constexpr int DURATIONS[SIZE] = {0, 5, 60, 60 * 60}; + static constexpr td::int32 DURATIONS[SIZE] = {0, 5, 60, 60 * 60}; td::TimedStat stat_[SIZE]; td::ActorId parent_; diff --git a/telegram-bot-api/WebhookActor.cpp b/telegram-bot-api/WebhookActor.cpp index 46898e3..bbd0f83 100644 --- a/telegram-bot-api/WebhookActor.cpp +++ b/telegram-bot-api/WebhookActor.cpp @@ -148,7 +148,7 @@ td::Status WebhookActor::create_connection() { return create_webhook_error("Can't connect to the webhook proxy", r_proxy_socket_fd.move_as_error(), false); } if (!was_checked_) { - // verify webhook even we can't establish connection to the webhook + // verify webhook even if we can't establish connection to the webhook was_checked_ = true; on_webhook_verified(); } diff --git a/telegram-bot-api/WebhookActor.h b/telegram-bot-api/WebhookActor.h index 22ecd3f..7400547 100644 --- a/telegram-bot-api/WebhookActor.h +++ b/telegram-bot-api/WebhookActor.h @@ -71,9 +71,9 @@ class WebhookActor final : public td::HttpOutboundConnection::Callback { private: static constexpr std::size_t MIN_PENDING_UPDATES_WARNING = 50; - static constexpr int IP_ADDRESS_CACHE_TIME = 30 * 60; // 30 minutes - static constexpr int WEBHOOK_MAX_RESEND_TIMEOUT = 60; - static constexpr int WEBHOOK_DROP_TIMEOUT = 60 * 60 * 23; + static constexpr td::int32 IP_ADDRESS_CACHE_TIME = 30 * 60; // 30 minutes + static constexpr td::int32 WEBHOOK_MAX_RESEND_TIMEOUT = 60; + static constexpr td::int32 WEBHOOK_DROP_TIMEOUT = 60 * 60 * 23; static std::atomic total_connection_count_;