Remove some getAuthorizationState usages.

This commit is contained in:
levlam 2023-01-12 22:25:47 +03:00
parent e87e18c8be
commit 75bdc6292b
6 changed files with 8 additions and 23 deletions

View File

@ -75,8 +75,8 @@ def td_receive():
# another test for TDLib execute method # another test for TDLib execute method
print(str(td_execute({'@type': 'getTextEntities', 'text': '@telegram /test_command https://telegram.org telegram.me', '@extra': ['5', 7.0, 'a']})).encode('utf-8')) print(str(td_execute({'@type': 'getTextEntities', 'text': '@telegram /test_command https://telegram.org telegram.me', '@extra': ['5', 7.0, 'a']})).encode('utf-8'))
# start the client by sending request to it # start the client by sending a request to it
td_send({'@type': 'getAuthorizationState', '@extra': 1.01234}) td_send({'@type': 'getOption', 'name': 'version', '@extra': 1.01234})
# main events cycle # main events cycle
while True: while True:

View File

@ -85,11 +85,6 @@ namespace TdApp
AcceptCommand("LogOut"); AcceptCommand("LogOut");
_client.Send(new TdApi.LogOut(), _handler); _client.Send(new TdApi.LogOut(), _handler);
} }
else if (command.StartsWith("gas"))
{
AcceptCommand(command);
_client.Send(new TdApi.GetAuthorizationState(), _handler);
}
else if (command.StartsWith("sap")) else if (command.StartsWith("sap"))
{ {
var args = command.Split(" ".ToCharArray(), 2); var args = command.Split(" ".ToCharArray(), 2);

View File

@ -231,7 +231,7 @@ EOT
* A function to create a dynamically allocated TDLib API object. Can be treated as an analogue of std::make_unique. * A function to create a dynamically allocated TDLib API object. Can be treated as an analogue of std::make_unique.
* Usage example: * Usage example:
* \\code * \\code
* auto get_authorization_state_request = td::td_api::make_object<td::td_api::getAuthorizationState>(); * auto get_me_request = td::td_api::make_object<td::td_api::getMe>();
* auto message_text = td::td_api::make_object<td::td_api::formattedText>("Hello, world!!!", * auto message_text = td::td_api::make_object<td::td_api::formattedText>("Hello, world!!!",
* td::td_api::array<td::td_api::object_ptr<td::td_api::textEntity>>()); * td::td_api::array<td::td_api::object_ptr<td::td_api::textEntity>>());
* auto send_message_request = td::td_api::make_object<td::td_api::sendMessage>(chat_id, 0, 0, nullptr, nullptr, * auto send_message_request = td::td_api::make_object<td::td_api::sendMessage>(chat_id, 0, 0, nullptr, nullptr,

View File

@ -187,7 +187,7 @@ using tl_object_ptr = tl::unique_ptr<Type>;
* A function to create a dynamically allocated TL-object. Can be treated as an analogue of std::make_unique. * A function to create a dynamically allocated TL-object. Can be treated as an analogue of std::make_unique.
* Usage example: * Usage example:
* \code * \code
* auto get_authorization_state_request = td::make_tl_object<td::td_api::getAuthorizationState>(); * auto get_me_request = td::make_tl_object<td::td_api::getMe>();
* auto message_text = td::make_tl_object<td::td_api::formattedText>("Hello, world!!!", * auto message_text = td::make_tl_object<td::td_api::formattedText>("Hello, world!!!",
* td::td_api::array<td::tl_object_ptr<td::td_api::textEntity>>()); * td::td_api::array<td::tl_object_ptr<td::td_api::textEntity>>());
* auto send_message_request = td::make_tl_object<td::td_api::sendMessage>(chat_id, 0, 0, nullptr, nullptr, * auto send_message_request = td::make_tl_object<td::td_api::sendMessage>(chat_id, 0, 0, nullptr, nullptr,

View File

@ -221,14 +221,12 @@ class InitTask : public Task {
private: private:
Options options_; Options options_;
td::Promise<> promise_; td::Promise<> promise_;
bool start_flag_{false};
void start_up() override { void start_up() override {
send_query(td::make_tl_object<td::td_api::getAuthorizationState>(), send_query(td::make_tl_object<td::td_api::getOption>("version"),
[this](auto res) { this->process_authorization_state(res.move_as_ok()); }); [](auto res) { LOG(INFO) << td::td_api::to_string(res.ok()); });
} }
void process_authorization_state(td::tl_object_ptr<td::td_api::Object> authorization_state) { void process_authorization_state(td::tl_object_ptr<td::td_api::Object> authorization_state) {
start_flag_ = true;
td::tl_object_ptr<td::td_api::Function> function; td::tl_object_ptr<td::td_api::Function> function;
switch (authorization_state->get_id()) { switch (authorization_state->get_id()) {
case td::td_api::authorizationStateReady::ID: case td::td_api::authorizationStateReady::ID:
@ -267,9 +265,6 @@ class InitTask : public Task {
}); });
} }
void process_update(std::shared_ptr<TestClient::Update> update) override { void process_update(std::shared_ptr<TestClient::Update> update) override {
if (!start_flag_) {
return;
}
if (!update->object) { if (!update->object) {
return; return;
} }

View File

@ -204,11 +204,10 @@ class DoAuthentication final : public TestClinetTask {
: name_(std::move(name)), phone_(std::move(phone)), code_(std::move(code)), promise_(std::move(promise)) { : name_(std::move(name)), phone_(std::move(phone)), code_(std::move(code)), promise_(std::move(promise)) {
} }
void start_up() final { void start_up() final {
send_query(td::make_tl_object<td::td_api::getAuthorizationState>(), send_query(td::make_tl_object<td::td_api::getOption>("version"),
[this](auto res) { this->process_authorization_state(std::move(res)); }); [](auto res) { LOG(INFO) << td::td_api::to_string(res); });
} }
void process_authorization_state(td::tl_object_ptr<td::td_api::Object> authorization_state) { void process_authorization_state(td::tl_object_ptr<td::td_api::Object> authorization_state) {
start_flag_ = true;
td::tl_object_ptr<td::td_api::Function> function; td::tl_object_ptr<td::td_api::Function> function;
switch (authorization_state->get_id()) { switch (authorization_state->get_id()) {
case td::td_api::authorizationStateWaitPhoneNumber::ID: case td::td_api::authorizationStateWaitPhoneNumber::ID:
@ -261,12 +260,8 @@ class DoAuthentication final : public TestClinetTask {
td::string phone_; td::string phone_;
td::string code_; td::string code_;
td::Promise<> promise_; td::Promise<> promise_;
bool start_flag_{false};
void process_update(std::shared_ptr<TestClient::Update> update) final { void process_update(std::shared_ptr<TestClient::Update> update) final {
if (!start_flag_) {
return;
}
if (!update->object) { if (!update->object) {
return; return;
} }