summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-09-06 21:28:56 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-09-06 21:28:56 +0000
commit3fc82f6c875756b1b30e08f2c3372dcf7e03ffdb (patch)
treea0fb9301ff16afa0ae165930e426a99eb604da5c /src
parent5e4b7f9c2cc78293867248f0606f8921b9c90d30 (diff)
Restructuring to m_alias, this will be used for (optional) fantasy commands.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10422 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_alias.cpp101
1 files changed, 54 insertions, 47 deletions
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 096bdb588..25c6960cc 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -124,7 +124,6 @@ class ModuleAlias : public Module
virtual int OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
{
- User *u = NULL;
std::multimap<std::string, Alias>::iterator i;
/* If theyre not registered yet, we dont want
@@ -152,66 +151,74 @@ class ModuleAlias : public Module
while (i != Aliases.end())
{
- /* Does it match the pattern? */
- if (!i->second.format.empty())
- {
- if (i->second.case_sensitive)
- {
- if (InspIRCd::Match(compare, i->second.format, case_sensitive_map))
- continue;
- }
- else
- {
- if (InspIRCd::Match(compare, i->second.format))
- continue;
- }
- }
+ DoAlias(user, &(i->second), compare, safe);
- if ((i->second.operonly) && (!IS_OPER(user)))
- return 0;
+ i++;
+ }
+
+ // If aliases have been processed, aliases took it.
+ return 1;
+ }
- if (!i->second.requires.empty())
+ void DoAlias(User *user, Alias *a, const std::string compare, const std::string safe)
+ {
+ User *u = NULL;
+ /* Does it match the pattern? */
+ if (!a->format.empty())
+ {
+ if (a->case_sensitive)
{
- u = ServerInstance->FindNick(i->second.requires);
- if (!u)
- {
- user->WriteNumeric(401, ""+std::string(user->nick)+" "+i->second.requires+" :is currently unavailable. Please try again later.");
- return 1;
- }
+ if (InspIRCd::Match(compare, a->format, case_sensitive_map))
+ return;
}
- if ((u != NULL) && (!i->second.requires.empty()) && (i->second.uline))
+ else
{
- if (!ServerInstance->ULine(u->server))
- {
- ServerInstance->SNO->WriteToSnoMask('A', "NOTICE -- Service "+i->second.requires+" required by alias "+std::string(i->second.text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
- user->WriteNumeric(401, ""+std::string(user->nick)+" "+i->second.requires+" :is an imposter! Please inform an IRC operator as soon as possible.");
- return 1;
- }
+ if (InspIRCd::Match(compare, a->format))
+ return;
}
+ }
- /* Now, search and replace in a copy of the original_line, replacing $1 through $9 and $1- etc */
-
- std::string::size_type crlf = i->second.replace_with.find('\n');
+ if ((a->operonly) && (!IS_OPER(user)))
+ return;
- if (crlf == std::string::npos)
+ if (!a->requires.empty())
+ {
+ u = ServerInstance->FindNick(a->requires);
+ if (!u)
{
- DoCommand(i->second.replace_with, user, safe);
- return 1;
+ user->WriteNumeric(401, ""+std::string(user->nick)+" "+a->requires+" :is currently unavailable. Please try again later.");
+ return;
}
- else
+ }
+ if ((u != NULL) && (!a->requires.empty()) && (a->uline))
+ {
+ if (!ServerInstance->ULine(u->server))
{
- irc::sepstream commands(i->second.replace_with, '\n');
- std::string scommand;
- while (commands.GetToken(scommand))
- {
- DoCommand(scommand, user, safe);
- }
- return 1;
+ ServerInstance->SNO->WriteToSnoMask('A', "NOTICE -- Service "+a->requires+" required by alias "+std::string(a->text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
+ user->WriteNumeric(401, ""+std::string(user->nick)+" "+a->requires+" :is an imposter! Please inform an IRC operator as soon as possible.");
+ return;
}
+ }
- i++;
+ /* Now, search and replace in a copy of the original_line, replacing $1 through $9 and $1- etc */
+
+ std::string::size_type crlf = a->replace_with.find('\n');
+
+ if (crlf == std::string::npos)
+ {
+ DoCommand(a->replace_with, user, safe);
+ return;
+ }
+ else
+ {
+ irc::sepstream commands(a->replace_with, '\n');
+ std::string scommand;
+ while (commands.GetToken(scommand))
+ {
+ DoCommand(scommand, user, safe);
+ }
+ return;
}
- return 0;
}
void DoCommand(std::string newline, User* user, const std::string &original_line)