mirror of
https://github.com/tdlib/telegram-bot-api
synced 2025-08-21 17:37:48 +00:00
Compare commits
40 Commits
3e9db0d84b
...
8be1f0058c
Author | SHA1 | Date | |
---|---|---|---|
|
8be1f0058c | ||
|
1be3aa8af8 | ||
|
4c51721dff | ||
|
d653237578 | ||
|
5fe7a665c2 | ||
|
b1880bc675 | ||
|
59a071d617 | ||
|
83fa5b3ee3 | ||
|
2efc96a48b | ||
|
794cae79cd | ||
|
db7c26bd0e | ||
|
39ba2eb54d | ||
|
6c78928142 | ||
|
201883e7b4 | ||
|
d9c58ff764 | ||
|
35a0af7366 | ||
|
3d5fcc25b2 | ||
|
a0d685a452 | ||
|
1cab852b77 | ||
|
1be9abdba4 | ||
|
4e9331ada1 | ||
|
b274d9b8ed | ||
|
3cf5e788ac | ||
|
d193c3e35c | ||
|
263846eaa8 | ||
|
611c0546e3 | ||
|
dfadb99c28 | ||
|
feaa39b418 | ||
|
6a7d3c3d81 | ||
|
c5d1ea0934 | ||
|
c6a8cf4a3a | ||
|
27bbe0c71b | ||
|
ddd1344b65 | ||
|
f0207bb215 | ||
|
32490d0ba1 | ||
|
dec84776db | ||
|
094008c1cb | ||
|
bb1e4a2285 | ||
|
9f6de77677 | ||
|
affc8c60f9 |
@ -1,17 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
if (POLICY CMP0065)
|
||||
# do not export symbols from executables
|
||||
# affects compiler checks in project(), so must be set before it
|
||||
cmake_policy(SET CMP0065 NEW)
|
||||
endif()
|
||||
|
||||
project(TelegramBotApi VERSION 8.3 LANGUAGES CXX)
|
||||
|
||||
if (POLICY CMP0069)
|
||||
option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.")
|
||||
set(TD_ENABLE_LTO "${TELEGRAM_BOT_API_ENABLE_LTO}" CACHE STRING "Enable LTO" FORCE)
|
||||
endif()
|
||||
project(TelegramBotApi VERSION 9.0 LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(td EXCLUDE_FROM_ALL)
|
||||
|
||||
@ -24,14 +13,6 @@ if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR "bin")
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0054)
|
||||
# do not expand quoted arguments
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif()
|
||||
if (POLICY CMP0060)
|
||||
# link libraries by full path
|
||||
cmake_policy(SET CMP0060 NEW)
|
||||
endif()
|
||||
if (POLICY CMP0074)
|
||||
# use environment variables to find libraries
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
@ -40,8 +21,7 @@ endif()
|
||||
include(PreventInSourceBuild)
|
||||
prevent_in_source_build()
|
||||
|
||||
if (POLICY CMP0069 AND TELEGRAM_BOT_API_ENABLE_LTO)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
if (TELEGRAM_BOT_API_ENABLE_LTO)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT IPO_SUPPORTED LANGUAGES CXX)
|
||||
if (IPO_SUPPORTED)
|
||||
|
@ -38,9 +38,9 @@ To build and run `Telegram Bot API server` you will need:
|
||||
|
||||
* OpenSSL
|
||||
* zlib
|
||||
* C++14 compatible compiler (e.g., Clang 3.4+, GCC 4.9+, MSVC 19.0+ (Visual Studio 2015+), Intel C++ Compiler 17+) (build only)
|
||||
* C++17 compatible compiler (e.g., Clang 5.0+, GCC 7.0+, MSVC 19.1+ (Visual Studio 2017.7+), Intel C++ Compiler 19+) (build only)
|
||||
* gperf (build only)
|
||||
* CMake (3.0.2+, build only)
|
||||
* CMake (3.10+, build only)
|
||||
|
||||
<a name="usage"></a>
|
||||
## Usage
|
||||
|
23
build.html
23
build.html
@ -202,11 +202,8 @@
|
||||
<option>CentOS 7</option>
|
||||
<option>CentOS 8</option>
|
||||
<option>CentOS Stream 9</option>
|
||||
<option>Debian 8/9</option>
|
||||
<option>Debian 10+</option>
|
||||
<option>Fedora 21+</option>
|
||||
<option>Ubuntu 14</option>
|
||||
<option>Ubuntu 16</option>
|
||||
<option>Ubuntu 18</option>
|
||||
<option>Ubuntu 20</option>
|
||||
<option>Ubuntu 22</option>
|
||||
@ -491,8 +488,6 @@ function onOptionsChanged() {
|
||||
|
||||
function getClangVersionSuffix() {
|
||||
switch (linux_distro) {
|
||||
case 'Ubuntu 14':
|
||||
return '-3.9';
|
||||
case 'Ubuntu 18':
|
||||
return '-6.0';
|
||||
case 'Ubuntu 20':
|
||||
@ -556,10 +551,7 @@ function onOptionsChanged() {
|
||||
var packages = 'gperf gcc-c++ make git zlib-devel openssl-devel cmake';
|
||||
commands.push(sudo + 'dnf install -y ' + packages);
|
||||
break;
|
||||
case 'Debian 8/9':
|
||||
case 'Debian 10+':
|
||||
case 'Ubuntu 14':
|
||||
case 'Ubuntu 16':
|
||||
case 'Ubuntu 18':
|
||||
case 'Ubuntu 20':
|
||||
case 'Ubuntu 22':
|
||||
@ -567,17 +559,9 @@ function onOptionsChanged() {
|
||||
if (linux_distro.includes('Debian') && !use_root) {
|
||||
commands.push('su -');
|
||||
}
|
||||
if (linux_distro === 'Ubuntu 14' && !use_clang) {
|
||||
commands.push(sudo + 'add-apt-repository ppa:ubuntu-toolchain-r/test');
|
||||
}
|
||||
commands.push(sudo + 'apt-get update');
|
||||
commands.push(sudo + 'apt-get upgrade');
|
||||
var packages = 'make git zlib1g-dev libssl-dev gperf';
|
||||
if (linux_distro === 'Ubuntu 14') {
|
||||
packages += ' cmake3';
|
||||
} else {
|
||||
packages += ' cmake';
|
||||
}
|
||||
var packages = 'make git zlib1g-dev libssl-dev gperf cmake';
|
||||
if (use_clang) {
|
||||
packages += ' clang' + getClangVersionSuffix() + ' libc++' + getLibcplusplusVersionSuffix() + '-dev';
|
||||
if (linux_distro === 'Debian 10+' || linux_distro === 'Ubuntu 18' || linux_distro === 'Ubuntu 20' || linux_distro === 'Ubuntu 22' || linux_distro === 'Ubuntu 24') {
|
||||
@ -585,9 +569,6 @@ function onOptionsChanged() {
|
||||
}
|
||||
} else {
|
||||
packages += ' g++';
|
||||
if (linux_distro === 'Ubuntu 14') {
|
||||
packages += '-4.9';
|
||||
}
|
||||
}
|
||||
commands.push(sudo + 'apt-get install ' + packages);
|
||||
if (linux_distro.includes('Debian') && !use_root) {
|
||||
@ -669,8 +650,6 @@ function onOptionsChanged() {
|
||||
if (use_clang) {
|
||||
var clang_version_suffix = getClangVersionSuffix();
|
||||
prefix = 'CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang' + clang_version_suffix + ' CXX=/usr/bin/clang++' + clang_version_suffix + ' ';
|
||||
} else if (linux_distro === 'Ubuntu 14') {
|
||||
prefix = 'CC=/usr/bin/gcc-4.9 CXX=/usr/bin/g++-4.9 ';
|
||||
} else if (linux_distro === 'CentOS 7') {
|
||||
prefix = 'CC=/opt/rh/devtoolset-9/root/usr/bin/gcc CXX=/opt/rh/devtoolset-9/root/usr/bin/g++ ';
|
||||
}
|
||||
|
2
td
2
td
@ -1 +1 @@
|
||||
Subproject commit b04e55f3e98c651ff34f1bd439d59bbb2f7ab5fb
|
||||
Subproject commit a03a90470d6fca9a5a3db747ba3f3e4a465b5fe7
|
File diff suppressed because it is too large
Load Diff
@ -93,6 +93,7 @@ class Client final : public WebhookActor::Callback {
|
||||
class JsonUsers;
|
||||
class JsonReactionType;
|
||||
class JsonReactionCount;
|
||||
class JsonAcceptedGiftTypes;
|
||||
class JsonBirthdate;
|
||||
class JsonBusinessStartPage;
|
||||
class JsonBusinessLocation;
|
||||
@ -172,8 +173,14 @@ class Client final : public WebhookActor::Callback {
|
||||
class JsonGameHighScore;
|
||||
class JsonGift;
|
||||
class JsonGifts;
|
||||
class JsonUniqueGiftModel;
|
||||
class JsonUniqueGiftSymbol;
|
||||
class JsonUniqueGiftBackdropColors;
|
||||
class JsonUniqueGiftBackdrop;
|
||||
class JsonUniqueGift;
|
||||
class JsonMessageReactionUpdated;
|
||||
class JsonMessageReactionCountUpdated;
|
||||
class JsonBusinessBotRights;
|
||||
class JsonBusinessConnection;
|
||||
class JsonBusinessMessagesDeleted;
|
||||
class JsonAddress;
|
||||
@ -184,6 +191,9 @@ class Client final : public WebhookActor::Callback {
|
||||
class JsonChatBackground;
|
||||
class JsonSuccessfulPaymentBot;
|
||||
class JsonRefundedPayment;
|
||||
class JsonGiftMessage;
|
||||
class JsonRefundedUpgradedGiftMessage;
|
||||
class JsonUniqueGiftMessage;
|
||||
class JsonEncryptedPassportElement;
|
||||
class JsonEncryptedCredentials;
|
||||
class JsonPassportData;
|
||||
@ -203,6 +213,10 @@ class Client final : public WebhookActor::Callback {
|
||||
class JsonGiveawayWinners;
|
||||
class JsonGiveawayCompleted;
|
||||
class JsonChatBoostAdded;
|
||||
class JsonPaidMessagePriceChanged;
|
||||
class JsonStarAmount;
|
||||
class JsonReceivedGift;
|
||||
class JsonReceivedGifts;
|
||||
class JsonRevenueWithdrawalState;
|
||||
class JsonAffiliateInfo;
|
||||
class JsonStarTransactionType;
|
||||
@ -229,6 +243,8 @@ class Client final : public WebhookActor::Callback {
|
||||
class TdOnEditInlineMessageCallback;
|
||||
class TdOnStopPollCallback;
|
||||
class TdOnStopBusinessPollCallback;
|
||||
class TdOnPostStoryCallback;
|
||||
class TdOnGetStoryCallback;
|
||||
class TdOnOkQueryCallback;
|
||||
class TdOnGetReplyMessageCallback;
|
||||
class TdOnGetEditedMessageCallback;
|
||||
@ -253,7 +269,10 @@ class Client final : public WebhookActor::Callback {
|
||||
class TdOnGetUserChatBoostsCallback;
|
||||
class TdOnGetGiftsCallback;
|
||||
class TdOnCreateInvoiceLinkCallback;
|
||||
class TdOnGetStarTransactionsQueryCallback;
|
||||
class TdOnUpgradeGiftCallback;
|
||||
class TdOnGetStarAmountCallback;
|
||||
class TdOnGetReceivedGiftsCallback;
|
||||
class TdOnGetStarTransactionsCallback;
|
||||
class TdOnReplacePrimaryChatInviteLinkCallback;
|
||||
class TdOnGetChatInviteLinkCallback;
|
||||
class TdOnGetGameHighScoresCallback;
|
||||
@ -606,6 +625,25 @@ class Client final : public WebhookActor::Callback {
|
||||
|
||||
static td::Result<td::vector<object_ptr<td_api::ReactionType>>> get_reaction_types(const Query *query);
|
||||
|
||||
static td::Result<object_ptr<td_api::InputStoryAreaType>> get_input_story_area_type(td::JsonValue &&value);
|
||||
|
||||
static td::Result<object_ptr<td_api::inputStoryArea>> get_input_story_area(td::JsonValue &&value);
|
||||
|
||||
static td::Result<object_ptr<td_api::inputStoryAreas>> get_input_story_areas(const Query *query);
|
||||
|
||||
td::Result<object_ptr<td_api::InputChatPhoto>> get_input_chat_photo(const Query *query, td::JsonValue &&value) const;
|
||||
|
||||
td::Result<object_ptr<td_api::InputChatPhoto>> get_input_chat_photo(const Query *query) const;
|
||||
|
||||
td::Result<object_ptr<td_api::InputStoryContent>> get_input_story_content(const Query *query,
|
||||
td::JsonValue &&value) const;
|
||||
|
||||
td::Result<object_ptr<td_api::InputStoryContent>> get_input_story_content(const Query *query) const;
|
||||
|
||||
static td::Result<object_ptr<td_api::acceptedGiftTypes>> get_accepted_gift_types(td::JsonValue &&value);
|
||||
|
||||
static td::Result<object_ptr<td_api::acceptedGiftTypes>> get_accepted_gift_types(const Query *query);
|
||||
|
||||
static int32 get_integer_arg(const Query *query, td::Slice field_name, int32 default_value,
|
||||
int32 min_value = std::numeric_limits<int32>::min(),
|
||||
int32 max_value = std::numeric_limits<int32>::max());
|
||||
@ -631,6 +669,10 @@ class Client final : public WebhookActor::Callback {
|
||||
void on_message_send_failed(int64 chat_id, int64 old_message_id, int64 new_message_id,
|
||||
object_ptr<td_api::error> &&error);
|
||||
|
||||
void on_story_send_succeeded(object_ptr<td_api::story> &&story, int64 old_story_id);
|
||||
|
||||
void on_story_send_failed(int64 chat_id, int64 story_id, object_ptr<td_api::error> &&error);
|
||||
|
||||
static bool init_methods();
|
||||
|
||||
static bool is_local_method(td::Slice method);
|
||||
@ -684,12 +726,16 @@ class Client final : public WebhookActor::Callback {
|
||||
td::Status process_edit_message_reply_markup_query(PromisedQueryPtr &query);
|
||||
td::Status process_delete_message_query(PromisedQueryPtr &query);
|
||||
td::Status process_delete_messages_query(PromisedQueryPtr &query);
|
||||
td::Status process_post_story_query(PromisedQueryPtr &query);
|
||||
td::Status process_edit_story_query(PromisedQueryPtr &query);
|
||||
td::Status process_delete_story_query(PromisedQueryPtr &query);
|
||||
td::Status process_create_invoice_link_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_star_transactions_query(PromisedQueryPtr &query);
|
||||
td::Status process_refund_star_payment_query(PromisedQueryPtr &query);
|
||||
td::Status process_edit_user_star_subscription_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_available_gifts_query(PromisedQueryPtr &query);
|
||||
td::Status process_send_gift_query(PromisedQueryPtr &query);
|
||||
td::Status process_gift_premium_subscription_query(PromisedQueryPtr &query);
|
||||
td::Status process_verify_user_query(PromisedQueryPtr &query);
|
||||
td::Status process_verify_chat_query(PromisedQueryPtr &query);
|
||||
td::Status process_remove_user_verification_query(PromisedQueryPtr &query);
|
||||
@ -709,6 +755,20 @@ class Client final : public WebhookActor::Callback {
|
||||
td::Status process_edit_chat_subscription_invite_link_query(PromisedQueryPtr &query);
|
||||
td::Status process_revoke_chat_invite_link_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_business_connection_query(PromisedQueryPtr &query);
|
||||
td::Status process_read_business_message_query(PromisedQueryPtr &query);
|
||||
td::Status process_delete_business_messages_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_business_account_name_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_business_account_username_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_business_account_bio_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_business_account_profile_photo_query(PromisedQueryPtr &query);
|
||||
td::Status process_remove_business_account_profile_photo_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_business_account_gift_settings_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_business_account_star_balance_query(PromisedQueryPtr &query);
|
||||
td::Status process_transfer_business_account_stars_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_business_account_gifts_query(PromisedQueryPtr &query);
|
||||
td::Status process_convert_gift_to_stars_query(PromisedQueryPtr &query);
|
||||
td::Status process_upgrade_gift_query(PromisedQueryPtr &query);
|
||||
td::Status process_transfer_gift_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_user_emoji_status_query(PromisedQueryPtr &query);
|
||||
td::Status process_get_chat_query(PromisedQueryPtr &query);
|
||||
td::Status process_set_chat_photo_query(PromisedQueryPtr &query);
|
||||
@ -796,6 +856,8 @@ class Client final : public WebhookActor::Callback {
|
||||
|
||||
void on_sent_message(object_ptr<td_api::message> &&message, int64 query_id);
|
||||
|
||||
void on_sent_story(object_ptr<td_api::story> &&story, PromisedQueryPtr query);
|
||||
|
||||
void do_get_file(object_ptr<td_api::file> file, PromisedQueryPtr query);
|
||||
|
||||
bool is_file_being_downloaded(int32 file_id) const;
|
||||
@ -861,6 +923,7 @@ class Client final : public WebhookActor::Callback {
|
||||
td::string bio;
|
||||
object_ptr<td_api::birthdate> birthdate;
|
||||
object_ptr<td_api::businessInfo> business_info;
|
||||
object_ptr<td_api::acceptedGiftTypes> accepted_gift_types;
|
||||
int64 personal_chat_id = 0;
|
||||
|
||||
bool have_access = false;
|
||||
@ -966,6 +1029,7 @@ class Client final : public WebhookActor::Callback {
|
||||
int32 edit_date = 0;
|
||||
int32 initial_send_date = 0;
|
||||
int32 sender_boost_count = 0;
|
||||
int64 paid_message_star_count = 0;
|
||||
object_ptr<td_api::MessageOrigin> forward_origin;
|
||||
td::string author_signature;
|
||||
td::unique_ptr<MessageInfo> business_reply_to_message;
|
||||
@ -992,7 +1056,7 @@ class Client final : public WebhookActor::Callback {
|
||||
int64 user_id_ = 0;
|
||||
int64 user_chat_id_ = 0;
|
||||
int32 date_ = 0;
|
||||
bool can_reply_ = false;
|
||||
object_ptr<td_api::businessBotRights> rights_;
|
||||
bool is_enabled_ = false;
|
||||
};
|
||||
const BusinessConnection *add_business_connection(object_ptr<td_api::businessConnection> &&business_connection,
|
||||
@ -1259,6 +1323,11 @@ class Client final : public WebhookActor::Callback {
|
||||
|
||||
td::FlatHashMap<int64, int32> yet_unsent_message_count_; // chat_id -> count
|
||||
|
||||
struct YetUnsentStory {
|
||||
PromisedQueryPtr query;
|
||||
};
|
||||
td::FlatHashMap<FullMessageId, YetUnsentStory, FullMessageIdHash> yet_unsent_stories_;
|
||||
|
||||
struct PendingSendMessageQuery {
|
||||
PromisedQueryPtr query;
|
||||
bool is_multisend = false;
|
||||
|
@ -590,6 +590,4 @@ void ClientManager::finish_close() {
|
||||
stop();
|
||||
}
|
||||
|
||||
constexpr double ClientManager::WATCHDOG_TIMEOUT;
|
||||
|
||||
} // namespace telegram_bot_api
|
||||
|
@ -83,9 +83,6 @@ td::vector<StatItem> ServerCpuStat::as_vector(double now) {
|
||||
return res;
|
||||
}
|
||||
|
||||
constexpr int ServerCpuStat::DURATIONS[SIZE];
|
||||
constexpr const char *ServerCpuStat::DESCR[SIZE];
|
||||
|
||||
void ServerBotStat::normalize(double duration) {
|
||||
if (duration == 0) {
|
||||
return;
|
||||
@ -201,7 +198,4 @@ bool BotStatActor::is_active(double now) const {
|
||||
return last_activity_timestamp_ > now - 86400;
|
||||
}
|
||||
|
||||
constexpr int BotStatActor::DURATIONS[SIZE];
|
||||
constexpr const char *BotStatActor::DESCR[SIZE];
|
||||
|
||||
} // namespace telegram_bot_api
|
||||
|
@ -165,7 +165,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_ = "8.3";
|
||||
parameters->version_ = "9.0";
|
||||
parameters->shared_data_ = shared_data;
|
||||
parameters->start_time_ = start_time;
|
||||
auto net_query_stats = td::create_net_query_stats();
|
||||
|
Loading…
x
Reference in New Issue
Block a user