2
0
mirror of https://github.com/tdlib/telegram-bot-api synced 2025-08-22 01:49:24 +00:00

Compare commits

...

10 Commits

Author SHA1 Message Date
Erfan Mola
df0c845372
Merge e2c834103a2f0c648c22362f59dbfa043518e96b into fa6706fc8f6e22b3c25b512ede6474613f32b32b 2025-01-02 02:23:53 +03:00
levlam
fa6706fc8f Update version to 8.2. 2024-12-31 00:36:19 +03:00
levlam
d69265e61b Add removeChatVerification. 2024-12-31 00:22:24 +03:00
levlam
faf2f9b60b Add removeUserVerification. 2024-12-31 00:21:04 +03:00
levlam
1f8ba44aaa Add verifyChat. 2024-12-31 00:19:02 +03:00
levlam
5b01642142 Add verifyUser. 2024-12-30 23:51:53 +03:00
levlam
d4ea517c2f Add sendGift.pay_for_upgrade. 2024-12-30 23:45:39 +03:00
levlam
bff46219ae Add Gift.upgrade_star_count. 2024-12-30 23:44:40 +03:00
levlam
bc771a3b2f Update TDLib to 1.8.42. 2024-12-30 18:38:12 +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 89 additions and 9 deletions

View File

@ -6,7 +6,7 @@ if (POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
project(TelegramBotApi VERSION 8.1 LANGUAGES CXX)
project(TelegramBotApi VERSION 8.2 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')) {
@ -686,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');
@ -704,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 7648b99d81d36d44bae3ca6c514a816a2fe8cfd1
Subproject commit ef580cd3dd0e5223c2be503342dc29e128be866e

View File

@ -256,6 +256,10 @@ bool Client::init_methods() {
methods_.emplace("edituserstarsubscription", &Client::process_edit_user_star_subscription_query);
methods_.emplace("getavailablegifts", &Client::process_get_available_gifts_query);
methods_.emplace("sendgift", &Client::process_send_gift_query);
methods_.emplace("verifyuser", &Client::process_verify_user_query);
methods_.emplace("verifychat", &Client::process_verify_chat_query);
methods_.emplace("removeuserverification", &Client::process_remove_user_verification_query);
methods_.emplace("removechatverification", &Client::process_remove_chat_verification_query);
methods_.emplace("setgamescore", &Client::process_set_game_score_query);
methods_.emplace("getgamehighscores", &Client::process_get_game_high_scores_query);
methods_.emplace("answerwebappquery", &Client::process_answer_web_app_query_query);
@ -3389,6 +3393,10 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const {
break;
case td_api::messageGift::ID:
break;
case td_api::messageUpgradedGift::ID:
break;
case td_api::messageRefundedUpgradedGift::ID:
break;
default:
UNREACHABLE();
}
@ -4084,6 +4092,9 @@ class Client::JsonGift final : public td::Jsonable {
object("id", td::to_string(gift_->id_));
object("sticker", JsonSticker(gift_->sticker_.get(), client_));
object("star_count", gift_->star_count_);
if (gift_->upgrade_star_count_ > 0) {
object("upgrade_star_count", gift_->upgrade_star_count_);
}
if (gift_->total_count_ > 0) {
object("remaining_count", gift_->remaining_count_);
object("total_count", gift_->total_count_);
@ -6666,8 +6677,8 @@ void Client::check_business_connection_chat_id(const td::string &business_connec
}
auto chat_id = r_chat_id.move_as_ok();
check_business_connection(business_connection_id, std::move(query),
[chat_id, on_success = std::move(on_success)](
const BusinessConnection *business_connection, PromisedQueryPtr query) mutable {
[chat_id, on_success = std::move(on_success)](const BusinessConnection *business_connection,
PromisedQueryPtr query) mutable {
on_success(business_connection, chat_id, std::move(query));
});
}
@ -8577,7 +8588,7 @@ td::Result<td_api::object_ptr<td_api::InputInlineQueryResult>> Client::get_inlin
CHECK(input_message_content != nullptr);
return make_object<td_api::inputInlineQueryResultArticle>(
id, url, hide_url, title, description, thumbnail_url, thumbnail_width, thumbnail_height,
id, hide_url ? td::string() : url, title, description, thumbnail_url, thumbnail_width, thumbnail_height,
std::move(reply_markup), std::move(input_message_content));
}
if (type == "audio") {
@ -11377,12 +11388,57 @@ td::Status Client::process_get_available_gifts_query(PromisedQueryPtr &query) {
td::Status Client::process_send_gift_query(PromisedQueryPtr &query) {
auto gift_id = td::to_integer<int64>(query->arg("gift_id"));
auto pay_for_upgrade = to_bool(query->arg("pay_for_upgrade"));
TRY_RESULT(user_id, get_user_id(query.get()));
TRY_RESULT(text, get_formatted_text(query->arg("text").str(), query->arg("text_parse_mode").str(),
get_input_entities(query.get(), "text_entities")));
check_user(user_id, std::move(query),
[this, gift_id, user_id, text = std::move(text)](PromisedQueryPtr query) mutable {
send_request(make_object<td_api::sendGift>(gift_id, user_id, std::move(text), false),
[this, gift_id, pay_for_upgrade, user_id, text = std::move(text)](PromisedQueryPtr query) mutable {
send_request(make_object<td_api::sendGift>(gift_id, user_id, std::move(text), false, pay_for_upgrade),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return td::Status::OK();
}
td::Status Client::process_verify_user_query(PromisedQueryPtr &query) {
TRY_RESULT(user_id, get_user_id(query.get()));
auto custom_description = query->arg("custom_description");
check_user(user_id, std::move(query),
[this, user_id, custom_description = custom_description.str()](PromisedQueryPtr query) {
send_request(make_object<td_api::setMessageSenderBotVerification>(
0, make_object<td_api::messageSenderUser>(user_id), custom_description),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return td::Status::OK();
}
td::Status Client::process_verify_chat_query(PromisedQueryPtr &query) {
auto chat_id = query->arg("chat_id");
auto custom_description = query->arg("custom_description");
check_chat(chat_id, AccessRights::Read, std::move(query),
[this, custom_description = custom_description.str()](int64 chat_id, PromisedQueryPtr query) {
send_request(make_object<td_api::setMessageSenderBotVerification>(
0, make_object<td_api::messageSenderChat>(chat_id), custom_description),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return td::Status::OK();
}
td::Status Client::process_remove_user_verification_query(PromisedQueryPtr &query) {
TRY_RESULT(user_id, get_user_id(query.get()));
check_user(user_id, std::move(query), [this, user_id](PromisedQueryPtr query) {
send_request(
make_object<td_api::removeMessageSenderBotVerification>(0, make_object<td_api::messageSenderUser>(user_id)),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return td::Status::OK();
}
td::Status Client::process_remove_chat_verification_query(PromisedQueryPtr &query) {
auto chat_id = query->arg("chat_id");
check_chat(chat_id, AccessRights::Read, std::move(query), [this](int64 chat_id, PromisedQueryPtr query) {
send_request(
make_object<td_api::removeMessageSenderBotVerification>(0, make_object<td_api::messageSenderChat>(chat_id)),
td::make_unique<TdOnOkQueryCallback>(std::move(query)));
});
return td::Status::OK();
@ -14284,6 +14340,10 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::me
return true;
case td_api::messageGift::ID:
return true;
case td_api::messageUpgradedGift::ID:
return true;
case td_api::messageRefundedUpgradedGift::ID:
return true;
default:
break;
}

View File

@ -690,6 +690,10 @@ class Client final : public WebhookActor::Callback {
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_verify_user_query(PromisedQueryPtr &query);
td::Status process_verify_chat_query(PromisedQueryPtr &query);
td::Status process_remove_user_verification_query(PromisedQueryPtr &query);
td::Status process_remove_chat_verification_query(PromisedQueryPtr &query);
td::Status process_set_game_score_query(PromisedQueryPtr &query);
td::Status process_get_game_high_scores_query(PromisedQueryPtr &query);
td::Status process_answer_web_app_query_query(PromisedQueryPtr &query);

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