diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-09-07 17:03:55 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-09-07 17:03:55 +0000 |
commit | 2f93b4225f3b0f908170c6591cc083ee3d297348 (patch) | |
tree | 86e36c1bbba059ed3cf25517045940ebb8bc8023 | |
parent | 004d9c7b18f7e5b8a4660e17238962630e2aadaa (diff) |
Added the OnBotPreLoad event to fix introducing StatServ
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2494 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | include/modules.h | 8 | ||||
-rw-r--r-- | src/bots.cpp | 10 | ||||
-rw-r--r-- | src/core/ss_main.c | 11 |
3 files changed, 26 insertions, 3 deletions
diff --git a/include/modules.h b/include/modules.h index 101fa6902..12a061c9e 100644 --- a/include/modules.h +++ b/include/modules.h @@ -578,6 +578,12 @@ class CoreExport Module */ virtual void OnBotBan(User *u, ChannelInfo *ci, const char *mask) { } + /** Called after a bot has been created, but NOT added to the internal + * list and NOT introduced + * @param bi The bot + */ + virtual void OnBotPreLoad(BotInfo *bi) { } + /** Called when a bot kicks a user * @param u The user being kicked * @param ci The channel @@ -890,7 +896,7 @@ enum Implementation /* BotServ */ I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign, - I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, + I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBotPreLoad, /* HostServ */ I_OnDeleteHostCore, I_OnFindHostCore, I_OnInsertHostCore, diff --git a/src/bots.cpp b/src/bots.cpp index 2dbaa8b83..4cb4556f2 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -17,7 +17,6 @@ BotInfo::BotInfo(const char *nnick) this->nick = sstrdup(nnick); this->lastmsg = time(NULL); this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? - insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. nbots++; this->cmdTable = NULL; this->flags = 0; @@ -37,6 +36,10 @@ BotInfo::BotInfo(const char *nnick) this->flags |= BI_NICKSERV; else if (s_GlobalNoticer && !stricmp(s_GlobalNoticer, nnick)) this->flags |= BI_GLOBAL; + + FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this)); + + insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. // If we're synchronised with the uplink already, call introduce_user() for this bot. alog("serv_uplink is %p and status is %d", static_cast<void *>(serv_uplink), serv_uplink ? serv_uplink->sync == SSYNC_DONE : 0); @@ -52,7 +55,6 @@ BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const this->real = sstrdup(nreal); this->lastmsg = time(NULL); this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? - insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. nbots++; this->cmdTable = NULL; this->flags = 0; @@ -72,6 +74,10 @@ BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const this->flags |= BI_NICKSERV; else if (s_GlobalNoticer && !stricmp(s_GlobalNoticer, nnick)) this->flags |= BI_GLOBAL; + + FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this)); + + insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. // If we're synchronised with the uplink already, call introduce_user() for this bot. alog("serv_uplink is %p and status is %d", static_cast<void *>(serv_uplink), serv_uplink ? serv_uplink->sync == SSYNC_DONE : 0); diff --git a/src/core/ss_main.c b/src/core/ss_main.c index 22d2edc1b..8dbea1271 100644 --- a/src/core/ss_main.c +++ b/src/core/ss_main.c @@ -42,6 +42,7 @@ class SSMain : public Module this->SetPermanent(true); this->AddCommand(cmdTable, new CommandSSHelp(), MOD_HEAD); + ModuleManager::Attach(I_OnBotPreLoad, this); statserv = findbot("StatServ"); if (!statserv) @@ -71,6 +72,16 @@ class SSMain : public Module delete statserv; } } + + void OnBotPreLoad(BotInfo *bi) + { + if (!strcmp(bi->nick, "StatServ")) + { + delete statserv; + statserv = bi; + statserv->cmdTable = cmdTable; + } + } }; MODULE_INIT("ss_main", SSMain) |