diff options
author | Adam <Adam@anope.org> | 2016-11-05 13:33:49 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-11-05 13:33:49 -0400 |
commit | 676e18e646aaae665a75e1c6da2220ea6f51b46e (patch) | |
tree | 560b9e8d37bb59a8d6f3b26834a3d618c7a70be8 /src | |
parent | be4083106b245053992e2b15c4c75aa74f5d39de (diff) |
Fix duplicating bots/opers on startup
Diffstat (limited to 'src')
-rw-r--r-- | src/config.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/config.cpp b/src/config.cpp index 6d671401e..e8f81c1a2 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -674,6 +674,31 @@ void Conf::LoadBots() void Conf::ApplyBots() { + /* Associate conf bots with db bots */ + for (BotInfo *bi : Serialize::GetObjects<BotInfo *>()) + { + ServiceBot *sb = ServiceBot::Find(bi->GetNick()); + + if (sb == nullptr) + continue; + + bi->bot = sb; + sb->bi = bi; + } + + /* Apply conf to conf bots */ + for (int i = 0; i < this->CountBlock("service"); ++i) + { + Block *service = this->GetBlock("service", i); + + const Anope::string &nick = service->Get<Anope::string>("nick"); + + for (BotInfo *bi : Serialize::GetObjects<BotInfo *>()) + if (bi->GetNick().equals_ci(nick)) + bi->conf = this; + } + + /* Create new bots for new conf bots */ for (std::pair<Anope::string, User *> p : UserListByNick) { User *u = p.second; @@ -687,6 +712,8 @@ void Conf::ApplyBots() sb->bi = Serialize::New<BotInfo *>(); sb->bi->bot = sb; + sb->bi->conf = this; + sb->bi->SetNick(sb->nick); sb->bi->SetUser(sb->GetIdent()); sb->bi->SetHost(sb->host); @@ -722,7 +749,10 @@ void Conf::LoadOpers() continue; } - Oper *o = Serialize::New<Oper *>(); + Oper *o = Oper::Find(nname); + if (o == nullptr) + o = Serialize::New<Oper *>(); + o->conf = this; o->SetName(nname); o->SetType(ot); |