+ User *u = NULL;
+
+ /* Does it match the pattern? */
+ if (!a->format.empty())
+ {
+ if (a->CaseSensitive)
+ {
+ if (!InspIRCd::Match(compare, a->format, rfc_case_sensitive_map))
+ return 0;
+ }
+ else
+ {
+ if (!InspIRCd::Match(compare, a->format))
+ return 0;
+ }
+ }
+
+ if ((a->OperOnly) && (!IS_OPER(user)))
+ return 0;
+
+ if (!a->RequiredNick.empty())
+ {
+ u = ServerInstance->FindNick(a->RequiredNick);
+ if (!u)
+ {
+ user->WriteNumeric(401, ""+user->nick+" "+a->RequiredNick+" :is currently unavailable. Please try again later.");
+ return 1;
+ }
+ }
+ if ((u != NULL) && (!a->RequiredNick.empty()) && (a->ULineOnly))
+ {
+ if (!ServerInstance->ULine(u->server))
+ {
+ 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, ""+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 */
+
+ std::string::size_type crlf = a->ReplaceFormat.find('\n');
+
+ if (crlf == std::string::npos)
+ {
+ DoCommand(a->ReplaceFormat, user, c, safe);
+ return 1;
+ }
+ else
+ {
+ irc::sepstream commands(a->ReplaceFormat, '\n');
+ std::string scommand;
+ while (commands.GetToken(scommand))
+ {
+ DoCommand(scommand, user, c, safe);
+ }
+ return 1;
+ }