#define AUTHOR "Jens 'DukePyrolator' Voss " #define VERSION "2.1" #include "module.h" /* access level for auto +q */ #define CA_AUTOQ 9999 int do_on_join(char *source, int ac, char **av); int do_on_identify(User *u); int is_identified(User * user, ChannelInfo * ci); int is_real_founder(User * user, ChannelInfo * ci); extern int should_mode_change(int16 status, int16 mode); int do_setmodes(User * u); int AnopeInit(int argc, char **argv) { Message *m = NULL; Command *c = NULL; m = createMessage("JOIN", do_on_join); moduleAddMessage(m, MOD_TAIL); c = createCommand("IDENTIFY", do_on_identify, NULL, -1, -1, -1, -1, -1); moduleAddCommand(NICKSERV, c, MOD_TAIL); c = createCommand("ID", do_on_identify, NULL, -1, -1, -1, -1, -1); moduleAddCommand(NICKSERV, c, MOD_TAIL); c = createCommand("UPDATE", do_on_identify, NULL, -1, -1, -1, -1, -1); moduleAddCommand(NICKSERV, c, MOD_TAIL); moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); return MOD_CONT; } int do_on_join(char *source, int ac, char **av) { User *u; Channel *c = findchan(av[0]); ChannelInfo *ci; struct u_chaninfolist *uc; if (!(ci = cs_findchan(av[0]))) return MOD_CONT; /* change it to if (!c->ci) ? */ if (!(u = finduser(source))) return MOD_CONT; if (!nick_identified(u)) return MOD_CONT; if ((get_access_level(ci, u->na)>=CA_AUTOQ) && (!is_real_founder(u,ci))) { if (!is_identified(u, ci)) { uc = scalloc(sizeof(*uc), 1); uc->next = u->founder_chans; if (u->founder_chans) u->founder_chans->prev = uc; u->founder_chans = uc; uc->chan = ci; } send_cmd(whosends(ci), "MODE %s +q %s", av[0], u->nick); chan_set_user_status(c, u, CUS_OWNER); } return MOD_CONT; } int do_on_identify(User *u) { if (!nick_identified(u)) return MOD_CONT; if (NSModeOnID) do_setmodes(u); return MOD_CONT; } int do_setmodes(User * u) { struct u_chanlist *uc; struct u_chaninfolist *uci; Channel *c; /* Walk users current channels */ for (uc = u->chans; uc; uc = uc->next) { if ((c = uc->chan)) { #if defined(IRC_UNREAL) || defined(IRC_VIAGRA) if (should_mode_change(uc->status, CUS_OWNER) && ((get_access_level(c->ci,u->na)>=CA_AUTOQ) && (!is_real_founder(u,c->ci)))) { if (!is_identified(u, c->ci)) { uci = scalloc(sizeof(*uci), 1); uci->next = u->founder_chans; if (u->founder_chans) u->founder_chans->prev = uci; u->founder_chans = uci; uci->chan = c->ci; } chan_set_user_status(c, u, CUS_OWNER); send_cmd(whosends(c->ci), "MODE %s +q %s", c->name, u->nick); } } } #endif return MOD_CONT; } int is_identified(User * user, ChannelInfo * ci) { struct u_chaninfolist *c; for (c = user->founder_chans; c; c = c->next) { if (c->chan == ci) return 1; } return 0; } int is_real_founder(User * user, ChannelInfo * ci) { if (user->isSuperAdmin) { return 1; } if (user->na && user->na->nc == ci->founder) { if ((nick_identified(user) || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) return 1; } return 0; }