diff options
author | Adam <Adam@anope.org> | 2010-12-25 02:26:00 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-25 02:26:00 -0500 |
commit | 821995bf604b5c6e18e6c0c93a31e149565160c8 (patch) | |
tree | 5b72b437f31e8fb96a45d6ec2ca73ad95185766e | |
parent | 673f6cb2f97d861e08d363cfa09d3022f1322389 (diff) |
Properly remove commands from bots when they are destructed, and run privmsgs for bots we know of but aren't the core
-rw-r--r-- | src/bots.cpp | 8 | ||||
-rw-r--r-- | src/messages.cpp | 6 | ||||
-rw-r--r-- | src/modules.cpp | 3 |
3 files changed, 14 insertions, 3 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index 33f871f1b..a11754e74 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -72,6 +72,14 @@ BotInfo::~BotInfo() ci->bi = NULL; } + for (CommandMap::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) + { + Command *c = it->second; + + if (c->module) + c->module->DelCommand(this, c); + } + BotListByNick.erase(this->nick); if (!this->uid.empty()) BotListByUID.erase(this->uid); diff --git a/src/messages.cpp b/src/messages.cpp index 6d93aeb13..4ba39d6fc 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -174,9 +174,7 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const ircdproto->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str()); } } - if (bi == NickServ || bi == MemoServ || bi == BotServ) - mod_run_cmd(bi, u, message); - else if (bi == ChanServ) + if (bi == ChanServ) { if (!is_oper(u) && Config->CSOpersOnly) u->SendMessage(ChanServ, ACCESS_DENIED); @@ -204,6 +202,8 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const mod_run_cmd(bi, u, message); } } + else + mod_run_cmd(bi, u, message); } } diff --git a/src/modules.cpp b/src/modules.cpp index 1fc83c06e..c5c964e61 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -173,6 +173,9 @@ int Module::DelCommand(BotInfo *bi, Command *c) if (!bi->Commands.erase(c->name)) return MOD_ERR_NOEXIST; + + c->module = NULL; + c->service = NULL; return MOD_ERR_OK; } |