summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-16 23:15:50 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-16 23:15:50 +0000
commit1eb1b8d92548b16b2b0f48f7404a5dd599fdc03c (patch)
tree813e6b044e51e71df694098161de405459cbb200 /src/modules
parentd7bc663d0ad571697f0a022f82aeb4ad3c23cc2b (diff)
Add format="" value, at request of Emeric.
See: http://www.inspircd.org/forum/index.php/topic,245.0.html git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6019 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_alias.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 7695b6f62..55241c278 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -34,11 +34,14 @@ class Alias : public classbase
bool uline;
/** Requires oper? */
bool operonly;
+ /** Format that must be matched for use */
+ std::string format;
};
class ModuleAlias : public Module
{
private:
+ /** We cant use a map, there may be multiple aliases with the same name */
std::vector<Alias> Aliases;
std::vector<std::string> pars;
@@ -57,6 +60,7 @@ class ModuleAlias : public Module
a.requires = MyConf.ReadValue("alias", "requires", i);
a.uline = MyConf.ReadFlag("alias", "uline", i);
a.operonly = MyConf.ReadFlag("alias", "operonly", i);
+ a.format = MyConf.ReadValue("alias", "format", i);
Aliases.push_back(a);
}
}
@@ -127,18 +131,30 @@ class ModuleAlias : public Module
virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
{
userrec *u = NULL;
- irc::string c = command.c_str();
+
/* If the command is valid, we dont want to know,
* and if theyre not registered yet, we dont want
* to know either
*/
if ((validated) || (user->registered != REG_ALL))
return 0;
+
+ irc::string c = command.c_str();
+ /* The parameters for the command in their original form, with the command stripped off */
+ std::string compare = original_line.substr(command.length());
+ while (*(compare.c_str()) == ' ')
+ compare.erase(compare.begin());
for (unsigned int i = 0; i < Aliases.size(); i++)
{
if (Aliases[i].text == c)
{
+ /* Does it match the pattern? */
+ if ((!Aliases[i].format.empty()) && (!ServerInstance->MatchText(compare, Aliases[i].format)))
+ {
+ continue;
+ }
+
if ((Aliases[i].operonly) && (!*user->oper))
return 0;