Add td_api::getCountryCode.
GitOrigin-RevId: 361b261b17848c5052769e4a0b6ebaa3cc30e769
This commit is contained in:
parent
c1e3f2d65d
commit
e4d76c43c3
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||||
|
|
||||||
project(TDLib VERSION 1.1.4 LANGUAGES CXX C)
|
project(TDLib VERSION 1.1.5 LANGUAGES CXX C)
|
||||||
|
|
||||||
# Prevent in-source build
|
# Prevent in-source build
|
||||||
get_filename_component(TD_REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
|
get_filename_component(TD_REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
|
||||||
|
@ -107,7 +107,7 @@ target_link_libraries(YourTarget PRIVATE Td::TdStatic)
|
|||||||
|
|
||||||
Or you could install `TDLib` and then reference it in your CMakeLists.txt like this:
|
Or you could install `TDLib` and then reference it in your CMakeLists.txt like this:
|
||||||
```
|
```
|
||||||
find_package(Td 1.1.4 REQUIRED)
|
find_package(Td 1.1.5 REQUIRED)
|
||||||
target_link_libraries(YourTarget PRIVATE Td::TdStatic)
|
target_link_libraries(YourTarget PRIVATE Td::TdStatic)
|
||||||
```
|
```
|
||||||
See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/tree/master/example/cpp/CMakeLists.txt).
|
See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/tree/master/example/cpp/CMakeLists.txt).
|
||||||
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
|
|||||||
|
|
||||||
project(TdExample VERSION 1.0 LANGUAGES CXX)
|
project(TdExample VERSION 1.0 LANGUAGES CXX)
|
||||||
|
|
||||||
find_package(Td 1.1.4 REQUIRED)
|
find_package(Td 1.1.5 REQUIRED)
|
||||||
|
|
||||||
add_executable(tdjson_example tdjson_example.cpp)
|
add_executable(tdjson_example tdjson_example.cpp)
|
||||||
target_link_libraries(tdjson_example PRIVATE Td::TdJson)
|
target_link_libraries(tdjson_example PRIVATE Td::TdJson)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
|
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
|
||||||
<Metadata>
|
<Metadata>
|
||||||
<Identity Id="TDLib.UWP" Version="1.1.4" Language="en-US" Publisher="Telegram team" />
|
<Identity Id="TDLib.UWP" Version="1.1.5" Language="en-US" Publisher="Telegram team" />
|
||||||
<DisplayName>TDLib for Universal Windows Platform</DisplayName>
|
<DisplayName>TDLib for Universal Windows Platform</DisplayName>
|
||||||
<Description>TDLib is a library for building Telegram clients</Description>
|
<Description>TDLib is a library for building Telegram clients</Description>
|
||||||
<MoreInfo>https://core.telegram.org/tdlib</MoreInfo>
|
<MoreInfo>https://core.telegram.org/tdlib</MoreInfo>
|
||||||
|
@ -2038,7 +2038,7 @@ createTemporaryPassword password:string valid_for:int32 = TemporaryPasswordState
|
|||||||
getTemporaryPasswordState = TemporaryPasswordState;
|
getTemporaryPasswordState = TemporaryPasswordState;
|
||||||
|
|
||||||
|
|
||||||
//@description Handles a DC_UPDATE push service notification, can be called before authorization @dc Value of the "dc" parameter of the notification @addr Value of the "addr" parameter of the notification
|
//@description Handles a DC_UPDATE push service notification. Can be called before authorization @dc Value of the "dc" parameter of the notification @addr Value of the "addr" parameter of the notification
|
||||||
processDcUpdate dc:string addr:string = Ok;
|
processDcUpdate dc:string addr:string = Ok;
|
||||||
|
|
||||||
|
|
||||||
@ -2258,16 +2258,16 @@ editInlineMessageCaption inline_message_id:string reply_markup:ReplyMarkup capti
|
|||||||
editInlineMessageReplyMarkup inline_message_id:string reply_markup:ReplyMarkup = Ok;
|
editInlineMessageReplyMarkup inline_message_id:string reply_markup:ReplyMarkup = Ok;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns all entities (mentions, hashtags, bot commands, URLs, and email addresses) contained in the text. This is an offline method. May be called before authorization. Can be called synchronously @text The text in which to look for entites
|
//@description Returns all entities (mentions, hashtags, bot commands, URLs, and email addresses) contained in the text. This is an offline method. Can be called before authorization. Can be called synchronously @text The text in which to look for entites
|
||||||
getTextEntities text:string = TextEntities;
|
getTextEntities text:string = TextEntities;
|
||||||
|
|
||||||
//@description Parses Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text. This is an offline method. May be called before authorization. Can be called synchronously @text The text which should be parsed @parse_mode Text parse mode
|
//@description Parses Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text. This is an offline method. Can be called before authorization. Can be called synchronously @text The text which should be parsed @parse_mode Text parse mode
|
||||||
parseTextEntities text:string parse_mode:TextParseMode = FormattedText;
|
parseTextEntities text:string parse_mode:TextParseMode = FormattedText;
|
||||||
|
|
||||||
//@description Returns the MIME type of a file, guessed by its extension. Returns an empty string on failure. This is an offline method. May be called before authorization. Can be called synchronously @file_name The name of the file or path to the file
|
//@description Returns the MIME type of a file, guessed by its extension. Returns an empty string on failure. This is an offline method. Can be called before authorization. Can be called synchronously @file_name The name of the file or path to the file
|
||||||
getFileMimeType file_name:string = Text;
|
getFileMimeType file_name:string = Text;
|
||||||
|
|
||||||
//@description Returns the extension of a file, guessed by its MIME type. Returns an empty string on failure. This is an offline method. May be called before authorization. Can be called synchronously @mime_type The MIME type of the file
|
//@description Returns the extension of a file, guessed by its MIME type. Returns an empty string on failure. This is an offline method. Can be called before authorization. Can be called synchronously @mime_type The MIME type of the file
|
||||||
getFileExtension mime_type:string = Text;
|
getFileExtension mime_type:string = Text;
|
||||||
|
|
||||||
|
|
||||||
@ -2734,11 +2734,11 @@ setUserPrivacySettingRules setting:UserPrivacySetting rules:userPrivacySettingRu
|
|||||||
getUserPrivacySettingRules setting:UserPrivacySetting = UserPrivacySettingRules;
|
getUserPrivacySettingRules setting:UserPrivacySetting = UserPrivacySettingRules;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) This method can be called before authorization
|
//@description Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization
|
||||||
//@name The name of the option
|
//@name The name of the option
|
||||||
getOption name:string = OptionValue;
|
getOption name:string = OptionValue;
|
||||||
|
|
||||||
//@description Sets the value of an option. (Check the list of available options on https://core.telegram.org/tdlib/options.) Only writable options can be set. This method can be called before authorization
|
//@description Sets the value of an option. (Check the list of available options on https://core.telegram.org/tdlib/options.) Only writable options can be set. Can be called before authorization
|
||||||
//@name The name of the option @value The new value of the option
|
//@name The name of the option @value The new value of the option
|
||||||
setOption name:string value:OptionValue = Ok;
|
setOption name:string value:OptionValue = Ok;
|
||||||
|
|
||||||
@ -2827,7 +2827,10 @@ answerCustomQuery custom_query_id:int64 data:string = Ok;
|
|||||||
setAlarm seconds:double = Ok;
|
setAlarm seconds:double = Ok;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns the default text for invitation messages to be used as a placeholder when the current user invites friends to Telegram.
|
//@description Uses current user IP to found his country. Returns two-letter ISO 3166-1 alpha-2 country code. Can be called before authorization
|
||||||
|
getCountryCode = Text;
|
||||||
|
|
||||||
|
//@description Returns the default text for invitation messages to be used as a placeholder when the current user invites friends to Telegram
|
||||||
getInviteText = Text;
|
getInviteText = Text;
|
||||||
|
|
||||||
//@description Returns the terms of service. Can be called before authorization
|
//@description Returns the terms of service. Can be called before authorization
|
||||||
|
Binary file not shown.
@ -118,7 +118,12 @@ void Td::ResultHandler::send_query(NetQueryPtr query) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GetNearestDcQuery : public Td::ResultHandler {
|
class GetNearestDcQuery : public Td::ResultHandler {
|
||||||
|
Promise<string> promise_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit GetNearestDcQuery(Promise<string> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
void send() {
|
void send() {
|
||||||
send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getNearestDc()), DcId::main(),
|
send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getNearestDc()), DcId::main(),
|
||||||
NetQuery::Type::Common, NetQuery::AuthFlag::Off));
|
NetQuery::Type::Common, NetQuery::AuthFlag::Off));
|
||||||
@ -129,11 +134,13 @@ class GetNearestDcQuery : public Td::ResultHandler {
|
|||||||
if (result_ptr.is_error()) {
|
if (result_ptr.is_error()) {
|
||||||
return on_error(id, result_ptr.move_as_error());
|
return on_error(id, result_ptr.move_as_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
promise_.set_value(std::move(result_ptr.ok()->country_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(uint64 id, Status status) override {
|
void on_error(uint64 id, Status status) override {
|
||||||
LOG(ERROR) << "GetNearestDc returned " << status;
|
LOG(ERROR) << "GetNearestDc returned " << status;
|
||||||
status.ignore();
|
promise_.set_error(std::move(status));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -419,7 +426,8 @@ class GetTermsOfServiceQuery : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void send() {
|
void send() {
|
||||||
send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getTermsOfService())));
|
send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getTermsOfService()), DcId::main(),
|
||||||
|
NetQuery::Type::Common, NetQuery::AuthFlag::Off));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_result(uint64 id, BufferSlice packet) override {
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
@ -3625,6 +3633,31 @@ class AnswerCustomQueryRequest : public RequestOnceActor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GetCountryCodeRequest : public RequestActor<string> {
|
||||||
|
string country_code_;
|
||||||
|
|
||||||
|
void do_run(Promise<string> &&promise) override {
|
||||||
|
if (get_tries() < 2) {
|
||||||
|
promise.set_value(std::move(country_code_));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
td->create_handler<GetNearestDcQuery>(std::move(promise))->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_set_result(string &&result) override {
|
||||||
|
country_code_ = std::move(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_send_result() override {
|
||||||
|
send_result(make_tl_object<td_api::text>(country_code_));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
GetCountryCodeRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class GetInviteTextRequest : public RequestActor<string> {
|
class GetInviteTextRequest : public RequestActor<string> {
|
||||||
string text_;
|
string text_;
|
||||||
|
|
||||||
@ -4471,7 +4504,7 @@ Status Td::init(DbKey key) {
|
|||||||
|
|
||||||
VLOG(td_init) << "Ping datacenter";
|
VLOG(td_init) << "Ping datacenter";
|
||||||
if (!auth_manager_->is_authorized()) {
|
if (!auth_manager_->is_authorized()) {
|
||||||
create_handler<GetNearestDcQuery>()->send();
|
create_handler<GetNearestDcQuery>(Auto())->send();
|
||||||
} else {
|
} else {
|
||||||
updates_manager_->get_difference("init");
|
updates_manager_->get_difference("init");
|
||||||
}
|
}
|
||||||
@ -6715,6 +6748,10 @@ void Td::on_request(uint64 id, td_api::removeRecentHashtag &request) {
|
|||||||
send_closure(hashtag_hints_, &HashtagHints::remove_hashtag, std::move(request.hashtag_), std::move(query_promise));
|
send_closure(hashtag_hints_, &HashtagHints::remove_hashtag, std::move(request.hashtag_), std::move(query_promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::getCountryCode &request) {
|
||||||
|
CREATE_NO_ARGS_REQUEST(GetCountryCodeRequest);
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::getInviteText &request) {
|
void Td::on_request(uint64 id, const td_api::getInviteText &request) {
|
||||||
CHECK_AUTH();
|
CHECK_AUTH();
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
|
@ -192,7 +192,7 @@ class Td final : public NetQueryCallback {
|
|||||||
static td_api::object_ptr<td_api::Object> static_request(td_api::object_ptr<td_api::Function> function);
|
static td_api::object_ptr<td_api::Object> static_request(td_api::object_ptr<td_api::Function> function);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr const char *tdlib_version = "1.1.4";
|
static constexpr const char *tdlib_version = "1.1.5";
|
||||||
static constexpr int64 ONLINE_ALARM_ID = 0;
|
static constexpr int64 ONLINE_ALARM_ID = 0;
|
||||||
static constexpr int32 ONLINE_TIMEOUT = 240;
|
static constexpr int32 ONLINE_TIMEOUT = 240;
|
||||||
static constexpr int64 PING_SERVER_ALARM_ID = -1;
|
static constexpr int64 PING_SERVER_ALARM_ID = -1;
|
||||||
@ -755,6 +755,8 @@ class Td final : public NetQueryCallback {
|
|||||||
|
|
||||||
void on_request(uint64 id, td_api::removeRecentHashtag &request);
|
void on_request(uint64 id, td_api::removeRecentHashtag &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::getCountryCode &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getInviteText &request);
|
void on_request(uint64 id, const td_api::getInviteText &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getTermsOfService &request);
|
void on_request(uint64 id, const td_api::getTermsOfService &request);
|
||||||
|
@ -1498,6 +1498,8 @@ class CliClient final : public Actor {
|
|||||||
send_request(make_tl_object<td_api::disconnectAllWebsites>());
|
send_request(make_tl_object<td_api::disconnectAllWebsites>());
|
||||||
} else if (op == "gw") {
|
} else if (op == "gw") {
|
||||||
send_request(make_tl_object<td_api::getWallpapers>());
|
send_request(make_tl_object<td_api::getWallpapers>());
|
||||||
|
} else if (op == "gccode") {
|
||||||
|
send_request(make_tl_object<td_api::getCountryCode>());
|
||||||
} else if (op == "git") {
|
} else if (op == "git") {
|
||||||
send_request(make_tl_object<td_api::getInviteText>());
|
send_request(make_tl_object<td_api::getInviteText>());
|
||||||
} else if (op == "gtos") {
|
} else if (op == "gtos") {
|
||||||
|
Loading…
Reference in New Issue
Block a user