diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-06-06 15:22:07 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-06-06 15:22:07 +0000 |
commit | a914ae91957f617af0a21bcdb024a16361ae3398 (patch) | |
tree | c2f9ebf285281c36477732e480e815821be45733 /src/modules | |
parent | 4e14ff66f1108dc8c596248ad368c20d14a79e03 (diff) |
Allow changing of command string and parameter vector within OnPreCommand, allowing for m_abbreviation and other fancy stuff.
Add basic skeleton module for it
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9840 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-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 |
16 files changed, 65 insertions, 15 deletions
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, |