* @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,
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; }
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)
{
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"))
{
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();
--- /dev/null
+/* +------------------------------------+
+ * | 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)
}
}
- 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;
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"))
{
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);
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))
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")
{
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,
}
- 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)
* 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)
* 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)
}
}
- 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"))
{
/* $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)
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,