diff options
-rw-r--r-- | include/modules.h | 3 | ||||
-rw-r--r-- | src/modules.cpp | 2 | ||||
-rw-r--r-- | src/modules/extra/m_sqllog.cpp | 2 | ||||
-rw-r--r-- | src/modules/extra/m_sqloper.cpp | 2 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_oper_cert.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_abbreviation.cpp | 50 | ||||
-rw-r--r-- | src/modules/m_alias.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_antibear.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_antibottler.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_blockamsg.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_conn_waitpong.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_namesx.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_operlog.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_safelist.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_securelist.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_shun.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/precommand.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_uhnames.cpp | 2 |
18 files changed, 68 insertions, 17 deletions
diff --git a/include/modules.h b/include/modules.h index 585bd98d9..7ae620752 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1034,10 +1034,11 @@ class CoreExport Module : public Extensible * @param pcnt The nuimber of parameters passed to the command * @param user the user issuing the command * @param validated True if the command has passed all checks, e.g. it is recognised, has enough parameters, the user has permission to execute it, etc. + * You should only change the parameter list and command string if validated == false (e.g. before the command lookup occurs). * @param original_line The entire original line as passed to the parser from the user * @return 1 to block the command, 0 to allow */ - virtual int OnPreCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line); + virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line); /** Called after any command has been executed. * This event occurs for all registered commands, wether they are registered in the core, diff --git a/src/modules.cpp b/src/modules.cpp index 5cfbd6f93..a45ec21ec 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -132,7 +132,7 @@ int Module::OnKill(User*, User*, const std::string&) { return 0; } void Module::OnLoadModule(Module*, const std::string&) { } void Module::OnUnloadModule(Module*, const std::string&) { } void Module::OnBackgroundTimer(time_t) { } -int Module::OnPreCommand(const std::string&, const std::vector<std::string>&, User *, bool, const std::string&) { return 0; } +int Module::OnPreCommand(std::string&, std::vector<std::string>&, User *, bool, const std::string&) { return 0; } void Module::OnPostCommand(const std::string&, const std::vector<std::string>&, User *, CmdResult, const std::string&) { } bool Module::OnCheckReady(User*) { return true; } int Module::OnUserRegister(User*) { return 0; } diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp index 16746f690..fb49f828c 100644 --- a/src/modules/extra/m_sqllog.cpp +++ b/src/modules/extra/m_sqllog.cpp @@ -276,7 +276,7 @@ class ModuleSQLLog : public Module return 0; } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { if ((command == "GLINE" || command == "KLINE" || command == "ELINE" || command == "ZLINE") && validated) { diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp index f3c32b140..b84834558 100644 --- a/src/modules/extra/m_sqloper.cpp +++ b/src/modules/extra/m_sqloper.cpp @@ -111,7 +111,7 @@ public: hashtype = assign(Conf.ReadValue("sqloper", "hash", 0)); } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { if ((validated) && (command == "OPER")) { diff --git a/src/modules/extra/m_ssl_oper_cert.cpp b/src/modules/extra/m_ssl_oper_cert.cpp index c99dfa2e2..ed4ba9c00 100644 --- a/src/modules/extra/m_ssl_oper_cert.cpp +++ b/src/modules/extra/m_ssl_oper_cert.cpp @@ -112,7 +112,7 @@ class ModuleOperSSLCert : public Module return false; } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { irc::string cmd = command.c_str(); diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp new file mode 100644 index 000000000..fd6309e83 --- /dev/null +++ b/src/modules/m_abbreviation.cpp @@ -0,0 +1,50 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2008 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" +#include "wildcard.h" + +/* $ModDesc: Provides the ability to abbreviate commands. */ + +class ModuleAbbreviation : public Module +{ + + public: + + ModuleAbbreviation(InspIRCd* Me) + : Module(Me) + { + Me->Modules->Attach(I_OnPreCommand, this); + /* Must do this first */ + Me->Modules->SetPriority(this, I_OnPreCommand, PRIO_FIRST); + } + + virtual Version GetVersion() + { + return Version(1,2,0,0,VF_VENDOR,API_VERSION); + } + + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + { + /* Command is already validated, has a length of 0, or last character is not a . */ + if (validated || command.empty() || *command.rbegin() != '.') + return 0; + + /* Whack the . off the end */ + command.erase(command.end() - 1); + + ServerInstance->Logs->Log("m_abbreviation", DEBUG, "Abbreviated command: %s", command.c_str()); + } +}; + +MODULE_INIT(ModuleAbbreviation) diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 1eb78023e..762ba6e29 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -124,7 +124,7 @@ class ModuleAlias : public Module } } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { User *u = NULL; diff --git a/src/modules/m_antibear.cpp b/src/modules/m_antibear.cpp index 633b1e332..925ec2314 100644 --- a/src/modules/m_antibear.cpp +++ b/src/modules/m_antibear.cpp @@ -37,7 +37,7 @@ class ModuleAntiBear : public Module return Version(1,2,0,0,VF_VENDOR,API_VERSION); } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { if (command == "NOTICE" && !validated && parameters.size() > 1 && user->GetExt("antibear_timewait")) { diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp index bafd422da..37f5f953e 100644 --- a/src/modules/m_antibottler.cpp +++ b/src/modules/m_antibottler.cpp @@ -37,7 +37,7 @@ class ModuleAntiBottler : public Module return Version(1,2,0,1,VF_VENDOR,API_VERSION); } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { char data[MAXBUF]; strlcpy(data,original_line.c_str(),MAXBUF); diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp index 500452fc4..cf390f165 100644 --- a/src/modules/m_blockamsg.cpp +++ b/src/modules/m_blockamsg.cpp @@ -84,7 +84,7 @@ class ModuleBlockAmsg : public Module action = IBLOCK_KILLOPERS; } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { // Don't do anything with unregistered users, or remote ones. if(!user || (user->registered != REG_ALL) || !IS_LOCAL(user)) diff --git a/src/modules/m_conn_waitpong.cpp b/src/modules/m_conn_waitpong.cpp index 4fe71f162..8d631b4f0 100644 --- a/src/modules/m_conn_waitpong.cpp +++ b/src/modules/m_conn_waitpong.cpp @@ -69,7 +69,7 @@ class ModuleWaitPong : public Module return 0; } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User* user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User* user, bool validated, const std::string &original_line) { if (command == "PONG") { diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index e9b109f5c..6ad15fa1d 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -48,7 +48,7 @@ class ModuleNamesX : public Module output.append(" NAMESX"); } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { irc::string c = command.c_str(); /* We don't actually create a proper command handler class for PROTOCTL, diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp index e295d2183..9c82222c1 100644 --- a/src/modules/m_operlog.cpp +++ b/src/modules/m_operlog.cpp @@ -37,7 +37,7 @@ class ModuleOperLog : public Module } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { /* If the command doesnt appear to be valid, we dont want to mess with it. */ if (!validated) diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index e6bb24442..9bcc78806 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -69,7 +69,7 @@ class ModuleSafeList : public Module * OnPreCommand() * Intercept the LIST command. */ - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { /* If the command doesnt appear to be valid, we dont want to mess with it. */ if (!validated) diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index b86a35b7f..356a1a93e 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -54,7 +54,7 @@ class ModuleSecureList : public Module * OnPreCommand() * Intercept the LIST command. */ - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { /* If the command doesnt appear to be valid, we dont want to mess with it. */ if (!validated) diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index be77f9d77..cd777340a 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -195,7 +195,7 @@ class ModuleShun : public Module } } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line) { if((command != "PONG") && (command != "PING")) { diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp index 2fdd9a5d5..e27de1dbd 100644 --- a/src/modules/m_spanningtree/precommand.cpp +++ b/src/modules/m_spanningtree/precommand.cpp @@ -33,7 +33,7 @@ /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */ -int ModuleSpanningTree::OnPreCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line) +int ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line) { /* If the command doesnt appear to be valid, we dont want to mess with it. */ if (!validated) diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp index 3733d1b35..e2144febc 100644 --- a/src/modules/m_uhnames.cpp +++ b/src/modules/m_uhnames.cpp @@ -48,7 +48,7 @@ class ModuleUHNames : public Module output.append(" UHNAMES"); } - virtual int OnPreCommand(const std::string &command, const std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) + virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line) { irc::string c = command.c_str(); /* We don't actually create a proper command handler class for PROTOCTL, |