Skip to content

Commit

Permalink
Merge version 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppeM99 committed Jun 30, 2022
2 parents be24b3c + 24ee05d commit 58168e2
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 109 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()

project(TelegramBotApi VERSION 6.0.1 LANGUAGES CXX)
project(TelegramBotApi VERSION 6.1 LANGUAGES CXX)

if (POLICY CMP0069)
option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.")
Expand Down
2 changes: 1 addition & 1 deletion td
Submodule td updated 194 files
280 changes: 177 additions & 103 deletions telegram-bot-api/Client.cpp

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions telegram-bot-api/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "td/telegram/ClientActor.h"
#include "td/telegram/td_api.h"

#include "td/net/HttpFile.h"

#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"
#include "td/actor/SignalSlot.h"
Expand Down Expand Up @@ -203,6 +205,7 @@ class Client final : public WebhookActor::Callback {
class TdOnGetGroupMembersCallback;
class TdOnGetSupergroupMembersCallback;
class TdOnGetSupergroupMembersCountCallback;
class TdOnCreateInvoiceLinkCallback;
class TdOnReplacePrimaryChatInviteLinkCallback;
class TdOnGetChatInviteLinkCallback;
class TdOnGetGameHighScoresCallback;
Expand Down Expand Up @@ -475,6 +478,8 @@ class Client final : public WebhookActor::Callback {
td::Result<td::vector<object_ptr<td_api::InputMessageContent>>> get_input_message_contents(
const Query *query, td::JsonValue &&value) const;

static td::Result<object_ptr<td_api::inputMessageInvoice>> get_input_message_invoice(const Query *query);

static object_ptr<td_api::messageSendOptions> get_message_send_options(bool disable_notification,
bool protect_content,
object_ptr<td_api::MessageSchedulingState> &&scheduling_state);
Expand Down Expand Up @@ -556,6 +561,7 @@ class Client final : public WebhookActor::Callback {
Status process_edit_message_caption_query(PromisedQueryPtr &query);
Status process_edit_message_reply_markup_query(PromisedQueryPtr &query);
Status process_delete_message_query(PromisedQueryPtr &query);
Status process_create_invoice_link_query(PromisedQueryPtr &query);
Status process_set_game_score_query(PromisedQueryPtr &query);
Status process_get_game_high_scores_query(PromisedQueryPtr &query);
Status process_answer_web_app_query_query(PromisedQueryPtr &query);
Expand Down Expand Up @@ -650,6 +656,7 @@ class Client final : public WebhookActor::Callback {
void webhook_error(Status status) final;
void webhook_closed(Status status) final;
void hangup_shared() final;
const td::HttpFile *get_webhook_certificate(const Query *query) const;
int32 get_webhook_max_connections(const Query *query) const;
static bool get_webhook_fix_ip_address(const Query *query);
void do_set_webhook(PromisedQueryPtr query, bool was_deleted);
Expand Down Expand Up @@ -719,6 +726,8 @@ class Client final : public WebhookActor::Callback {
bool can_read_all_group_messages = false;
bool is_inline_bot = false;
bool has_private_forwards = false;
bool is_premium = false;
bool added_to_attachment_menu = false;
};
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);
Expand Down Expand Up @@ -759,6 +768,8 @@ class Client final : public WebhookActor::Callback {
bool is_supergroup = false;
bool can_set_sticker_set = false;
bool has_location = false;
bool join_to_send_messages = false;
bool join_by_request = false;

// start custom properties
bool is_verified = false;
Expand Down Expand Up @@ -1054,6 +1065,7 @@ class Client final : public WebhookActor::Callback {
struct PendingSendMessageQuery {
PromisedQueryPtr query;
bool is_multisend = false;
int32 total_message_count = 0;
int32 awaited_message_count = 0;
td::vector<td::string> messages;
object_ptr<td_api::error> error;
Expand Down Expand Up @@ -1131,6 +1143,7 @@ class Client final : public WebhookActor::Callback {
int32 webhook_max_connections_ = 0;
td::string webhook_ip_address_;
bool webhook_fix_ip_address_ = false;
td::string webhook_secret_token_;
int32 last_webhook_error_date_ = 0;
Status last_webhook_error_;
double next_allowed_set_webhook_time_ = 0;
Expand Down
5 changes: 5 additions & 0 deletions telegram-bot-api/ClientManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ PromisedQueryPtr ClientManager::get_webhook_restore_query(td::Slice token, bool
parser.skip('/');
}

if (parser.try_skip("#secret")) {
args.emplace_back(add_string("secret_token"), add_string(parser.read_till('/')));
parser.skip('/');
}

if (parser.try_skip("#allow")) {
args.emplace_back(add_string("allowed_updates"), add_string(parser.read_till('/')));
parser.skip('/');
Expand Down
8 changes: 6 additions & 2 deletions telegram-bot-api/WebhookActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ std::atomic<td::uint64> WebhookActor::total_connections_count_{0};

WebhookActor::WebhookActor(td::ActorShared<Callback> callback, td::int64 tqueue_id, td::HttpUrl url,
td::string cert_path, td::int32 max_connections, bool from_db_flag,
td::string cached_ip_address, bool fix_ip_address,
td::string cached_ip_address, bool fix_ip_address, td::string secret_token,
std::shared_ptr<const ClientParameters> parameters)
: callback_(std::move(callback))
, tqueue_id_(tqueue_id)
Expand All @@ -51,7 +51,8 @@ WebhookActor::WebhookActor(td::ActorShared<Callback> callback, td::int64 tqueue_
, parameters_(std::move(parameters))
, fix_ip_address_(fix_ip_address)
, from_db_flag_(from_db_flag)
, max_connections_(max_connections) {
, max_connections_(max_connections)
, secret_token_(std::move(secret_token)) {
CHECK(max_connections_ > 0);

if (!cached_ip_address.empty()) {
Expand Down Expand Up @@ -539,6 +540,9 @@ td::Status WebhookActor::send_update() {
if (!url_.userinfo_.empty()) {
hc.add_header("Authorization", PSLICE() << "Basic " << td::base64_encode(url_.userinfo_));
}
if (!secret_token_.empty()) {
hc.add_header("X-Telegram-Bot-Api-Secret-Token", secret_token_);
}
hc.set_content_type("application/json");
hc.set_content_size(body.size());
hc.set_keep_alive();
Expand Down
3 changes: 2 additions & 1 deletion telegram-bot-api/WebhookActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class WebhookActor final : public td::HttpOutboundConnection::Callback {

WebhookActor(td::ActorShared<Callback> callback, td::int64 tqueue_id, td::HttpUrl url, td::string cert_path,
td::int32 max_connections, bool from_db_flag, td::string cached_ip_address, bool fix_ip_address,
std::shared_ptr<const ClientParameters> parameters);
td::string secret_token, std::shared_ptr<const ClientParameters> parameters);

void update();

Expand Down Expand Up @@ -163,6 +163,7 @@ class WebhookActor final : public td::HttpOutboundConnection::Callback {
td::vector<td::BufferedFd<td::SocketFd>> ready_sockets_;

td::int32 max_connections_ = 0;
td::string secret_token_;
td::Container<Connection> connections_;
td::ListNode ready_connections_;
td::FloodControlFast active_new_connection_flood_;
Expand Down
2 changes: 1 addition & 1 deletion telegram-bot-api/telegram-bot-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int main(int argc, char *argv[]) {
auto start_time = td::Time::now();
auto shared_data = std::make_shared<SharedData>();
auto parameters = std::make_unique<ClientParameters>();
parameters->version_ = "6.0.1";
parameters->version_ = "6.1";
parameters->shared_data_ = shared_data;
parameters->start_time_ = start_time;
auto net_query_stats = td::create_net_query_stats();
Expand Down

0 comments on commit 58168e2

Please sign in to comment.