static void do_why(const char *source) { const char *chan = gettok(NULL, " ", CHANMAX); const char *nick = gettok(NULL, " ", NICKMAX); ChanInfo *ci; User *u; char *ntrace=NULL; if (!chan || !nick) { notice(s_ChanServ, source, "Syntax: /%s WHY <#channel> ", s_ChanServ); notice(s_ChanServ, source, "\2/%s HELP WHY\2 for more information.", s_ChanServ); } else if (!(ci=findchaninfo(chan))) { notice(s_ChanServ, source, "The channel '%s' is not registered!", chan); } else if (!(u = finduser(nick))) { notice(s_ChanServ, source, "Nick '%s' is not online!", nick); } else if ((get_access(finduser(source), chan, NULL, 0) < 3) && !is_oper(source)) { notice(s_ChanServ, source, "You do not have access to this command for channel %s.", chan); } else { int type=0, acc=0; if (is_founder(u, chan)) { notice(s_ChanServ, source, "Nick %s has founder access to channel %s. " "Reason: Identification to channel.", nick, chan); return; } acc = get_access(u, chan, &ntrace, 1); if (!ntrace && acc) { notice(s_ChanServ, source, "Unknown WHY error. Please try again later."); return; } if (ntrace) { if (strchr(ntrace, '@')) type=1; else if (is_identified(nick, ntrace)) type=2; else type=3; } switch (acc) { case -2: case -1: notice(s_ChanServ, source, "Nick %s does not have access to channel %s. " "Reason: Banned.%s%s%s", nick, chan, ntrace ? " (Ban Entry: " : "", ntrace ? ntrace : "", ntrace ? ")" : ""); break; case 0: notice(s_ChanServ, source, "Nick %s does not have access to channel %s. " "Reason: Basic User.", nick, chan); break; case 10: case 5: case 3: notice(s_ChanServ, source, "Nick %s has %s access to channel %s. " "Reason: %s%s", nick, acc==10 ? "Super-Op" : acc==5 ? "Auto-Op" : type==1 ? "User's host matches channel's access list." : type==2 ? "Identification to nick " : type==3 ? "Recognition to nick " : "Uknown", type>1 ? ntrace : ""); break; case 14: case 15: notice(s_ChanServ, source, "Nick %s has founder access to channel %s. " "Reason: %s (%s).", nick, chan, type==2 ? "Identification to the founder's nick" : "Recognition to the founder's nick", ntrace); break; default: notice(s_ChanServ, source, "Unknown WHY error. Please try again later."); } } }