diff options
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; |
