- for (unsigned int i = 0; i < Aliases.size(); i++)
+ while (i != Aliases.end())
{
- if (Aliases[i].text == c)
+ if (i->second.UserCommand)
{
- /* Does it match the pattern? */
- if (!Aliases[i].format.empty())
+ if (DoAlias(user, NULL, &(i->second), compare, safe))
{
- if (InspIRCd::Match(Aliases[i].case_sensitive, compare, Aliases[i].format))
- continue;
+ return 1;
}
+ }
- if ((Aliases[i].operonly) && (!IS_OPER(user)))
- return 0;
+ i++;
+ }
- if (!Aliases[i].requires.empty())
- {
- u = ServerInstance->FindNick(Aliases[i].requires);
- if (!u)
- {
- user->WriteNumeric(401, ""+std::string(user->nick)+" "+Aliases[i].requires+" :is currently unavailable. Please try again later.");
- return 1;
- }
- }
- if ((u != NULL) && (!Aliases[i].requires.empty()) && (Aliases[i].uline))
- {
- if (!ServerInstance->ULine(u->server))
- {
- ServerInstance->SNO->WriteToSnoMask('A', "NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
- user->WriteNumeric(401, ""+std::string(user->nick)+" "+Aliases[i].requires+" :is an imposter! Please inform an IRC operator as soon as possible.");
- return 1;
- }
- }
+ // If aliases have been processed, aliases took it.
+ return 1;
+ }
- /* Now, search and replace in a copy of the original_line, replacing $1 through $9 and $1- etc */
+ virtual int OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
+ {
+ if (target_type != TYPE_CHANNEL)
+ {
+ ServerInstance->Logs->Log("FANTASY", DEBUG, "fantasy: not a channel msg");
+ 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->CaseSensitive)
+ {
+ if (InspIRCd::Match(compare, a->format, 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, ""+std::string(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, ""+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 */