2
0
mirror of https://github.com/tdlib/telegram-bot-api synced 2025-08-21 17:37:48 +00:00

Compare commits

...

8 Commits

Author SHA1 Message Date
Erfan Mola
01769bd9e1
Merge e2c834103a2f0c648c22362f59dbfa043518e96b into 12bbe26692b8c6e347aaf3e32e0e9d11b86bb56d 2024-08-05 10:22:25 +07:00
levlam
12bbe26692 Update version to 7.8. 2024-07-30 16:21:23 +03:00
levlam
127964a3f2 Add User.has_main_web_app. 2024-07-30 13:43:00 +03:00
levlam
16de9313b0 Support unpinChatMessage for business messages. 2024-07-30 13:10:46 +03:00
levlam
94aa9d390b Support pinChatMessage for business messages. 2024-07-30 13:05:42 +03:00
levlam
3a53074483 Update TDLib to 1.8.34. 2024-07-30 12:28:40 +03:00
levlam
dd17f94d9a Simplify packages list in build instructions generator. 2024-07-18 17:21:56 +03:00
Erfan Mola
e2c834103a
Added Multiple Core build support option
Added an option to chose multi core build by using clang's -j parameter
2022-12-30 13:53:00 +00:00
6 changed files with 56 additions and 12 deletions

View File

