diff options
| author | Adam <Adam@anope.org> | 2011-07-14 02:31:12 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2011-07-14 02:31:12 -0400 |
| commit | f858164deed48f2dcacd5ffc06a55398a54da7e8 (patch) | |
| tree | 89c3cf36bd8e94942370135218d67d6d17ee222e /modules/extra | |
| parent | 924f6849fee4598a1a3a7f1a98d96b79e5ffd3b4 (diff) | |
Rewrote how commands are handled within Anope.
This allows naming commands and having spaces within command names.
Diffstat (limited to 'modules/extra')
| -rw-r--r-- | modules/extra/cs_appendtopic.cpp | 46 | ||||
| -rw-r--r-- | modules/extra/cs_enforce.cpp | 36 | ||||
| -rw-r--r-- | modules/extra/cs_entrymsg.cpp | 42 | ||||
| -rw-r--r-- | modules/extra/cs_set_misc.cpp | 78 | ||||
| -rw-r--r-- | modules/extra/cs_tban.cpp | 35 | ||||
| -rw-r--r-- | modules/extra/hs_request.cpp | 159 | ||||
| -rw-r--r-- | modules/extra/m_alias.cpp | 230 | ||||
| -rw-r--r-- | modules/extra/m_async_commands.cpp | 13 | ||||
| -rw-r--r-- | modules/extra/m_dnsbl.cpp | 16 | ||||
| -rw-r--r-- | modules/extra/m_helpchan.cpp | 5 | ||||
| -rw-r--r-- | modules/extra/m_ldap_authentication.cpp | 36 | ||||
| -rw-r--r-- | modules/extra/m_xmlrpc_main.cpp | 12 | ||||
| -rw-r--r-- | modules/extra/ns_maxemail.cpp | 25 | ||||
| -rw-r--r-- | modules/extra/ns_set_misc.cpp | 81 | ||||
| -rw-r--r-- | modules/extra/os_defcon.cpp | 199 |
15 files changed, 280 insertions, 733 deletions
diff --git a/modules/extra/cs_appendtopic.cpp b/modules/extra/cs_appendtopic.cpp index bb6702237..41a69f9fc 100644 --- a/modules/extra/cs_appendtopic.cpp +++ b/modules/extra/cs_appendtopic.cpp @@ -17,7 +17,6 @@ /*************************************************************************/ #include "module.h" -#include "chanserv.h" /* ------------------------------------------------------------ * Name: cs_appendtopic @@ -40,49 +39,48 @@ /* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ /* ---------------------------------------------------------------------- */ -static Module *me; - class CommandCSAppendTopic : public Command { public: - CommandCSAppendTopic() : Command("APPENDTOPIC", 2, 2) + CommandCSAppendTopic(Module *creator) : Command(creator, "APPENDTOPIC", 2, 2) { this->SetDesc(_("Add text to a channels topic")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &newtopic = params[1]; User *u = source.u; - ChannelInfo *ci = source.ci; - Channel *c = ci->c; + Channel *c = findchan(params[0]);; if (!c) - source.Reply(_(CHAN_X_NOT_IN_USE), ci->name.c_str()); - else if (!check_access(u, ci, CA_TOPIC)) - source.Reply(_(ACCESS_DENIED)); + source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); + else if (!c->ci) + source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); + else if (!check_access(u, c->ci, CA_TOPIC)) + source.Reply(ACCESS_DENIED); else { Anope::string topic; - if (!ci->last_topic.empty()) + if (!c->ci->last_topic.empty()) { - topic = ci->last_topic + " " + newtopic; - ci->last_topic.clear(); + topic = c->ci->last_topic + " " + newtopic; + c->ci->last_topic.clear(); } else topic = newtopic; - bool has_topiclock = ci->HasFlag(CI_TOPICLOCK); - ci->UnsetFlag(CI_TOPICLOCK); + bool has_topiclock = c->ci->HasFlag(CI_TOPICLOCK); + c->ci->UnsetFlag(CI_TOPICLOCK); c->ChangeTopic(u->nick, topic, Anope::CurTime); if (has_topiclock) - ci->SetFlag(CI_TOPICLOCK); + c->ci->SetFlag(CI_TOPICLOCK); - bool override = !check_access(u, ci, CA_TOPIC); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "changed topic to " << topic; + bool override = !check_access(u, c->ci, CA_TOPIC); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, c->ci) << "changed topic to " << topic; } - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) @@ -107,16 +105,12 @@ class CSAppendTopic : public Module CommandCSAppendTopic commandcsappendtopic; public: - CSAppendTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + CSAppendTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + commandcsappendtopic(this) { this->SetAuthor("SGR"); - if (!chanserv) - throw ModuleException("ChanServ is not loaded!"); - - me = this; - - this->AddCommand(chanserv->Bot(), &commandcsappendtopic); + ModuleManager::RegisterService(&commandcsappendtopic); } }; diff --git a/modules/extra/cs_enforce.cpp b/modules/extra/cs_enforce.cpp index c39744ca2..d258f7458 100644 --- a/modules/extra/cs_enforce.cpp +++ b/modules/extra/cs_enforce.cpp @@ -14,9 +14,6 @@ */ #include "module.h" -#include "chanserv.h" - -static Module *me; class CommandCSEnforce : public Command { @@ -122,22 +119,24 @@ class CommandCSEnforce : public Command } } public: - CommandCSEnforce() : Command("ENFORCE", 1, 2) + CommandCSEnforce(Module *creator) : Command(creator, "ENFORCE", 1, 2) { this->SetDesc(_("Enforce various channel modes and set options")); + this->SetSyntax(_("\037channel\037 [\037what\037]")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &what = params.size() > 1 ? params[1] : ""; User *u = source.u; - ChannelInfo *ci = source.ci; - Channel *c = ci->c; + Channel *c = findchan(params[0]); if (!c) - source.Reply(_(CHAN_X_NOT_IN_USE), ci->name.c_str()); - else if (!check_access(u, ci, CA_AKICK)) + source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); + else if (!c->ci) + source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); + else if (!check_access(u, c->ci, CA_AKICK)) source.Reply(ACCESS_DENIED); else { @@ -170,12 +169,12 @@ class CommandCSEnforce : public Command this->OnSyntaxError(source, ""); } - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002ENFORCE \037channel\037 [\037what\037]\002")); + this->SendSyntax(source); source.Reply(" "); source.Reply(_("Enforce various channel modes and set options. The \037channel\037\n" "option indicates what channel to enforce the modes and options\n" @@ -204,11 +203,6 @@ class CommandCSEnforce : public Command return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: \002ENFORCE \037channel\037 [\037what\037]\002")); - } }; class CSEnforce : public Module @@ -216,16 +210,12 @@ class CSEnforce : public Module CommandCSEnforce commandcsenforce; public: - CSEnforce(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + CSEnforce(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + commandcsenforce(this) { this->SetAuthor("Anope"); - if (!chanserv) - throw ModuleException("ChanServ is not loaded!"); - - me = this; - - this->AddCommand(chanserv->Bot(), &commandcsenforce); + ModuleManager::RegisterService(&commandcsenforce); } }; diff --git a/modules/extra/cs_entrymsg.cpp b/modules/extra/cs_entrymsg.cpp index dbfe35d35..28f5603f8 100644 --- a/modules/extra/cs_entrymsg.cpp +++ b/modules/extra/cs_entrymsg.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "chanserv.h" struct EntryMsg { @@ -41,7 +40,7 @@ class CommandEntryMessage : public Command { source.Reply(_("Entry message list for \2%s\2:"), ci->name.c_str()); for (unsigned i = 0; i < messages.size(); ++i) - source.Reply(_(CHAN_LIST_ENTRY), i + 1, messages[i].message.c_str(), messages[i].creator.c_str(), do_strftime(messages[i].when).c_str()); + source.Reply(CHAN_LIST_ENTRY, i + 1, messages[i].message.c_str(), messages[i].creator.c_str(), do_strftime(messages[i].when).c_str()); source.Reply(_("End of entry message list.")); } else @@ -98,17 +97,24 @@ class CommandEntryMessage : public Command } public: - CommandEntryMessage(const Anope::string &cname) : Command(cname, 2, 3) + CommandEntryMessage(Module *creator) : Command(creator, "ENTRYMSG", 2, 3) { this->SetDesc(_("Manage the channel's entry messages")); + this->SetSyntax(_("\037channel\037 {ADD|DEL|LIST|CLEAR} [\037message\037|\037num\037]")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.u; - ChannelInfo *ci = source.ci; - if (ci && (IsFounder(u, ci) || u->HasCommand("chanserv/entrymsg"))) + ChannelInfo *ci = cs_findchan(params[0]); + if (ci == NULL) + { + source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); + return; + } + + if (IsFounder(u, ci) || u->HasCommand("chanserv/entrymsg")) { bool success = true; if (params[1].equals_ci("LIST")) @@ -133,23 +139,16 @@ class CommandEntryMessage : public Command Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << params[1]; } else - { - source.Reply(_(ACCESS_DENIED)); - } + source.Reply(ACCESS_DENIED); - return MOD_CONT; - } - - void OnSyntaxError(CommandSource &source, const Anope::string &) - { - SyntaxError(source, "ENTRYMSG", _("ENTRYMSG \037channel\037 {ADD|DEL|LIST|CLEAR} [\037message\037|\037num\037]")); + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002ENTRYMSG \037channel\037 {ADD|DEL|LIST|CLEAR} [\037message\037|\037num\037]\002\n" - " \n" - "Controls what messages will be sent to users when they join the channel.")); + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Controls what messages will be sent to users when they join the channel.")); return true; } }; @@ -159,17 +158,14 @@ class CSEntryMessage : public Module CommandEntryMessage commandentrymsg; public: - CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), commandentrymsg("ENTRYMSG") + CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), commandentrymsg(this) { this->SetAuthor("Anope"); - if (!chanserv) - throw ModuleException("ChanServ is not loaded!"); - Implementation i[] = { I_OnJoinChannel, I_OnReload, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata }; ModuleManager::Attach(i, this, 4); - this->AddCommand(chanserv->Bot(), &commandentrymsg); + ModuleManager::RegisterService(&commandentrymsg); this->OnReload(); } diff --git a/modules/extra/cs_set_misc.cpp b/modules/extra/cs_set_misc.cpp index 2318d415c..03c498b07 100644 --- a/modules/extra/cs_set_misc.cpp +++ b/modules/extra/cs_set_misc.cpp @@ -11,52 +11,45 @@ /*************************************************************************/ #include "module.h" -#include "chanserv.h" class CommandCSSetMisc : public Command { Anope::string Desc; public: - CommandCSSetMisc(const Anope::string &cname, const Anope::string &cdesc, const Anope::string &cpermission = "") : Command(cname, 1, 2, cpermission), Desc(cdesc) + CommandCSSetMisc(Module *creator, const Anope::string &cname, const Anope::string &cdesc, const Anope::string &cpermission = "") : Command(creator, "chanserv/set/" + cname, 1, 2, cpermission), Desc(cdesc) { this->SetDesc(cdesc); + this->SetSyntax(_("\037channel\037 \037option\037 \037parameters\037")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - ChannelInfo *ci = source.ci; - if (!ci) - throw CoreException("NULL ci in CommandCSSetMisc"); + ChannelInfo *ci = cs_findchan(params[0]); + if (ci == NULL) + { + source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); + return; + } ci->Shrink("chanserv:" + this->name); if (params.size() > 1) { ci->Extend("chanserv:" + this->name, new ExtensibleItemRegular<Anope::string>(params[1])); - source.Reply(_(CHAN_SETTING_CHANGED), this->name.c_str(), ci->name.c_str(), params[1].c_str()); + source.Reply(CHAN_SETTING_CHANGED, this->name.c_str(), ci->name.c_str(), params[1].c_str()); } else - source.Reply(_(CHAN_SETTING_UNSET), this->name.c_str(), ci->name.c_str()); + source.Reply(CHAN_SETTING_UNSET, this->name.c_str(), ci->name.c_str()); - return MOD_CONT; - } - - void OnSyntaxError(CommandSource &source, const Anope::string &) - { - SyntaxError(source, "SET", _(CHAN_SET_SYNTAX)); + return; } }; class CommandCSSASetMisc : public CommandCSSetMisc { public: - CommandCSSASetMisc(const Anope::string &cname, const Anope::string &cdesc) : CommandCSSetMisc(cname, cdesc, "chanserv/saset/" + cname) + CommandCSSASetMisc(Module *creator, const Anope::string &cname, const Anope::string &cdesc) : CommandCSSetMisc(creator, cname, cdesc, "chanserv/saset/" + cname) { } - - void OnSyntaxError(CommandSource &source, const Anope::string &) - { - SyntaxError(source, "SASET", _(CHAN_SASET_SYNTAX)); - } }; class CSSetMisc : public Module @@ -75,37 +68,8 @@ class CSSetMisc : public Module void RemoveAll() { - if (!chanserv || Commands.empty()) - return; - - Command *set = FindCommand(chanserv->Bot(), "SET"); - Command *saset = FindCommand(chanserv->Bot(), "SASET"); - - if (!set && !saset) - return; - for (std::map<Anope::string, CommandInfo *>::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) - { - if (set) - { - Command *c = set->FindSubcommand(it->second->Name); - if (c) - { - set->DelSubcommand(c); - delete c; - } - } - if (saset) - { - Command *c = saset->FindSubcommand(it->second->Name); - if (c) - { - saset->DelSubcommand(c); - delete c; - } - } - } - + delete it->second; this->Commands.clear(); } @@ -114,9 +78,6 @@ class CSSetMisc : public Module { this->SetAuthor("Anope"); - if (!chanserv) - throw ModuleException("ChanServ is not loaded!"); - Implementation i[] = { I_OnReload, I_OnChanInfo, I_OnDatabaseWriteMetadata, I_OnDatabaseReadMetadata }; ModuleManager::Attach(i, this, 4); @@ -132,11 +93,6 @@ class CSSetMisc : public Module { RemoveAll(); - Command *set = FindCommand(chanserv->Bot(), "SET"); - Command *saset = FindCommand(chanserv->Bot(), "SASET"); - if (!set && !saset) - return; - ConfigReader config; for (int i = 0, num = config.Enumerate("cs_set_misc"); i < num; ++i) @@ -155,10 +111,8 @@ class CSSetMisc : public Module continue; } - if (set) - set->AddSubcommand(this, new CommandCSSetMisc(cname, desc)); - if (saset) - saset->AddSubcommand(this, new CommandCSSASetMisc(cname, desc)); + ModuleManager::RegisterService(new CommandCSSetMisc(this, cname, desc)); + ModuleManager::RegisterService(new CommandCSSASetMisc(this, cname, desc)); } } diff --git a/modules/extra/cs_tban.cpp b/modules/extra/cs_tban.cpp index 78c3b1fa9..a0bb6a626 100644 --- a/modules/extra/cs_tban.cpp +++ b/modules/extra/cs_tban.cpp @@ -16,7 +16,6 @@ /*************************************************************************/ #include "module.h" -#include "chanserv.h" static Module *me; @@ -42,11 +41,11 @@ static bool CanBanUser(CommandSource &source, Channel *c, User *u2) ChannelInfo *ci = c->ci; bool ok = false; if (!check_access(u, ci, CA_BAN)) - source.Reply(_(ACCESS_DENIED)); + source.Reply(ACCESS_DENIED); else if (matches_list(c, u2, CMODE_EXCEPT)) - source.Reply(_(CHAN_EXCEPTED), u2->nick.c_str(), ci->name.c_str()); + source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); else if (u2->IsProtected()) - source.Reply(_(ACCESS_DENIED)); + source.Reply(ACCESS_DENIED); else ok = true; @@ -56,25 +55,24 @@ static bool CanBanUser(CommandSource &source, Channel *c, User *u2) class CommandCSTBan : public Command { public: - CommandCSTBan() : Command("TBAN", 3, 3) + CommandCSTBan(Module *m) : Command(m, "TBAN", 3, 3) { this->SetDesc(_("Bans the user for a given length of time")); + this->SetSyntax(_("\037channel\037 \037nick\037 \037time\037")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - ChannelInfo *ci = source.ci; - Channel *c = ci->c; + Channel *c = findchan(params[0]); - const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; const Anope::string &time = params[2]; User *u2; if (!c) - source.Reply(_(CHAN_X_NOT_IN_USE), chan.c_str()); + source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); else if (!(u2 = finduser(nick))) - source.Reply(_(NICK_X_NOT_IN_USE), nick.c_str()); + source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); else if (CanBanUser(source, c, u2)) { @@ -85,7 +83,7 @@ class CommandCSTBan : public Command source.Reply(_("%s banned from %s, will auto-expire in %s"), mask.c_str(), c->name.c_str(), time.c_str()); } - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) @@ -97,11 +95,6 @@ class CommandCSTBan : public Command return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: TBAN channel nick time")); - } }; class CSTBan : public Module @@ -109,16 +102,14 @@ class CSTBan : public Module CommandCSTBan commandcstban; public: - CSTBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + CSTBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + commandcstban(this) { this->SetAuthor("Anope"); - if (!chanserv) - throw ModuleException("ChanServ is not loaded!"); - me = this; - this->AddCommand(chanserv->Bot(), &commandcstban); + ModuleManager::RegisterService(&commandcstban); } }; diff --git a/modules/extra/hs_request.cpp b/modules/extra/hs_request.cpp index 518acb6de..74fe04dab 100644 --- a/modules/extra/hs_request.cpp +++ b/modules/extra/hs_request.cpp @@ -16,7 +16,6 @@ */ #include "module.h" -#include "hostserv.h" #include "memoserv.h" static bool HSRequestMemoUser = false; @@ -35,8 +34,6 @@ struct HostRequest typedef std::map<Anope::string, HostRequest *, std::less<ci::string> > RequestMap; RequestMap Requests; -static Module *me; - class CommandHSRequest : public Command { bool isvalidchar(char c) @@ -47,12 +44,13 @@ class CommandHSRequest : public Command } public: - CommandHSRequest() : Command("REQUEST", 1, 1) + CommandHSRequest(Module *creator) : Command(creator, "hostserv/request", 1, 1) { this->SetDesc(_("Request a vHost for your nick")); + this->SetSyntax(_("vhost")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.u; @@ -65,46 +63,46 @@ class CommandHSRequest : public Command rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ if (rawhostmask.empty()) { - source.Reply(_("Syntax: \002REQUEST \037vhost\037\002")); - return MOD_CONT; + this->SendSyntax(source); + return; } if (vIdent.length() > Config->UserLen) { - source.Reply(_(HOST_SET_IDENTTOOLONG), Config->UserLen); - return MOD_CONT; + source.Reply(HOST_SET_IDENTTOOLONG, Config->UserLen); + return; } else for (Anope::string::iterator s = vIdent.begin(), s_end = vIdent.end(); s != s_end; ++s) if (!isvalidchar(*s)) { - source.Reply(_(HOST_SET_IDENT_ERROR)); - return MOD_CONT; + source.Reply(HOST_SET_IDENT_ERROR); + return; } if (!ircd->vident) { - source.Reply(_(HOST_NO_VIDENT)); - return MOD_CONT; + source.Reply(HOST_NO_VIDENT); + return; } } if (rawhostmask.length() < Config->HostLen) hostmask = rawhostmask; else { - source.Reply(_(HOST_SET_TOOLONG), Config->HostLen); - return MOD_CONT; + source.Reply(HOST_SET_TOOLONG, Config->HostLen); + return; } if (!isValidHost(hostmask, 3)) { - source.Reply(_(HOST_SET_ERROR)); - return MOD_CONT; + source.Reply(HOST_SET_ERROR); + return; } if (HSRequestMemoOper && Config->MSSendDelay > 0 && u && u->lastmemosend + Config->MSSendDelay > Anope::CurTime) { source.Reply(_("Please wait %d seconds before requesting a new vHost"), Config->MSSendDelay); u->lastmemosend = Anope::CurTime; - return MOD_CONT; + return; } my_add_host_request(u->nick, vIdent, hostmask, u->nick, Anope::CurTime); @@ -112,34 +110,30 @@ class CommandHSRequest : public Command req_send_memos(source, vIdent, hostmask); Log(LOG_COMMAND, u, this, NULL) << "to request new vhost " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask; - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002REQUEST \037vhost\037\002")); + this->SendSyntax(source); source.Reply(" "); source.Reply(_("Request the given vHost to be actived for your nick by the\n" "network administrators. Please be patient while your request\n" "is being considered.")); return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: \002REQUEST \037vhost\037\002")); - } }; class CommandHSActivate : public Command { public: - CommandHSActivate() : Command("ACTIVATE", 1, 1, "hostserv/set") + CommandHSActivate(Module *creator) : Command(creator, "hostserv/activate", 1, 1, "hostserv/set") { this->SetDesc(_("Approve the requested vHost of a user")); + this->SetSyntax(_("\037nick\037")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.u; @@ -155,7 +149,7 @@ class CommandHSActivate : public Command FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (HSRequestMemoUser && memoserv) - memoserv->Send(Config->s_HostServ, na->nick, _("[auto memo] Your requested vHost has been approved."), true); + memoserv->Send(Config->HostServ, na->nick, _("[auto memo] Your requested vHost has been approved."), true); source.Reply(_("vHost for %s has been activated"), na->nick.c_str()); Log(LOG_COMMAND, u, this, NULL) << "for " << na->nick << " for vhost " << (!it->second->ident.empty() ? it->second->ident + "@" : "") << it->second->host; @@ -166,14 +160,14 @@ class CommandHSActivate : public Command source.Reply(_("No request for nick %s found."), nick.c_str()); } else - source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str()); + source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002ACTIVATE \037nick\037\002")); + this->SendSyntax(source); source.Reply(" "); source.Reply(_("Activate the requested vHost for the given nick.")); if (HSRequestMemoUser) @@ -181,22 +175,17 @@ class CommandHSActivate : public Command return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: \002ACTIVATE \037nick\037\002")); - } }; class CommandHSReject : public Command { public: - CommandHSReject() : Command("REJECT", 1, 2, "hostserv/set") + CommandHSReject(Module *creator) : Command(creator, "hostserv/reject", 1, 2, "hostserv/set") { this->SetDesc(_("Reject the requested vHost of a user")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.u; @@ -217,7 +206,7 @@ class CommandHSReject : public Command else message = _("[auto memo] Your requested vHost has been rejected."); - memoserv->Send(Config->s_HostServ, nick, message, true); + memoserv->Send(Config->HostServ, nick, message, true); } source.Reply(_("vHost for %s has been rejected"), nick.c_str()); @@ -226,12 +215,12 @@ class CommandHSReject : public Command else source.Reply(_("No request for nick %s found."), nick.c_str()); - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002REJECT \037nick\037\002")); + this->SendSyntax(source); source.Reply(" "); source.Reply(_("Reject the requested vHost for the given nick.")); if (HSRequestMemoUser) @@ -239,17 +228,12 @@ class CommandHSReject : public Command return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - source.Reply(_("Syntax: \002REJECT \037nick\037\002")); - } }; class HSListBase : public Command { protected: - CommandReturn DoList(CommandSource &source) + void DoList(CommandSource &source) { int counter = 1; int from = 0, to = 0; @@ -270,10 +254,10 @@ class HSListBase : public Command } source.Reply(_("Displayed all records (Count: \002%d\002)"), display_counter); - return MOD_CONT; + return; } public: - HSListBase(const Anope::string &cmd, int min, int max) : Command(cmd, min, max, "hostserv/set") + HSListBase(Module *creator, const Anope::string &cmd, int min, int max) : Command(creator, cmd, min, max, "hostserv/set") { } }; @@ -281,22 +265,22 @@ class HSListBase : public Command class CommandHSWaiting : public HSListBase { public: - CommandHSWaiting() : HSListBase("WAITING", 0, 0) + CommandHSWaiting(Module *creator) : HSListBase(creator, "hostserv/waiting", 0, 0) { - this->SetDesc(_("Convenience command for LIST +req")); + this->SetDesc(_("Retrieves the vhost requests")); + this->SetSyntax(""); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { return this->DoList(source); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002WAITING\002")); + this->SendSyntax(source); source.Reply(" "); - source.Reply(_("This command is provided for convenience. It is essentially\n" - "the same as performing a LIST +req .")); + source.Reply(_("This command retrieves the vhost requests")); return true; } @@ -310,21 +294,17 @@ class HSRequest : public Module CommandHSWaiting commandhswaiting; public: - HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) + HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), + commandhsrequest(this), commandhsactive(this), commandhsreject(this), commandhswaiting(this) { - me = this; - - if (!hostserv) - throw ModuleException("HostServ is not loaded!"); - - this->AddCommand(hostserv->Bot(), &commandhsrequest); - this->AddCommand(hostserv->Bot(), &commandhsactive); - this->AddCommand(hostserv->Bot(), &commandhsreject); - this->AddCommand(hostserv->Bot(), &commandhswaiting); - this->SetAuthor("Anope"); - Implementation i[] = { I_OnPreCommand, I_OnDatabaseRead, I_OnDatabaseWrite, I_OnReload }; + ModuleManager::RegisterService(&commandhsrequest); + ModuleManager::RegisterService(&commandhsactive); + ModuleManager::RegisterService(&commandhsreject); + ModuleManager::RegisterService(&commandhswaiting); + + Implementation i[] = { I_OnDelNick, I_OnDatabaseRead, I_OnDatabaseWrite, I_OnReload }; ModuleManager::Attach(i, this, 4); this->OnReload(); @@ -340,46 +320,15 @@ class HSRequest : public Module } } - EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) + void OnDelNick(NickAlias *na) { - BotInfo *service = source.owner; - if (service->nick == Config->s_HostServ) - { - if (command->name.equals_ci("LIST")) - { - Anope::string key = params.size() ? params[0] : ""; - - if (!key.empty() && key.equals_ci("+req")) - { - std::vector<Anope::string> emptyParams; - Command *c = FindCommand(hostserv->Bot(), "WAITING"); - if (!c) - throw CoreException("No waiting command?"); - c->Execute(source, emptyParams); - return EVENT_STOP; - } - } - } - else if (service->nick == Config->s_NickServ) - { - if (command->name.equals_ci("DROP")) - { - NickAlias *na = findnick(source.u->nick); - - if (na) - { - RequestMap::iterator it = Requests.find(na->nick); + RequestMap::iterator it = Requests.find(na->nick); - if (it != Requests.end()) - { - delete it->second; - Requests.erase(it); - } - } - } + if (it != Requests.end()) + { + delete it->second; + Requests.erase(it); } - - return EVENT_CONTINUE; } EventReturn OnDatabaseRead(const std::vector<Anope::string> ¶ms) @@ -437,7 +386,7 @@ void req_send_memos(CommandSource &source, const Anope::string &vIdent, const An Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.u->GetMask().c_str()); - memoserv->Send(Config->s_HostServ, na->nick, message, true); + memoserv->Send(Config->HostServ, na->nick, message, true); } } diff --git a/modules/extra/m_alias.cpp b/modules/extra/m_alias.cpp deleted file mode 100644 index e1d35b111..000000000 --- a/modules/extra/m_alias.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * (C) 2003-2011 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "module.h" -#include "chanserv.h" - -struct CommandAlias -{ - bool fantasy; - bool operonly; - Anope::string source_client; - Anope::string source_command; - Anope::string source_desc; - Anope::string target_client; - Anope::string target_command; - Anope::string target_rewrite; -}; - -class AliasCommand : public Command -{ - CommandAlias alias; - dynamic_reference<Command> target_command_c; - public: - AliasCommand(CommandAlias &a) : Command(a.source_command, 0, 0), alias(a), target_command_c(NULL) { } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { return MOD_CONT; } - - void OnServHelp(CommandSource &source) - { - Anope::string cdesc = this->alias.source_desc; - if (!this->target_command_c) - this->target_command_c = FindCommand(findbot(this->alias.target_client), this->alias.target_command); - if (this->target_command_c && cdesc.empty()) - cdesc = this->target_command_c->GetDesc(); - if (this->target_command_c) - source.Reply(" %-14s %s", this->name.c_str(), _(cdesc.c_str())); - } - - bool OnHelp(CommandSource &source, const Anope::string &subcommand) - { - if (!this->alias.target_rewrite.empty()) - return false; - - if (!this->target_command_c) - this->target_command_c = FindCommand(findbot(this->alias.target_client), this->alias.target_command); - if (!this->target_command_c) - return false; - - mod_help_cmd(this->target_command_c->service, source.u, source.ci, this->target_command_c->name); - return true; - } -}; - -class ModuleAlias : public Module -{ - std::multimap<Anope::string, CommandAlias, std::less<ci::string> > aliases; - std::vector<AliasCommand *> commands; - - Anope::string RewriteCommand(Anope::string &message, const Anope::string &rewrite) - { - if (rewrite.empty()) - return message; - - std::vector<Anope::string> tokens = BuildStringVector(message); - spacesepstream sep(rewrite); - Anope::string token, final_message; - while (sep.GetToken(token)) - { - if (token[0] == '$' && token.length() > 1) - { - Anope::string number = token.substr(1); - bool all = false; - if (number[number.length() - 1] == '-') - { - number.erase(number.length() - 1); - all = true; - } - if (number.empty()) - continue; - - int index; - try - { - index = convertTo<int>(number); - } - catch (const ConvertException &ex) - { - continue; - } - - if (index < 0 || static_cast<unsigned>(index) >= tokens.size()) - continue; - - final_message += tokens[index] + " "; - if (all) - for (unsigned i = index + i; i < tokens.size(); ++i) - final_message += tokens[i] + " "; - } - else - final_message += token + " "; - } - - final_message.trim(); - return final_message; - } - - public: - ModuleAlias(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) - { - this->SetAuthor("Anope"); - - Implementation i[] = { I_OnReload, I_OnPreCommandRun, I_OnBotFantasy }; - ModuleManager::Attach(i, this, 3); - - OnReload(); - } - - void OnReload() - { - ConfigReader config; - - this->aliases.clear(); - for (unsigned i = 0; i < this->commands.size(); ++i) - delete this->commands[i]; - this->commands.clear(); - - for (int i = 0; i < config.Enumerate("alias"); ++i) - { - bool fantasy = config.ReadFlag("alias", "fantasy", "no", i); - bool operonly = config.ReadFlag("alias", "operonly", "no", i); - bool hide = config.ReadFlag("alias", "hide", "no", i); - Anope::string source_client = config.ReadValue("alias", "source_client", "", i); - Anope::string source_command = config.ReadValue("alias", "source_command", "", i); - Anope::string source_desc = config.ReadValue("alias", "source_desc", "", i); - Anope::string target_client = config.ReadValue("alias", "target_client", "", i); - Anope::string target_command = config.ReadValue("alias", "target_command", "", i); - Anope::string target_rewrite = config.ReadValue("alias", "target_rewrite", "", i); - - if ((!fantasy && source_client.empty()) || source_command.empty() || target_client.empty() || target_command.empty()) - continue; - - CommandAlias alias; - alias.fantasy = fantasy; - alias.operonly = operonly; - alias.source_client = source_client; - alias.source_command = source_command; - alias.source_desc = source_desc; - alias.target_client = target_client; - alias.target_command = target_command; - alias.target_rewrite = target_rewrite; - - this->aliases.insert(std::make_pair(source_command, alias)); - if (hide == false) - { - AliasCommand *cmd = new AliasCommand(alias); - this->commands.push_back(cmd); - BotInfo *bi = findbot(alias.source_client); - if (bi != NULL) - this->AddCommand(bi, cmd); - } - } - } - - EventReturn OnPreCommandRun(User *&u, BotInfo *&bi, Anope::string &command, Anope::string &message, ChannelInfo *&ci) - { - bool fantasy = ci != NULL; - std::multimap<Anope::string, CommandAlias, std::less<ci::string> >::const_iterator it = aliases.find(command), it_end = it; - if (it_end != aliases.end()) - it_end = aliases.upper_bound(command); - for (; it != it_end; ++it) - { - const CommandAlias &alias = it->second; - - if (!u->HasMode(UMODE_OPER) && alias.operonly) - continue; - else if (fantasy != alias.fantasy) - continue; - else if (fantasy && alias.fantasy) // OnBotFantasy gets this! - continue; - else if (!bi->nick.equals_ci(alias.source_client)) - continue; - - BotInfo *target = findbot(alias.target_client); - if (target) - bi = target; - command = alias.target_command; - message = this->RewriteCommand(message, alias.target_rewrite); - break; - } - - return EVENT_CONTINUE; - } - - void OnBotFantasy(const Anope::string &command, User *u, ChannelInfo *ci, const Anope::string ¶ms) - { - std::multimap<Anope::string, CommandAlias, std::less<ci::string> >::const_iterator it = aliases.find(command), it_end = it; - if (it_end != aliases.end()) - it_end = aliases.upper_bound(command); - for (; it != it_end; ++it) - { - const CommandAlias &alias = it->second; - - if (!u->HasMode(UMODE_OPER) && alias.operonly) - continue; - - BotInfo *target = findbot(alias.target_client); - if (!target) - target = chanserv->Bot(); - - Anope::string full_message = alias.target_command; - if (target == chanserv->Bot() || target->nick == Config->s_BotServ) - { - Command *target_c = FindCommand(target, alias.target_command); - if (target_c && !target_c->HasFlag(CFLAG_STRIP_CHANNEL)) - full_message += " " + ci->name; - } - if (!params.empty()) - full_message += + " " + params; - - full_message = this->RewriteCommand(full_message, alias.target_rewrite); - mod_run_cmd(target, u, ci, full_message); - break; - } - } -}; - -MODULE_INIT(ModuleAlias) diff --git a/modules/extra/m_async_commands.cpp b/modules/extra/m_async_commands.cpp index c223bcdc5..665ee536d 100644 --- a/modules/extra/m_async_commands.cpp +++ b/modules/extra/m_async_commands.cpp @@ -53,12 +53,9 @@ class AsynchCommandMutex : public CommandMutex } else { - CommandReturn ret = command->Execute(source, params); - if (ret != MOD_STOP) - { - FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, command, params)); - source.DoReply(); - } + command->Execute(source, params); + FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, command, params)); + source.DoReply(); } main_mutex.Unlock(); @@ -134,14 +131,14 @@ class ModuleAsynchCommands : public Module, public Pipe, public AsynchCommandsSe { AsynchCommandMutex *cm = debug_cast<AsynchCommandMutex *>(*it); - if (cm->started && (cm->command == b || cm->source.u == b || cm->source.owner == b || cm->source.service == b || cm->source.ci == b)) + if (cm->started && (cm->command == b || cm->source.u == b || cm->source.owner == b || cm->source.service == b)) cm->Destroy(); } this->reset = true; } - EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) + EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) { if (ignore_pre_command) { diff --git a/modules/extra/m_dnsbl.cpp b/modules/extra/m_dnsbl.cpp index 06d55df92..a860a10f0 100644 --- a/modules/extra/m_dnsbl.cpp +++ b/modules/extra/m_dnsbl.cpp @@ -6,13 +6,8 @@ */ #include "module.h" -#include "operserv.h" -struct FakeAkill : public Command -{ - FakeAkill() : Command("AKILL", 0, 0) { this->service = findbot(Config->s_OperServ); } - CommandReturn Execute(CommandSource &, const std::vector<Anope::string> &) { return MOD_CONT; } -} fake_akill; +static service_reference<XLineManager> akills("xlinemanager/sgline"); struct Blacklist { @@ -62,17 +57,18 @@ class DNSBLResolver : public DNSRequest reason = reason.replace_all_cs("%N", Config->NetworkName); XLine *x = NULL; - if (this->add_to_akill && SGLine && (x = SGLine->Add(Anope::string("*@") + user->host, Config->s_OperServ, Anope::CurTime + this->blacklist.bantime, reason))) + BotInfo *operserv = findbot(Config->OperServ); + if (this->add_to_akill && akills && (x = akills->Add(Anope::string("*@") + user->host, Config->OperServ, Anope::CurTime + this->blacklist.bantime, reason))) { - Log(LOG_COMMAND, operserv->Bot(), &fake_akill) << "for " << user->GetMask() << " (Listed in " << this->blacklist.name << ")"; + Log(operserv) << "DNSBL: " << user->GetMask() << " appears in " << this->blacklist.name; /* If AkillOnAdd is disabled send it anyway, noone wants bots around... */ if (!Config->AkillOnAdd) ircdproto->SendAkill(user, x); } else { - Log(operserv->Bot()) << "DNSBL: " << user->GetMask() << " appears in " << this->blacklist.name; - XLine xline(Anope::string("*@") + user->host, Config->s_OperServ, Anope::CurTime + this->blacklist.bantime, reason); + Log(operserv) << "DNSBL: " << user->GetMask() << " appears in " << this->blacklist.name << "(" << reason << ")"; + XLine xline(Anope::string("*@") + user->host, Config->OperServ, Anope::CurTime + this->blacklist.bantime, reason); ircdproto->SendAkill(user, &xline); } } diff --git a/modules/extra/m_helpchan.cpp b/modules/extra/m_helpchan.cpp index 6e5cdd2be..5da492a3a 100644 --- a/modules/extra/m_helpchan.cpp +++ b/modules/extra/m_helpchan.cpp @@ -6,7 +6,6 @@ */ #include "module.h" -#include "operserv.h" class HelpChannel : public Module { @@ -25,12 +24,12 @@ class HelpChannel : public Module EventReturn OnChannelModeSet(Channel *c, ChannelModeName Name, const Anope::string ¶m) { - if (Name == CMODE_OP && operserv && c && c->ci && c->name.equals_ci(this->HelpChan)) + if (Name == CMODE_OP && c && c->ci && c->name.equals_ci(this->HelpChan)) { User *u = finduser(param); if (u && check_access(u, c->ci, CA_OPDEOPME)) - u->SetMode(operserv->Bot(), UMODE_HELPOP); + u->SetMode(findbot(Config->OperServ), UMODE_HELPOP); } return EVENT_CONTINUE; diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index 59e532d50..a6fa5bd1b 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -8,11 +8,12 @@ struct IdentifyInfo { dynamic_reference<User> user; dynamic_reference<Command> command; + CommandSource source; std::vector<Anope::string> params; Anope::string account; Anope::string pass; - IdentifyInfo(User *u, Command *c, const std::vector<Anope::string> &pa, const Anope::string &a, const Anope::string &p) : user(u), command(c), params(pa), account(a), pass(p) { } + IdentifyInfo(User *u, Command *c, CommandSource &s, const std::vector<Anope::string> &pa, const Anope::string &a, const Anope::string &p) : user(u), command(c), source(s), params(pa), account(a), pass(p) { } }; @@ -57,15 +58,14 @@ class IdentifyInterface : public LDAPInterface if (Config->NSAddAccessOnReg) na->nc->AddAccess(create_mask(u)); - u->SendMessage(nickserv->Bot(), _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); + BotInfo *bi = findbot(Config->NickServ); + if (bi) + u->SendMessage(bi, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } enc_encrypt(ii->pass, na->nc->pass); - Anope::string params; - for (unsigned i = 0; i < ii->params.size(); ++i) - params += ii->params[i] + " "; - mod_run_cmd(c->service, u, NULL, c, c->name, params); + c->Execute(ii->source, ii->params); delete ii; } @@ -89,10 +89,7 @@ class IdentifyInterface : public LDAPInterface u->Extend("m_ldap_authentication_error"); - Anope::string params; - for (unsigned i = 0; i < ii->params.size(); ++i) - params += ii->params[i] + " "; - mod_run_cmd(c->service, u, NULL, c, c->name, params); + c->Execute(ii->source, ii->params); delete ii; } @@ -129,7 +126,9 @@ class OnIdentifyInterface : public LDAPInterface if (!email.equals_ci(u->Account()->email)) { u->Account()->email = email; - u->SendMessage(nickserv->Bot(), _("Your email has been updated to \002%s\002"), email.c_str()); + BotInfo *bi = findbot(Config->NickServ); + if (bi) + u->SendMessage(bi, _("Your email has been updated to \002%s\002"), email.c_str()); Log() << "m_ldap_authentication: Updated email address for " << u->nick << " (" << u->Account()->display << ") to " << email; } } @@ -201,9 +200,9 @@ class NSIdentifyLDAP : public Module this->disable_reason = config.ReadValue("m_ldap_authentication", "disable_reason", "", 0); } - EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) + EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) { - if (this->disable_register && !this->disable_reason.empty() && nickserv && command->service == nickserv->Bot() && command->name == "REGISTER") + if (this->disable_register && !this->disable_reason.empty() && command->name == "nickserv/register") { source.Reply(_(this->disable_reason.c_str())); return EVENT_STOP; @@ -212,11 +211,14 @@ class NSIdentifyLDAP : public Module return EVENT_CONTINUE; } - EventReturn OnCheckAuthentication(User *u, Command *c, const std::vector<Anope::string> ¶ms, const Anope::string &account, const Anope::string &password) + EventReturn OnCheckAuthentication(Command *c, CommandSource *source, const std::vector<Anope::string> ¶ms, const Anope::string &account, const Anope::string &password) { - if (u == NULL || c == NULL || !this->ldap) + + if (c == NULL || source == NULL || !this->ldap) return EVENT_CONTINUE; - else if (u->GetExt("m_ldap_authentication_authenticated")) + + User *u = source->u; + if (u->GetExt("m_ldap_authentication_authenticated")) { u->Shrink("m_ldap_authentication_authenticated"); return EVENT_ALLOW; @@ -227,7 +229,7 @@ class NSIdentifyLDAP : public Module return EVENT_CONTINUE; } - IdentifyInfo *ii = new IdentifyInfo(u, c, params, account, password); + IdentifyInfo *ii = new IdentifyInfo(u, c, *source, params, account, password); try { Anope::string full_binddn = this->username_attribute + "=" + account + "," + this->binddn; diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index 6a113a14a..895ad437c 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -8,7 +8,7 @@ class XMLRPCUser : public User dynamic_reference<NickAlias> na; public: - XMLRPCUser(const Anope::string &nnick) : User(nnick, Config->ServiceUser, Config->ServiceHost, ""), na(findnick(nick)) + XMLRPCUser(const Anope::string &nnick) : User(nnick, Config->NSEnforcerUser, Config->NSEnforcerHost, ""), na(findnick(nick)) { this->realname = "XMLRPC User"; this->server = Me; @@ -87,7 +87,7 @@ class MyXMLRPCEvent : public XMLRPCEvent else request->reply("online", "yes"); - mod_run_cmd(bi, u, NULL, command); + bi->OnMessage(u, command); if (created && u) { @@ -131,14 +131,6 @@ class MyXMLRPCEvent : public XMLRPCEvent void DoStats(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request) { - if (SGLine) - request->reply("sglinecount", stringify(SGLine->GetCount())); - if (SQLine) - request->reply("sqlinecount", stringify(SQLine->GetCount())); - if (SNLine) - request->reply("snlinecount", stringify(SNLine->GetCount())); - if (SZLine) - request->reply("szlinecount", stringify(SZLine->GetCount())); request->reply("uptime", stringify(Anope::CurTime - start_time)); request->reply("uplinkname", Me->GetLinks().front()->GetName()); { diff --git a/modules/extra/ns_maxemail.cpp b/modules/extra/ns_maxemail.cpp index 25feffd79..18be74bce 100644 --- a/modules/extra/ns_maxemail.cpp +++ b/modules/extra/ns_maxemail.cpp @@ -71,24 +71,17 @@ class NSMaxEmail : public Module Log(LOG_DEBUG) << "[ns_maxemail] NSEmailMax set to " << NSEmailMax; } - EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) + EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) { - BotInfo *service = source.owner; - if (service->nick == Config->s_NickServ) + if (command->name == "nickserv/register") { - if (command->name.equals_ci("REGISTER")) - { - if (this->CheckLimitReached(source, params.size() > 1 ? params[1] : "")) - return EVENT_STOP; - } - else if (command->name.equals_ci("SET")) - { - Anope::string set = params[0]; - Anope::string email = params.size() > 1 ? params[1] : ""; - - if (set.equals_ci("email") && this->CheckLimitReached(source, email)) - return EVENT_STOP; - } + if (this->CheckLimitReached(source, params.size() > 1 ? params[1] : "")) + return EVENT_STOP; + } + else if (command->name == "nickserv/set/email") + { + if (this->CheckLimitReached(source, params.size() > 0 ? params[0] : "")) + return EVENT_STOP; } return EVENT_CONTINUE; diff --git a/modules/extra/ns_set_misc.cpp b/modules/extra/ns_set_misc.cpp index b70a871de..12fcf66c9 100644 --- a/modules/extra/ns_set_misc.cpp +++ b/modules/extra/ns_set_misc.cpp @@ -12,54 +12,54 @@ /*************************************************************************/ #include "module.h" -#include "nickserv.h" class CommandNSSetMisc : public Command { - private: - Anope::string Desc; - public: - CommandNSSetMisc(const Anope::string &cname, const Anope::string &cdesc, const Anope::string &cpermission = "") : Command(cname, 1, 2, cpermission), Desc(cdesc) + CommandNSSetMisc(Module *creator, const Anope::string &cname, const Anope::string &cdesc, const Anope::string &cpermission = "", size_t min = 1) : Command(owner, "nickserv/set/" + cname, min, min + 1, cpermission) { this->SetDesc(cdesc); + this->SetSyntax(_("\037parameter\037")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - NickAlias *na = findnick(params[0]); + NickAlias *na = findnick(user); if (!na) - throw CoreException("NULL na in CommandNSSetMisc"); + { + source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); + return; + } NickCore *nc = na->nc; nc->Shrink("nickserv:" + this->name); - if (params.size() > 1) + if (!param.empty()) { - nc->Extend("nickserv:" + this->name, new ExtensibleItemRegular<Anope::string>(params[1])); - source.Reply(_(CHAN_SETTING_CHANGED), this->name.c_str(), nc->display.c_str(), params[1].c_str()); + nc->Extend("nickserv:" + this->name, new ExtensibleItemRegular<Anope::string>(param)); + source.Reply(CHAN_SETTING_CHANGED, this->name.c_str(), nc->display.c_str(), param.c_str()); } else - source.Reply(_(CHAN_SETTING_UNSET), this->name.c_str(), nc->display.c_str()); + source.Reply(CHAN_SETTING_UNSET, this->name.c_str(), nc->display.c_str()); - return MOD_CONT; + return; } - void OnSyntaxError(CommandSource &source, const Anope::string &) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - SyntaxError(source, "SET", _(NICK_SET_SYNTAX)); + this->Run(source, source.u->Account()->display, params[0]); } }; class CommandNSSASetMisc : public CommandNSSetMisc { public: - CommandNSSASetMisc(const Anope::string &cname, const Anope::string &cdesc) : CommandNSSetMisc(cname, cdesc, "nickserv/saset/" + cname) + CommandNSSASetMisc(Module *creator, const Anope::string &cname, const Anope::string &cdesc) : CommandNSSetMisc(creator, "nickserv/saset/" + cname, cdesc, "nickserv/saset/" + cname, 2) { } - void OnSyntaxError(CommandSource &source, const Anope::string &) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - SyntaxError(source, "SASET", _(NICK_SASET_SYNTAX)); + this->Run(source, params[0], params[1]); } }; @@ -78,37 +78,8 @@ class NSSetMisc : public Module void RemoveAll() { - if (!nickserv || Commands.empty()) - return; - - Command *set = FindCommand(nickserv->Bot(), "SET"); - Command *saset = FindCommand(nickserv->Bot(), "SASET"); - - if (!set && !saset) - return; - for (std::map<Anope::string, CommandInfo *>::const_iterator it = this->Commands.begin(), it_end = this->Commands.end(); it != it_end; ++it) - { - if (set) - { - Command *c = set->FindSubcommand(it->second->Name); - if (c) - { - set->DelSubcommand(c); - delete c; - } - } - if (saset) - { - Command *c = saset->FindSubcommand(it->second->Name); - if (c) - { - saset->DelSubcommand(c); - delete c; - } - } - } - + delete it->second; this->Commands.clear(); } @@ -117,9 +88,6 @@ class NSSetMisc : public Module { this->SetAuthor("Anope"); - if (!nickserv) - throw ModuleException("NickServ is not loaded!"); - Implementation i[] = { I_OnReload, I_OnNickInfo, I_OnDatabaseWriteMetadata, I_OnDatabaseReadMetadata }; ModuleManager::Attach(i, this, 4); @@ -135,11 +103,6 @@ class NSSetMisc : public Module { RemoveAll(); - Command *set = FindCommand(nickserv->Bot(), "SET"); - Command *saset = FindCommand(nickserv->Bot(), "SASET"); - if (!set && !saset) - return; - ConfigReader config; for (int i = 0, num = config.Enumerate("ns_set_misc"); i < num; ++i) @@ -158,10 +121,8 @@ class NSSetMisc : public Module continue; } - if (set) - set->AddSubcommand(this, new CommandNSSetMisc(cname, desc)); - if (saset) - saset->AddSubcommand(this, new CommandNSSASetMisc(cname, desc)); + ModuleManager::RegisterService(new CommandNSSetMisc(this, cname, desc)); + ModuleManager::RegisterService(new CommandNSSASetMisc(this, cname, desc)); } } diff --git a/modules/extra/os_defcon.cpp b/modules/extra/os_defcon.cpp index b7e523312..cad01e8a4 100644 --- a/modules/extra/os_defcon.cpp +++ b/modules/extra/os_defcon.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "operserv.h" #include "global.h" #include "os_session.h" @@ -30,7 +29,6 @@ enum DefconLevel DEFCON_NO_NEW_MEMOS }; -static Module *me = NULL; bool DefConModesSet = false; struct DefconConfig @@ -118,18 +116,17 @@ class DefConTimeout : public CallBack { DConfig.defaultlevel = level; FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(level)); - Log(operserv->Bot(), "operserv/defcon") << "Defcon level timeout, returning to level " << level; - ircdproto->SendGlobops(operserv->Bot(), translate(_("\002%s\002 Changed the DEFCON level to \002%d\002")), Config->s_OperServ.c_str(), level); + Log(findbot(Config->OperServ), "operserv/defcon") << "Defcon level timeout, returning to level " << level; if (DConfig.globalondefcon) { if (!DConfig.offmessage.empty()) - global->SendGlobal(global->Bot(), "", DConfig.offmessage); + global->SendGlobal(findbot(Config->Global), "", DConfig.offmessage); else - global->SendGlobal(global->Bot(), "", Anope::printf(translate(_("The Defcon Level is now at Level: \002%d\002")), DConfig.defaultlevel)); + global->SendGlobal(findbot(Config->Global), "", Anope::printf(translate(_("The Defcon Level is now at Level: \002%d\002")), DConfig.defaultlevel)); if (!DConfig.message.empty()) - global->SendGlobal(global->Bot(), "", DConfig.message); + global->SendGlobal(findbot(Config->Global), "", DConfig.message); } runDefCon(); @@ -165,12 +162,13 @@ class CommandOSDefcon : public Command } public: - CommandOSDefcon() : Command("DEFCON", 1, 1, "operserv/defcon") + CommandOSDefcon(Module *creator) : Command(creator, "operserv/defcon", 1, 1, "operserv/defcon") { this->SetDesc(_("Manipulate the DefCon system")); + this->SetSyntax(_("[\0021\002|\0022\002|\0023\002|\0024\002|\0025\002]")); } - CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.u; const Anope::string &lvl = params[0]; @@ -179,7 +177,7 @@ class CommandOSDefcon : public Command { source.Reply(_("Services are now at DEFCON \002%d\002"), DConfig.defaultlevel); this->SendLevels(source); - return MOD_CONT; + return; } int newLevel = 0; @@ -192,7 +190,7 @@ class CommandOSDefcon : public Command if (newLevel < 1 || newLevel > 5) { this->OnSyntaxError(source, ""); - return MOD_CONT; + return; } DConfig.defaultlevel = newLevel; @@ -206,49 +204,46 @@ class CommandOSDefcon : public Command } if (DConfig.timeout) - timeout = new DefConTimeout(me, 5); + timeout = new DefConTimeout(this->module, 5); source.Reply(_("Services are now at DEFCON \002%d\002"), DConfig.defaultlevel); this->SendLevels(source); Log(LOG_ADMIN, u, this) << "to change defcon level to " << newLevel; - ircdproto->SendGlobops(operserv->Bot(), _("\002%s\002 Changed the DEFCON level to \002%d\002"), u->nick.c_str(), newLevel); + /* Global notice the user what is happening. Also any Message that the Admin would like to add. Set in config file. */ if (DConfig.globalondefcon) { if (DConfig.defaultlevel == 5 && !DConfig.offmessage.empty()) - global->SendGlobal(global->Bot(), "", DConfig.offmessage); + global->SendGlobal(findbot(Config->Global), "", DConfig.offmessage); else if (DConfig.defaultlevel != 5) { - global->SendGlobal(global->Bot(), "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel)); + global->SendGlobal(findbot(Config->Global), "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel)); if (!DConfig.message.empty()) - global->SendGlobal(global->Bot(), "", DConfig.message); + global->SendGlobal(findbot(Config->Global), "", DConfig.message); } } /* Run any defcon functions, e.g. FORCE CHAN MODE */ runDefCon(); - return MOD_CONT; + return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) { - source.Reply(_("Syntax: \002DEFCON\002 [\0021\002|\0022\002|\0023\002|\0024\002|\0025\002]\n" - "The defcon system can be used to implement a pre-defined\n" + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("The defcon system can be used to implement a pre-defined\n" "set of restrictions to services useful during an attempted\n" "attack on the network.")); return true; } - - void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) - { - SyntaxError(source, "DEFCON", _("DEFCON [\0021\002|\0022\002|\0023\002|\0024\002|\0025\002]")); - } }; class OSDefcon : public Module { service_reference<SessionService> session_service; + service_reference<XLineManager> akills; CommandOSDefcon commandosdefcon; void ParseModeString() @@ -339,22 +334,17 @@ class OSDefcon : public Module } public: - OSDefcon(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), session_service("session") + OSDefcon(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), session_service("session"), akills("xlinemanager/sgline"), commandosdefcon(this) { if (!DConfig.defaultlevel) throw ModuleException("Invalid configuration settings"); - me = this; - this->SetAuthor("Anope"); - Implementation i[] = { I_OnReload, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommandRun, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelCreate }; - ModuleManager::Attach(i, this, 9); - - if (!operserv) - throw ModuleException("OperServ is not loaded!"); + Implementation i[] = { I_OnReload, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelCreate }; + ModuleManager::Attach(i, this, 8); - this->AddCommand(operserv->Bot(), &commandosdefcon); + ModuleManager::RegisterService(&commandosdefcon); this->OnReload(); } @@ -378,9 +368,9 @@ class OSDefcon : public Module dconfig.offmessage = config.ReadValue("defcon", "offmessage", 0); if (dconfig.defaultlevel < 1 || dconfig.defaultlevel > 5) - throw ConfigException("The value for <os_defcon:defaultlevel> must be between 1 and 5"); + throw ConfigException("The value for <defcon:defaultlevel> must be between 1 and 5"); else if (dconfig.akillexpire <= 0) - throw ConfigException("The value for <os_defcon:akillexpire> must be greater than zero!"); + throw ConfigException("The value for <defcon:akillexpire> must be greater than zero!"); for (unsigned level = 1; level < 5; ++level) { @@ -411,11 +401,11 @@ class OSDefcon : public Module } if (dconfig.Check(level, DEFCON_REDUCE_SESSION) && dconfig.sessionlimit <= 0) - throw ConfigException("The value for <os_defcon:sessionlimit> must be greater than zero!"); + throw ConfigException("The value for <defcon:sessionlimit> must be greater than zero!"); else if (dconfig.Check(level, DEFCON_AKILL_NEW_CLIENTS) && dconfig.akillreason.empty()) - throw ConfigException("The value for <os_defcon:akillreason> must not be empty!"); + throw ConfigException("The value for <defcon:akillreason> must not be empty!"); else if (dconfig.Check(level, DEFCON_FORCE_CHAN_MODES) && dconfig.chanmodes.empty()) - throw ConfigException("The value for <os_defcon:chanmodes> must not be empty!"); + throw ConfigException("The value for <defcon:chanmodes> must not be empty!"); } DConfig = dconfig; @@ -426,16 +416,16 @@ class OSDefcon : public Module { if (!exempt && u->server->IsSynced() && DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && !u->server->IsULined()) { - if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) + if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills) { - Log(operserv->Bot(), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; - XLine *x = SGLine->Add("*@" + u->host, Config->s_OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason); + Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; + XLine *x = akills->Add("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason); if (x) - x->By = Config->s_OperServ; + x->By = Config->OperServ; } if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) - u->Kill(Config->s_OperServ, DConfig.akillreason); + u->Kill(Config->OperServ, DConfig.akillreason); return EVENT_STOP; } @@ -449,7 +439,7 @@ class OSDefcon : public Module if (DConfig.Check(DEFCON_FORCE_CHAN_MODES) && cm && DConfig.DefConModesOff.HasFlag(Name)) { - c->RemoveMode(operserv->Bot(), Name, param); + c->RemoveMode(findbot(Config->OperServ), Name, param); return EVENT_STOP; } @@ -466,9 +456,9 @@ class OSDefcon : public Module Anope::string param; if (DConfig.GetDefConParam(Name, param)) - c->SetMode(operserv->Bot(), Name, param); + c->SetMode(findbot(Config->OperServ), Name, param); else - c->SetMode(operserv->Bot(), Name); + c->SetMode(findbot(Config->OperServ), Name); return EVENT_STOP; @@ -477,61 +467,38 @@ class OSDefcon : public Module return EVENT_CONTINUE; } - EventReturn OnPreCommandRun(User *&u, BotInfo *&bi, Anope::string &command, Anope::string &message, ChannelInfo *&ci) + EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) { - if (!u->HasMode(UMODE_OPER) && (DConfig.Check(DEFCON_OPER_ONLY) || DConfig.Check(DEFCON_SILENT_OPER_ONLY))) + if (command->name == "nickserv/register" || command->name == "nickserv/group") { - if (!DConfig.Check(DEFCON_SILENT_OPER_ONLY)) - u->SendMessage(bi, _("Services are in Defcon mode, Please try again later.")); - - return EVENT_STOP; - } - - return EVENT_CONTINUE; - } - - EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) - { - BotInfo *service = command->service; - if (service->nick == Config->s_NickServ) - { - if (command->name.equals_ci("REGISTER") || command->name.equals_ci("GROUP")) + if (DConfig.Check(DEFCON_NO_NEW_NICKS)) { - if (DConfig.Check(DEFCON_NO_NEW_NICKS)) - { - source.Reply(_("Services are in Defcon mode, Please try again later.")); - return EVENT_STOP; - } + source.Reply(_("Services are in Defcon mode, Please try again later.")); + return EVENT_STOP; } } - else if (service->nick == Config->s_ChanServ) + else if (command->name == "chanserv/set/mlock") { - if (command->name.equals_ci("SET")) + if (DConfig.Check(DEFCON_NO_MLOCK_CHANGE)) { - if (!params.empty() && params[0].equals_ci("MLOCK") && DConfig.Check(DEFCON_NO_MLOCK_CHANGE)) - { - source.Reply(_("Services are in Defcon mode, Please try again later.")); - return EVENT_STOP; - } + source.Reply(_("Services are in Defcon mode, Please try again later.")); + return EVENT_STOP; } - else if (command->name.equals_ci("REGISTER")) + } + else if (command->name == "chanserv/register") + { + if (DConfig.Check(DEFCON_NO_NEW_CHANNELS)) { - if (DConfig.Check(DEFCON_NO_NEW_CHANNELS)) - { - source.Reply(_("Services are in Defcon mode, Please try again later.")); - return EVENT_STOP; - } + source.Reply(_("Services are in Defcon mode, Please try again later.")); + return EVENT_STOP; } } - else if (service->nick == Config->s_MemoServ) + else if (command->name == "memoserv/send") { - if (command->name.equals_ci("SEND") || command->name.equals_ci("SENDALL")) + if (DConfig.Check(DEFCON_NO_NEW_MEMOS)) { - if (DConfig.Check(DEFCON_NO_NEW_MEMOS)) - { - source.Reply(_("Services are in Defcon mode, Please try again later.")); - return EVENT_STOP; - } + source.Reply(_("Services are in Defcon mode, Please try again later.")); + return EVENT_STOP; } } @@ -543,37 +510,33 @@ class OSDefcon : public Module if (exempt || !u || !u->server->IsSynced() || u->server->IsULined()) return; - if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) + if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills) { - if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) - { - Log(operserv->Bot(), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; - XLine *x = SGLine->Add("*@" + u->host, Config->s_OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason); - if (x) - x->By = Config->s_OperServ; - } - - if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) - { - u->Kill(Config->s_OperServ, DConfig.akillreason); - return; - } + Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; + XLine *x = akills->Add("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason); + if (x) + x->By = Config->OperServ; + } + if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) + { + u->Kill(Config->OperServ, DConfig.akillreason); + return; } if (!DConfig.sessionlimit) return; - if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) + if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills) { - Log(operserv->Bot(), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; - XLine *x = SGLine->Add("*@" + u->host, Config->s_OperServ, Anope::CurTime + DConfig.akillexpire, !DConfig.akillreason.empty() ? DConfig.akillreason : "DEFCON AKILL"); + Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; + XLine *x = akills->Add("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, !DConfig.akillreason.empty() ? DConfig.akillreason : "DEFCON AKILL"); if (x) - x->By = Config->s_OperServ; + x->By = Config->OperServ; } if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) { - u->Kill(Config->s_OperServ, DConfig.akillreason); + u->Kill(Config->OperServ, DConfig.akillreason); return; } @@ -585,16 +548,16 @@ class OSDefcon : public Module if (session && session->count > DConfig.sessionlimit) { if (!Config->SessionLimitExceeded.empty()) - ircdproto->SendMessage(operserv->Bot(), u->nick, Config->SessionLimitExceeded.c_str(), u->host.c_str()); + ircdproto->SendMessage(findbot(Config->OperServ), u->nick, Config->SessionLimitExceeded.c_str(), u->host.c_str()); if (!Config->SessionLimitDetailsLoc.empty()) - ircdproto->SendMessage(operserv->Bot(), u->nick, "%s", Config->SessionLimitDetailsLoc.c_str()); + ircdproto->SendMessage(findbot(Config->OperServ), u->nick, "%s", Config->SessionLimitDetailsLoc.c_str()); - u->Kill(Config->s_OperServ, "Defcon session limit exceeded"); + u->Kill(Config->OperServ, "Defcon session limit exceeded"); ++session->hits; - if (Config->MaxSessionKill && session->hits >= Config->MaxSessionKill) + if (akills && Config->MaxSessionKill && session->hits >= Config->MaxSessionKill) { - SGLine->Add("*@" + u->host, Config->s_OperServ, Anope::CurTime + Config->SessionAutoKillExpiry, "Defcon session limit exceeded"); - ircdproto->SendGlobops(operserv->Bot(), "[DEFCON] Added a temporary AKILL for \2*@%s\2 due to excessive connections", u->host.c_str()); + akills->Add("*@" + u->host, Config->OperServ, Anope::CurTime + Config->SessionAutoKillExpiry, "Defcon session limit exceeded"); + ircdproto->SendGlobops(findbot(Config->OperServ), "[DEFCON] Added a temporary AKILL for \2*@%s\2 due to excessive connections", u->host.c_str()); } } } @@ -609,7 +572,7 @@ class OSDefcon : public Module void OnChannelCreate(Channel *c) { if (DConfig.Check(DEFCON_FORCE_CHAN_MODES)) - c->SetModes(operserv->Bot(), false, "%s", DConfig.chanmodes.c_str()); + c->SetModes(findbot(Config->OperServ), false, "%s", DConfig.chanmodes.c_str()); } }; @@ -648,10 +611,10 @@ void runDefCon() { if (DConfig.chanmodes[0] == '+' || DConfig.chanmodes[0] == '-') { - Log(operserv->Bot(), "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels"; + Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels"; DefConModesSet = true; for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) - it->second->SetModes(operserv->Bot(), false, "%s", DConfig.chanmodes.c_str()); + it->second->SetModes(findbot(Config->OperServ), false, "%s", DConfig.chanmodes.c_str()); } } } @@ -665,9 +628,9 @@ void runDefCon() Anope::string newmodes = defconReverseModes(DConfig.chanmodes); if (!newmodes.empty()) { - Log(operserv->Bot(), "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; + Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) - it->second->SetModes(operserv->Bot(), false, "%s", newmodes.c_str()); + it->second->SetModes(findbot(Config->OperServ), false, "%s", newmodes.c_str()); } } } |
