Fix is_bot.

GitOrigin-RevId: ac6909ef9ed31bfb7b4b34d015f54a7d6e97c3e2
This commit is contained in:
levlam 2018-03-08 20:35:23 +03:00
parent 6afacdd23f
commit a25cfc3e06
3 changed files with 11 additions and 1 deletions

View File

@ -332,6 +332,14 @@ bool AuthManager::is_bot() const {
return is_authorized() && is_bot_; return is_authorized() && is_bot_;
} }
void AuthManager::set_is_bot(bool is_bot) {
if (!is_bot_ && is_bot && api_id_ == 23818) {
LOG(ERROR) << "Fix is_bot to " << is_bot;
G()->td_db()->get_binlog_pmc()->set("auth_is_bot", "true");
is_bot_ = true;
}
}
bool AuthManager::is_authorized() const { bool AuthManager::is_authorized() const {
return state_ == State::Ok; return state_ == State::Ok;
} }

View File

@ -111,6 +111,7 @@ class AuthManager : public NetActor {
AuthManager(int32 api_id, const string &api_hash, ActorShared<> parent); AuthManager(int32 api_id, const string &api_hash, ActorShared<> parent);
bool is_bot() const; bool is_bot() const;
void set_is_bot(bool is_bot);
bool is_authorized() const; bool is_authorized() const;
void get_state(uint64 query_id); void get_state(uint64 query_id);

View File

@ -4901,8 +4901,10 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
flags |= USER_FLAG_IS_ME; flags |= USER_FLAG_IS_ME;
} }
bool is_bot = (flags & USER_FLAG_IS_BOT) != 0;
if (flags & USER_FLAG_IS_ME) { if (flags & USER_FLAG_IS_ME) {
set_my_id(user_id); set_my_id(user_id);
td_->auth_manager_->set_is_bot(is_bot);
} else { } else {
/* /*
if (!(flags & USER_FLAG_HAS_ACCESS_HASH) && !(flags & USER_FLAG_IS_DELETED) && if (!(flags & USER_FLAG_HAS_ACCESS_HASH) && !(flags & USER_FLAG_IS_DELETED) &&
@ -4958,7 +4960,6 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
bool is_verified = (flags & USER_FLAG_IS_VERIFIED) != 0; bool is_verified = (flags & USER_FLAG_IS_VERIFIED) != 0;
bool is_deleted = (flags & USER_FLAG_IS_DELETED) != 0; bool is_deleted = (flags & USER_FLAG_IS_DELETED) != 0;
bool is_bot = (flags & USER_FLAG_IS_BOT) != 0;
bool can_join_groups = (flags & USER_FLAG_IS_PRIVATE_BOT) == 0; bool can_join_groups = (flags & USER_FLAG_IS_PRIVATE_BOT) == 0;
bool can_read_all_group_messages = (flags & USER_FLAG_IS_BOT_WITH_PRIVACY_DISABLED) != 0; bool can_read_all_group_messages = (flags & USER_FLAG_IS_BOT_WITH_PRIVACY_DISABLED) != 0;
string restriction_reason = std::move(user->restriction_reason_); string restriction_reason = std::move(user->restriction_reason_);