+ /* 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;
- if (!i->second.requires.empty())
+ /* Does it match the pattern? */
+ if (!a->format.empty())
+ {
+ if (a->CaseSensitive)
{
- 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 0;
}
- 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 0;
}
+ }
- /* Now, search and replace in a copy of the original_line, replacing $1 through $9 and $1- etc */
+ 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;
}
+ }
- i++;
+ /* Now, search and replace in a copy of the original_line, replacing $1 through $9 and $1- etc */