Add Td::set_is_bot_online function.
This commit is contained in:
parent
1f01a40521
commit
dd80b0ef25
@ -729,7 +729,7 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
|
|||||||
td->schedule_get_promo_data(0);
|
td->schedule_get_promo_data(0);
|
||||||
G()->td_db()->get_binlog_pmc()->set("fetched_marks_as_unread", "1");
|
G()->td_db()->get_binlog_pmc()->set("fetched_marks_as_unread", "1");
|
||||||
} else {
|
} else {
|
||||||
send_closure(G()->state_manager(), &StateManager::on_online, true);
|
td->set_is_bot_online(true);
|
||||||
}
|
}
|
||||||
send_closure(G()->config_manager(), &ConfigManager::request_config);
|
send_closure(G()->config_manager(), &ConfigManager::request_config);
|
||||||
if (query_id_ != 0) {
|
if (query_id_ != 0) {
|
||||||
|
@ -3031,7 +3031,7 @@ void Td::on_alarm_timeout(int64 alarm_id) {
|
|||||||
updates_manager_->ping_server();
|
updates_manager_->ping_server();
|
||||||
alarm_timeout_.set_timeout_in(PING_SERVER_ALARM_ID,
|
alarm_timeout_.set_timeout_in(PING_SERVER_ALARM_ID,
|
||||||
PING_SERVER_TIMEOUT + Random::fast(0, PING_SERVER_TIMEOUT / 5));
|
PING_SERVER_TIMEOUT + Random::fast(0, PING_SERVER_TIMEOUT / 5));
|
||||||
send_closure(G()->state_manager(), &StateManager::on_online, false);
|
set_is_bot_online(false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3190,6 +3190,15 @@ bool Td::is_online() const {
|
|||||||
return is_online_;
|
return is_online_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::set_is_bot_online(bool is_bot_online) {
|
||||||
|
if (is_bot_online == is_bot_online_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
is_bot_online_ = is_bot_online;
|
||||||
|
send_closure(G()->state_manager(), &StateManager::on_online, is_bot_online_);
|
||||||
|
}
|
||||||
|
|
||||||
bool Td::is_authentication_request(int32 id) {
|
bool Td::is_authentication_request(int32 id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case td_api::setTdlibParameters::ID:
|
case td_api::setTdlibParameters::ID:
|
||||||
@ -3538,7 +3547,7 @@ void Td::on_result(NetQueryPtr query) {
|
|||||||
if (auth_manager_->is_bot() && auth_manager_->is_authorized()) {
|
if (auth_manager_->is_bot() && auth_manager_->is_authorized()) {
|
||||||
alarm_timeout_.set_timeout_in(PING_SERVER_ALARM_ID,
|
alarm_timeout_.set_timeout_in(PING_SERVER_ALARM_ID,
|
||||||
PING_SERVER_TIMEOUT + Random::fast(0, PING_SERVER_TIMEOUT / 5));
|
PING_SERVER_TIMEOUT + Random::fast(0, PING_SERVER_TIMEOUT / 5));
|
||||||
send_closure(G()->state_manager(), &StateManager::on_online, true);
|
set_is_bot_online(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -4177,7 +4186,7 @@ Status Td::init(DbKey key) {
|
|||||||
on_online_updated(true, true);
|
on_online_updated(true, true);
|
||||||
}
|
}
|
||||||
if (auth_manager_->is_bot()) {
|
if (auth_manager_->is_bot()) {
|
||||||
send_closure(G()->state_manager(), &StateManager::on_online, true);
|
set_is_bot_online(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send binlog events to managers
|
// Send binlog events to managers
|
||||||
|
@ -124,6 +124,8 @@ class Td final : public NetQueryCallback {
|
|||||||
|
|
||||||
bool is_online() const;
|
bool is_online() const;
|
||||||
|
|
||||||
|
void set_is_bot_online(bool is_bot_online);
|
||||||
|
|
||||||
template <class ActorT, class... ArgsT>
|
template <class ActorT, class... ArgsT>
|
||||||
ActorId<ActorT> create_net_actor(ArgsT &&... args) {
|
ActorId<ActorT> create_net_actor(ArgsT &&... args) {
|
||||||
auto slot_id = request_actors_.create(ActorOwn<>(), RequestActorIdType);
|
auto slot_id = request_actors_.create(ActorOwn<>(), RequestActorIdType);
|
||||||
@ -287,6 +289,7 @@ class Td final : public NetQueryCallback {
|
|||||||
Container<ActorOwn<Actor>> request_actors_;
|
Container<ActorOwn<Actor>> request_actors_;
|
||||||
|
|
||||||
bool is_online_ = false;
|
bool is_online_ = false;
|
||||||
|
bool is_bot_online_ = false;
|
||||||
NetQueryRef update_status_query_;
|
NetQueryRef update_status_query_;
|
||||||
|
|
||||||
int64 alarm_id_ = 1;
|
int64 alarm_id_ = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user