tdlight-telegram-bot-api/telegram-bot-api/ClientParameters.h
Giuseppe Marino a5a0c49467
Custom methods
* Added custom methods
  - getMessageInfo
  - getParticipants
  - deleteMessages
  - toggleGroupInvite

* Implemented method getMessageInfo
* added `views` field and `forwards` field to message
* getChat now resolves the username also for users

* Added custom executable flags
  - relative : use relative path for files in local mode
  - insecure (not implemented) : allow http connection in non-local mode
2020-11-10 16:14:44 +01:00

77 lines
1.8 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/actor/actor.h"
#include "td/db/KeyValueSyncInterface.h"
#include "td/db/TQueue.h"
#include "td/net/GetHostByNameActor.h"
#include "td/utils/common.h"
#include "td/utils/List.h"
#include "td/utils/port/IPAddress.h"
#include <atomic>
#include <limits>
#include <memory>
namespace td {
class NetQueryStats;
}
namespace telegram_bot_api {
struct SharedData {
std::atomic<td::uint64> query_count_{0};
std::atomic<int> next_verbosity_level_{-1};
// not thread-safe
td::ListNode query_list_;
td::unique_ptr<td::KeyValueSyncInterface> webhook_db_;
td::unique_ptr<td::TQueue> tqueue_;
double unix_time_difference_{-1e100};
static constexpr size_t TQUEUE_EVENT_BUFFER_SIZE = 1000;
td::TQueue::Event event_buffer_[TQUEUE_EVENT_BUFFER_SIZE];
td::int32 get_unix_time(double now) const {
auto result = unix_time_difference_ + now;
if (result <= 0) {
return 0;
}
if (result >= std::numeric_limits<td::int32>::max()) {
return std::numeric_limits<td::int32>::max();
}
return static_cast<td::int32>(result);
}
};
struct ClientParameters {
bool local_mode_ = false;
bool allow_http_ = false;
bool use_relative_path_ = false;
td::int32 api_id_ = 0;
td::string api_hash_;
td::int32 default_max_webhook_connections_ = 0;
td::IPAddress webhook_proxy_ip_address_;
double start_timestamp_ = 0;
td::ActorId<td::GetHostByNameActor> get_host_by_name_actor_id_;
std::shared_ptr<SharedData> shared_data_;
std::shared_ptr<td::NetQueryStats> net_query_stats_;
};
} // namespace telegram_bot_api