+ /* Escape out any $ symbols in the user provided text (ugly, but better than crashy) */
+ SearchAndReplace(safe, "$", "\r");
+
+ ServerInstance->Logs->Log("FANTASY", DEBUG, "fantasy: compare is %s and safe is %s", compare.c_str(), safe.c_str());
+
+ while (i != Aliases.end())
+ {
+ if (i->second.ChannelCommand)
+ {
+ if (DoAlias(user, c, &(i->second), compare, safe))
+ return 0;
+ }
+
+ i++;
+ }
+
+ return 0;
+ }
+
+
+ int DoAlias(User *user, Channel *c, 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)
+ if (a->CaseSensitive)
{
if (InspIRCd::Match(compare, a->format, case_sensitive_map))
- return;
+ return 0;
}
else
{
if (InspIRCd::Match(compare, a->format))
- return;
+ return 0;
}
}
- if ((a->operonly) && (!IS_OPER(user)))
- return;
+ if ((a->OperOnly) && (!IS_OPER(user)))
+ return 0;
- if (!a->requires.empty())
+ if (!a->RequiredNick.empty())
{
- u = ServerInstance->FindNick(a->requires);
+ u = ServerInstance->FindNick(a->RequiredNick);
if (!u)
{
- user->WriteNumeric(401, ""+std::string(user->nick)+" "+a->requires+" :is currently unavailable. Please try again later.");
- return;
+ user->WriteNumeric(401, ""+std::string(user->nick)+" "+a->RequiredNick+" :is currently unavailable. Please try again later.");
+ return 1;
}
}
- if ((u != NULL) && (!a->requires.empty()) && (a->uline))
+ if ((u != NULL) && (!a->RequiredNick.empty()) && (a->ULineOnly))
{
if (!ServerInstance->ULine(u->server))
{
- 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;
+ ServerInstance->SNO->WriteToSnoMask('A', "NOTICE -- Service "+a->RequiredNick+" required by alias "+std::string(a->AliasedCommand.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
+ user->WriteNumeric(401, ""+std::string(user->nick)+" "+a->RequiredNick+" :is an imposter! Please inform an IRC operator as soon as possible.");
+ return 1;
}
}
/* Now, search and replace in a copy of the original_line, replacing $1 through $9 and $1- etc */