@ -6,7 +6,7 @@ if (POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
project(TelegramBotApi VERSION 7.7 LANGUAGES CXX)
project(TelegramBotApi VERSION 7.8 LANGUAGES CXX)
if (POLICY CMP0069)
option(TELEGRAM_BOT_API_ENABLE_LTO "Use \"ON\" to enable Link Time Optimization.")

View File

@ -75,7 +75,7 @@
a:hover {
text-decoration: underline;
}
select, button {
select, button, input {
border: 1px solid var(--color-select-border);
background-color: var(--background);
color: var(--color);
@ -266,6 +266,14 @@
<label><input type="checkbox" id="buildRootCheckbox" onchange="onOptionsChanged()"/>Build from root user (not recommended).</label>
</div>
<div id="buildMultiCoreDiv" class="hide">
<label><input type="checkbox" id="buildMultiCoreCheckbox" onchange="onOptionsChanged()"/>Build using mulitple cores<span class="hide" id="buildMultiCoreColon">:</span></label>
<div id="buildMultiCoreInputDiv" class="hide">
<input type="number" id="buildMultiCoreInput" onchange="onOptionsChanged()" placeholder="Cores number" min="1" style="text-align: center;"/>
</div>
</div>
<p></p>
</div>
@ -354,6 +362,7 @@ function onOptionsChanged() {
linux_distro = document.getElementById('linuxSelect').value;
}
document.getElementById('buildCommandsDiv').style.display = 'block';
document.getElementById('buildMultiCoreDiv').style.display = 'block';
var use_clang = os_freebsd || os_openbsd;
if (os_linux && linux_distro !== 'Alpine' && !linux_distro.includes('CentOS') && !linux_distro.includes('Fedora')) {
@ -534,29 +543,26 @@ function onOptionsChanged() {
break;
case 'CentOS 7':
commands.push(sudo + 'yum update -y');
var packages = 'gcc-c++ make git zlib-devel openssl-devel';
commands.push(sudo + 'yum install -y centos-release-scl-rh epel-release');
commands.push(sudo + 'yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++');
cmake = 'cmake3';
packages += ' gperf ' + cmake;
var packages = 'gcc-c++ make git zlib-devel openssl-devel gperf ' + cmake;
commands.push(sudo + 'yum install -y ' + packages);
break;
case 'CentOS 8':
case 'CentOS Stream 9':
commands.push(sudo + 'dnf update -y');
var packages = 'gcc-c++ make git zlib-devel openssl-devel';
if (linux_distro === 'CentOS 8') {
commands.push(sudo + 'dnf --enablerepo=powertools install gperf');
} else {
commands.push(sudo + 'dnf --enablerepo=crb install gperf');
}
packages += ' ' + cmake;
var packages = 'gcc-c++ make git zlib-devel openssl-devel cmake';
commands.push(sudo + 'dnf install -y ' + packages);
break;
case 'Fedora 21+':
commands.push(sudo + 'dnf update -y');
var packages = 'gperf gcc-c++ make git zlib-devel openssl-devel';
packages += ' ' + cmake;
var packages = 'gperf gcc-c++ make git zlib-devel openssl-devel cmake';
commands.push(sudo + 'dnf install -y ' + packages);
break;
case 'Debian 8/9':
@ -689,6 +695,11 @@ function onOptionsChanged() {
commands.push('cd ../build');
}
let build_command = cmake + ' --build . --target install';
if (document.getElementById('buildMultiCoreCheckbox').checked && document.getElementById('buildMultiCoreInput').value.toString().length > 0 && !(isNaN(document.getElementById('buildMultiCoreInput').value))) {
build_command += ` -j ${ document.getElementById('buildMultiCoreInput').value }`;
}
if (use_msvc) {
if (!is_debug_build) {
commands.push(build_command + ' --config Release');
@ -707,6 +718,8 @@ function onOptionsChanged() {
if (install_dir !== '/usr/local') {
install_dir = 'telegram-bot-api';
}
document.getElementById('buildMultiCoreInputDiv').style.display = document.getElementById('buildMultiCoreCheckbox').checked ? 'block' : 'none';
document.getElementById('buildMultiCoreColon').style.display = document.getElementById('buildMultiCoreCheckbox').checked ? 'inline' : 'none';
commands.push((use_powershell ? 'dir ' : 'ls -l ') + install_dir + '/bin/telegram-bot-api*');
document.getElementById('buildCommands').innerHTML = '<ul><li>' + commands.join('</li><li>') + '</li></ul>';
document.getElementById('copyBuildCommandsButton').style.display = commands.includes('exit') ? 'none' : 'block';

2
td

@ -1 +1 @@
Subproject commit cb164927417f22811c74cd8678ed4a5ab7cb80ba
Subproject commit 1fa2a372a88c26369dcac2ce476166531df74a77

View File

@ -420,6 +420,7 @@ class Client::JsonUser final : public td::Jsonable {
object("can_read_all_group_messages", td::JsonBool(user_info->can_read_all_group_messages));
object("supports_inline_queries", td::JsonBool(user_info->is_inline_bot));
object("can_connect_to_business", td::JsonBool(user_info->can_connect_to_business));
object("has_main_web_app", td::JsonBool(user_info->has_main_web_app));
}
}
@ -3285,6 +3286,8 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const {
object("refunded_payment", JsonRefundedPayment(content));
break;
}
case td_api::messageGiftedStars::ID:
break;
default:
UNREACHABLE();
}
@ -4085,7 +4088,7 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable {
case td_api::starTransactionPartnerBot::ID: {
auto source_user = static_cast<const td_api::starTransactionPartnerBot *>(source_);
object("type", "user");
object("user", JsonUser(source_user->bot_user_id_, client_));
object("user", JsonUser(source_user->user_id_, client_));
if (!source_user->invoice_payload_.empty()) {
if (!td::check_utf8(source_user->invoice_payload_)) {
LOG(WARNING) << "Receive non-UTF-8 invoice payload";
@ -4102,6 +4105,7 @@ class Client::JsonStarTransactionPartner final : public td::Jsonable {
case td_api::starTransactionPartnerTelegram::ID:
case td_api::starTransactionPartnerAppStore::ID:
case td_api::starTransactionPartnerGooglePlay::ID:
case td_api::starTransactionPartnerUser::ID:
case td_api::starTransactionPartnerChannel::ID:
LOG(ERROR) << "Receive " << to_string(*source_);
object("type", "other");
@ -11299,10 +11303,21 @@ td::Status Client::process_set_chat_description_query(PromisedQueryPtr &query) {
}
td::Status Client::process_pin_chat_message_query(PromisedQueryPtr &query) {
auto business_connection_id = query->arg("business_connection_id");
auto chat_id = query->arg("chat_id");
auto message_id = get_message_id(query.get());
auto disable_notification = to_bool(query->arg("disable_notification"));
if (!business_connection_id.empty()) {
check_business_connection_chat_id(
business_connection_id.str(), chat_id.str(), std::move(query),
[this, message_id](const BusinessConnection *business_connection, int64 chat_id, PromisedQueryPtr query) {
send_request(
make_object<td_api::setBusinessMessageIsPinned>(business_connection->id_, chat_id, message_id, true),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return td::Status::OK();
}
check_message(chat_id, message_id, false, AccessRights::Write, "message to pin", std::move(query),
[this, disable_notification](int64 chat_id, int64 message_id, PromisedQueryPtr query) {
send_request(make_object<td_api::pinChatMessage>(chat_id, message_id, disable_notification, false),
@ -11312,9 +11327,21 @@ td::Status Client::process_pin_chat_message_query(PromisedQueryPtr &query) {
}
td::Status Client::process_unpin_chat_message_query(PromisedQueryPtr &query) {
auto business_connection_id = query->arg("business_connection_id");
auto chat_id = query->arg("chat_id");
auto message_id = get_message_id(query.get());
if (!business_connection_id.empty()) {
check_business_connection_chat_id(
business_connection_id.str(), chat_id.str(), std::move(query),
[this, message_id](const BusinessConnection *business_connection, int64 chat_id, PromisedQueryPtr query) {
send_request(
make_object<td_api::setBusinessMessageIsPinned>(business_connection->id_, chat_id, message_id, false),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return td::Status::OK();
}
if (message_id == 0) {
check_chat(chat_id, AccessRights::Write, std::move(query), [this](int64 chat_id, PromisedQueryPtr query) {
send_request(make_object<td_api::getChatPinnedMessage>(chat_id),
@ -12832,6 +12859,7 @@ void Client::add_user(UserInfo *user_info, object_ptr<td_api::user> &&user) {
user_info->can_read_all_group_messages = bot->can_read_all_group_messages_;
user_info->is_inline_bot = bot->is_inline_;
user_info->can_connect_to_business = bot->can_connect_to_business_;
user_info->has_main_web_app = bot->has_main_web_app_;
break;
}
case td_api::userTypeDeleted::ID:
@ -13778,6 +13806,8 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::me
return true;
case td_api::messagePremiumGiftCode::ID:
return true;
case td_api::messageGiftedStars::ID:
return true;
default:
break;
}

View File

@ -841,9 +841,10 @@ class Client final : public WebhookActor::Callback {
bool can_join_groups = false;
bool can_read_all_group_messages = false;
bool can_connect_to_business = false;
bool is_inline_bot = false;
bool has_main_web_app = false;
bool has_private_forwards = false;
bool has_restricted_voice_and_video_messages = false;
bool is_inline_bot = false;
bool is_premium = false;
bool added_to_attachment_menu = false;
};

View File

@ -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_ = "7.7";
parameters->version_ = "7.8";
parameters->shared_data_ = shared_data;
parameters->start_time_ = start_time;
auto net_query_stats = td::create_net_query_stats();