Example #1
0
static int do_deowner(User * u)
{
    char *av[2];
    char *chan = strtok(NULL, " ");

    Channel *c;
    ChannelInfo *ci;
    struct u_chanlist *uc;

    if (!ircd->owner) {
        return MOD_CONT;
    }

    if (!chan) {
        av[0] = sstrdup(ircd->ownerunset);
        av[1] = GET_USER(u);

        /* Sets the mode to the user on every channels he is on. */

        for (uc = u->chans; uc; uc = uc->next) {
            if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
                && is_founder(u, ci)) {
                anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
                               av[0], GET_USER(u));
                chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
            }
        }

        free(av[0]);
        return MOD_CONT;
    }

    if (!(c = findchan(chan))) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (!(ci = c->ci)) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
    } else if (ci->flags & CI_VERBOTEN) {
        notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
    } else if (!is_founder(u, ci)) {
        notice_lang(s_ChanServ, u, ACCESS_DENIED);
    } else if (!is_on_chan(c, u)) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name);
    } else {
        anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerunset,
                       GET_USER(u));

        av[0] = sstrdup(ircd->ownerunset);
        av[1] = GET_USER(u);
        chan_set_modes(s_ChanServ, c, 2, av, 1);
        free(av[0]);
    }
    return MOD_CONT;
}
Example #2
0
void common_unban2(ChannelInfo * ci, char *nick) {
   User *u;
   char *av[3], **bans;
   int count, i;

   if (!ci || !nick)
      return;
   else if (!(u = finduser(nick)))
      return;
   
   av[0] = ci->name;
   av[1] = sstrdup("-b");
   count = ci->c->bancount;
   bans = scalloc(sizeof(char *) * count, 1);
   memcpy(bans, ci->c->bans, sizeof(char *) * count);
   for (i = 0; i < count; i++) {
      if (match_usermask2(bans[i], u)) {
         anope_cmd_mode(whosends(ci), ci->name, "-b %s", bans[i]);
         av[2] = bans[i];
         do_cmode(whosends(ci), 3, av);
      }
   }
   free(bans);
   free(av[1]);
}
Example #3
0
/**
 * The /os mode command.
 * @param u The user who issued the command
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
static int do_os_mode(User * u)
{
    int ac;
    char **av;
    char *chan = strtok(NULL, " "), *modes = strtok(NULL, "");
    Channel *c;

    if (!chan || !modes) {
        syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
        return MOD_CONT;
    }

    if (!(c = findchan(chan))) {
        notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (c->bouncy_modes) {
        notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
        return MOD_CONT;
    } else if ((ircd->adminmode) && (!is_services_admin(u))
               && (c->mode & ircd->adminmode)) {
        notice_lang(s_OperServ, u, PERMISSION_DENIED);
        return MOD_CONT;
    } else {
        anope_cmd_mode(s_OperServ, chan, "%s", modes);

        ac = split_buf(modes, &av, 1);
        chan_set_modes(s_OperServ, c, ac, av, -1);
        free(av);

        if (WallOSMode)
            anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick,
                             modes, chan);
    }
    return MOD_CONT;
}
Example #4
0
int mEventJoin(int argc, char **argv)
{
    ChannelInfo *ci;
    User *u;
	NickAlias *na;
	char *data = NULL;
	if (argc != 3) {
        return MOD_CONT;
	}
	if (!(u = finduser(argv[1]))) {
		return MOD_CONT;
	}
    if (strcmp(argv[0], EVENT_STOP) == 0) {
        if (u) {
			if ((ci = cs_findchan(argv[2]))) {
				if ((data = moduleGetData(&ci->moduleData, "avoice"))) {
                    if (stricmp(data, "REG") == 0) {
						if ((na = findnick(u->nick))) {
							if (!check_access(na->u, ci, CA_AUTOVOICE) && nick_identified(u) && 
								!(na->nc->flags & NI_AUTOOP)) {
									anope_cmd_mode(whosends(ci), ci->name, "+v %s", na->nick);
									chan_set_user_status(ci->c, u, CUS_VOICE);
							}
						}
					} else if (stricmp(data, "ALL") == 0) {
						if (!check_access(u, ci, CA_AUTOVOICE)) {
							anope_cmd_mode(whosends(ci), ci->name, "+v %s", u->nick);
							chan_set_user_status(ci->c, u, CUS_VOICE);
						}
					}
					free(data);
				}
			}
		}
    }
    return MOD_CONT;
}
Example #5
0
int AnopeInit( int argc, char **argv )
{
    moduleAddAuthor(AUTHOR);
    moduleAddVersion(VERSION);
    
    if( !LogChannel )
    {
      alog( "[bs_logchanmon] No LogChannel was found. Unloading module." );
      return MOD_STOP;
    }

    anope_cmd_nick( BotNick, "Service to protect the service log channel.", "+BSo" );
    anope_cmd_join( BotNick, LogChannel, time( NULL ) );
    anope_cmd_mode( BotNick, LogChannel, "+o %s", BotNick );
    return MOD_CONT;
}
Example #6
0
static void addBan(Channel * c, time_t timeout, char *banmask)
{
    char *av[3];
    char *cb[2];

    cb[0] = c->name;
    cb[1] = banmask;

    av[0] = sstrdup("+b");
    av[1] = banmask;

    anope_cmd_mode(whosends(c->ci), c->name, "+b %s", av[1]);
    chan_set_modes(s_ChanServ, c, 2, av, 1);

    free(av[0]);
    moduleAddCallback("tban", time(NULL) + timeout, delBan, 2, cb);
}
Example #7
0
static int delBan(int argc, char **argv)
{
    char *av[3];
    Channel *c;

    av[0] = sstrdup("-b");
    av[1] = argv[1];

    if ((c = findchan(argv[0])) && c->ci) {
        anope_cmd_mode(whosends(c->ci), c->name, "-b %s", av[1]);
        chan_set_modes(s_ChanServ, c, 2, av, 1);
    }

    free(av[0]);

    return MOD_CONT;
}
Example #8
0
void do_enforce_restricted(Channel * c)
{
    struct c_userlist *user;
    struct c_userlist *next;
    ChannelInfo *ci;
    int16 old_nojoin_level;
    char mask[BUFSIZE];
    char *reason;
    char *av[3];
    User *u;

    if (!(ci = c->ci))
        return;

    if (debug)
        alog("debug: cs_enforce: Enforcing RESTRICTED on %s", c->name);

    old_nojoin_level = ci->levels[CA_NOJOIN];
    if (ci->levels[CA_NOJOIN] < 0)
        ci->levels[CA_NOJOIN] = 0;

    user = c->users;
    do {
        next = user->next;
        u = user->user;
        if (check_access(u, c->ci, CA_NOJOIN)) {
            get_idealban(ci, u, mask, sizeof(mask));
            reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN);
            anope_cmd_mode(whosends(ci), ci->name, "+b %s %lu", mask,
                           time(NULL));
            anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s", reason);
            av[0] = ci->name;
            av[1] = u->nick;
            av[2] = reason;
            do_kick(s_ChanServ, 3, av);
        }
        user = next;
    } while (user);

    ci->levels[CA_NOJOIN] = old_nojoin_level;
}
Example #9
0
/**
 * The /os oline command.
 * @param u The user who issued the command
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
int do_operoline(User * u)
{
    char *nick = strtok(NULL, " ");
    char *flags = strtok(NULL, "");
    User *u2 = NULL;

    /* Only allow this if SuperAdmin is enabled */
    if (!u->isSuperAdmin) {
        notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
        return MOD_CONT;
    }

    if (!nick || !flags) {
        syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
        return MOD_CONT;
    } else {
        /* let's check whether the user is online */
        if (!(u2 = finduser(nick))) {
            notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
        } else if (u2 && flags[0] == '+') {
            anope_cmd_svso(s_OperServ, nick, flags);
            anope_cmd_mode(s_OperServ, nick, "+o");
            common_svsmode(u2, "+o", NULL);
            notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP);
            notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
            anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
                             u->nick, nick);
        } else if (u2 && flags[0] == '-') {
            anope_cmd_svso(s_OperServ, nick, flags);
            notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
            anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
                             u->nick, nick);
        } else
            syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
    }
    return MOD_CONT;
}
Example #10
0
void do_enforce_cmode_R(Channel * c)
{
    struct c_userlist *user;
    struct c_userlist *next;
    ChannelInfo *ci;
    char mask[BUFSIZE];
    char *reason;
    char *av[3];
    User *u;
    CBMode *cbm;

    if (!(ci = c->ci))
        return;

    if (debug)
        alog("debug: cs_enforce: Enforcing mode +R on %s", c->name);

    user = c->users;
    do {
        next = user->next;
        u = user->user;
        if (!nick_identified(u)) {
            get_idealban(ci, u, mask, sizeof(mask));
            reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN);
            if (((cbm = &cbmodes['R'])->flag == 0)
                || !(c->mode & cbm->flag))
                anope_cmd_mode(whosends(ci), ci->name, "+b %s %lu", mask,
                               time(NULL));
            anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s", reason);
            av[0] = ci->name;
            av[1] = u->nick;
            av[2] = reason;
            do_kick(s_ChanServ, 3, av);
        }
        user = next;
    } while (user);
}
Example #11
0
/**
 * The /cs clear command.
 * @param u The user who issued the command
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
int do_clear(User * u)
{
    char *chan = strtok(NULL, " ");
    char *what = strtok(NULL, " ");
    char tmp[BUFSIZE];
    Channel *c;
    ChannelInfo *ci;

    if (!what) {
        syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX);
    } else if (!(c = findchan(chan))) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (!(ci = c->ci)) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
    } else if (ci->flags & CI_VERBOTEN) {
        notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
    } else if (!u || !check_access(u, ci, CA_CLEAR)) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else if (stricmp(what, "bans") == 0) {
        char *av[2];
        int i;

        /* Save original ban info */
        int count = c->bancount;
        char **bans = scalloc(sizeof(char *) * count, 1);
        for (i = 0; i < count; i++)
            bans[i] = sstrdup(c->bans[i]);

        for (i = 0; i < count; i++) {
            av[0] = sstrdup("-b");
            av[1] = bans[i];
            anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
            chan_set_modes(whosends(ci), c, 2, av, 0);
            free(av[1]);
            free(av[0]);
        }
        notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan);
        free(bans);
    } else if (ircd->except && stricmp(what, "excepts") == 0) {
        char *av[2];
        int i;

        /* Save original except info */
        int count = c->exceptcount;
        char **excepts = scalloc(sizeof(char *) * count, 1);
        for (i = 0; i < count; i++)
            excepts[i] = sstrdup(c->excepts[i]);

        for (i = 0; i < count; i++) {
            av[0] = sstrdup("-e");
            av[1] = excepts[i];
            anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
            chan_set_modes(whosends(ci), c, 2, av, 0);
            free(av[1]);
            free(av[0]);
        }
        notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan);
        free(excepts);

    } else if (ircd->invitemode && stricmp(what, "invites") == 0) {
        char *av[2];
        int i;

        /* Save original except info */
        int count = c->invitecount;
        char **invites = scalloc(sizeof(char *) * count, 1);
        for (i = 0; i < count; i++)
            invites[i] = sstrdup(c->invite[i]);

        for (i = 0; i < count; i++) {
            av[0] = sstrdup("-I");
            av[1] = invites[i];
            anope_cmd_mode(whosends(ci), chan, "%s %s", av[0], av[1]);
            chan_set_modes(whosends(ci), c, 2, av, 0);
            free(av[1]);
            free(av[0]);
        }
        notice_lang(s_ChanServ, u, CHAN_CLEARED_INVITES, chan);
        free(invites);

    } else if (stricmp(what, "modes") == 0) {
        char buf[BUFSIZE], *end = buf;
        char *argv[2];

        if (c->mode) {
            /* Clear modes the bulk of the modes */
            anope_cmd_mode(whosends(ci), c->name, "%s",
                           ircd->modestoremove);
            argv[0] = sstrdup(ircd->modestoremove);
            chan_set_modes(whosends(ci), c, 1, argv, 0);
            free(argv[0]);

            /* to prevent the internals from complaining send -k, -L, -f by themselves if we need
               to send them - TSL */
            if (c->key) {
                anope_cmd_mode(whosends(ci), c->name, "-k %s", c->key);
                argv[0] = sstrdup("-k");
                argv[1] = c->key;
                chan_set_modes(whosends(ci), c, 2, argv, 0);
                free(argv[0]);
            }
            if (ircd->Lmode && c->redirect) {
                anope_cmd_mode(whosends(ci), c->name, "-L %s",
                               c->redirect);
                argv[0] = sstrdup("-L");
                argv[1] = c->redirect;
                chan_set_modes(whosends(ci), c, 2, argv, 0);
                free(argv[0]);
            }
            if (ircd->fmode && c->flood) {
                if (flood_mode_char_remove) {
                    anope_cmd_mode(whosends(ci), c->name, "%s %s",
                                   flood_mode_char_remove, c->flood);
                    argv[0] = sstrdup(flood_mode_char_remove);
                    argv[1] = c->flood;
                    chan_set_modes(whosends(ci), c, 2, argv, 0);
                    free(argv[0]);
                } else {
                    if (debug) {
                        alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes");
                    }
                }
            }
            check_modes(c);
        }



        /* TODO: decide if the above implementation is better than this one. */

        if (0) {
            CBModeInfo *cbmi = cbmodeinfos;
            CBMode *cbm;

            do {
                if (c->mode & cbmi->flag)
                    *end++ = cbmi->mode;
            } while ((++cbmi)->flag != 0);

            cbmi = cbmodeinfos;

            do {
                if (cbmi->getvalue && (c->mode & cbmi->flag)
                    && !(cbmi->flags & CBM_MINUS_NO_ARG)) {
                    char *value = cbmi->getvalue(c);

                    if (value) {
                        *end++ = ' ';
                        while (*value)
                            *end++ = *value++;

                        /* Free the value */
                        cbm = &cbmodes[(int) cbmi->mode];
                        cbm->setvalue(c, NULL);
                    }
                }
            } while ((++cbmi)->flag != 0);

            *end = 0;

            anope_cmd_mode(whosends(ci), c->name, "-%s", buf);
            c->mode = 0;
            check_modes(c);
        }
        notice_lang(s_ChanServ, u, CHAN_CLEARED_MODES, chan);
    } else if (stricmp(what, "ops") == 0) {
        char *av[3];
        struct c_userlist *cu, *next;

        if (ircd->svsmode_ucmode) {
            av[0] = sstrdup(chan);
            anope_cmd_svsmode_chan(av[0], "-o", NULL);
            if (ircd->owner) {
                anope_cmd_svsmode_chan(av[0], ircd->ownerunset, NULL);
            }
            if (ircd->protect || ircd->admin) {
                anope_cmd_svsmode_chan(av[0], ircd->adminunset, NULL);
            }
            for (cu = c->users; cu; cu = next) {
                next = cu->next;
                av[0] = sstrdup(chan);
                if (!chan_has_user_status(c, cu->user, CUS_OP)) {
                    if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) {
                        if (!chan_has_user_status(c, cu->user, CUS_OWNER)) {
                            continue;
                        } else {
                            snprintf(tmp, BUFSIZE, "%so",
                                     ircd->ownerunset);
                            av[1] = sstrdup(tmp);

                        }
                    } else {
                        snprintf(tmp, BUFSIZE, "%so", ircd->adminunset);
                        av[1] = sstrdup(tmp);
                    }
                } else {
                    av[1] = sstrdup("-o");
                }
                av[2] = sstrdup(cu->user->nick);
                do_cmode(s_ChanServ, 3, av);
                free(av[2]);
                free(av[1]);
                free(av[0]);
            }
        } else {
            for (cu = c->users; cu; cu = next) {
                next = cu->next;
                av[0] = sstrdup(chan);
                if (!chan_has_user_status(c, cu->user, CUS_OP)) {
                    if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) {
                        if (!chan_has_user_status(c, cu->user, CUS_OWNER)) {
                            continue;
                        } else {
                            snprintf(tmp, BUFSIZE, "%so",
                                     ircd->ownerunset);
                            av[1] = sstrdup(tmp);
                        }
                    } else {
                        snprintf(tmp, BUFSIZE, "%so", ircd->adminunset);
                        av[1] = sstrdup(tmp);
                    }
                } else {
                    av[1] = sstrdup("-o");
                }
                av[2] = sstrdup(cu->user->nick);
                anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
                               av[2]);
                do_cmode(s_ChanServ, 3, av);
                free(av[2]);
                free(av[1]);
                free(av[0]);
            }
        }
        notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan);
    } else if (ircd->halfop && stricmp(what, "hops") == 0) {
        char *av[3];
        struct c_userlist *cu, *next;

        for (cu = c->users; cu; cu = next) {
            next = cu->next;
            if (!chan_has_user_status(c, cu->user, CUS_HALFOP))
                continue;
            av[0] = sstrdup(chan);
            av[1] = sstrdup("-h");
            av[2] = sstrdup(cu->user->nick);
            if (ircd->svsmode_ucmode) {
                anope_cmd_svsmode_chan(av[0], av[1], NULL);
                do_cmode(s_ChanServ, 3, av);
                break;
            } else {
                anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
                               av[2]);
            }
            do_cmode(s_ChanServ, 3, av);
            free(av[2]);
            free(av[1]);
            free(av[0]);
        }
        notice_lang(s_ChanServ, u, CHAN_CLEARED_HOPS, chan);
    } else if (stricmp(what, "voices") == 0) {
        char *av[3];
        struct c_userlist *cu, *next;

        for (cu = c->users; cu; cu = next) {
            next = cu->next;
            if (!chan_has_user_status(c, cu->user, CUS_VOICE))
                continue;
            av[0] = sstrdup(chan);
            av[1] = sstrdup("-v");
            av[2] = sstrdup(cu->user->nick);
            if (ircd->svsmode_ucmode) {
                anope_cmd_svsmode_chan(av[0], av[1], NULL);
                do_cmode(s_ChanServ, 3, av);
                break;
            } else {
                anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1],
                               av[2]);
            }
            do_cmode(s_ChanServ, 3, av);
            free(av[2]);
            free(av[1]);
            free(av[0]);
        }
        notice_lang(s_ChanServ, u, CHAN_CLEARED_VOICES, chan);
    } else if (stricmp(what, "users") == 0) {
        char *av[3];
        struct c_userlist *cu = NULL, *next = NULL;
        char buf[256];

        snprintf(buf, sizeof(buf), "CLEAR USERS command from %s", u->nick);

        for (cu = c->users; cu; cu = next) {
	
            next = cu->next;
	    
	    if ((cu->user->mode & UMODE_q))
	    {
	        continue;
            }

            av[0] = sstrdup(chan);
            av[1] = sstrdup(cu->user->nick);
            av[2] = sstrdup(buf);
            anope_cmd_kick(whosends(ci), av[0], av[1], av[2]);
            do_kick(s_ChanServ, 3, av);
            free(av[2]);
            free(av[1]);
            free(av[0]);
        }
        notice_lang(s_ChanServ, u, CHAN_CLEARED_USERS, chan);
    } else {
        syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX);
    }
    return MOD_CONT;
}
Example #12
0
static int do_util(User * u, CSModeUtil * util)
{
    char *av[2];
    char *chan = strtok(NULL, " ");
    char *nick = strtok(NULL, " ");

    Channel *c;
    ChannelInfo *ci;
    User *u2;

    int is_same;

    if (!chan) {
        struct u_chanlist *uc;

        av[0] = util->mode;
        av[1] = u->nick;

        /* Sets the mode to the user on every channels he is on. */

        for (uc = u->chans; uc; uc = uc->next) {
            if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
                && check_access(u, ci, util->levelself)) {
                anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
                               util->mode, GET_USER(u));
                chan_set_modes(s_ChanServ, uc->chan, 2, av, 2);

                if (util->notice && ci->flags & util->notice)
                    notice(whosends(ci), uc->chan->name,
                           "%s command used for %s by %s", util->name,
                           u->nick, u->nick);
            }
        }

        return MOD_CONT;
    } else if (!nick) {
        nick = u->nick;
    }

    is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0);

    if (!(c = findchan(chan))) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (!(ci = c->ci)) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
    } else if (ci->flags & CI_VERBOTEN) {
        notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
    } else if (is_same ? !(u2 = u) : !(u2 = finduser(nick))) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
    } else if (is_same ? !check_access(u, ci, util->levelself) :
               !check_access(u, ci, util->level)) {
        notice_lang(s_ChanServ, u, ACCESS_DENIED);
    } else if (*util->mode == '-' && !is_same && (ci->flags & CI_PEACE)
               && (get_access(u2, ci) >= get_access(u, ci))) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else if (*util->mode == '-' && is_protected(u2) && !is_same) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else if (!is_on_chan(c, u2)) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
    } else {
        anope_cmd_mode(whosends(ci), c->name, "%s %s", util->mode,
                       GET_USER(u2));

        av[0] = util->mode;
        av[1] = GET_USER(u2);
        chan_set_modes(s_ChanServ, c, 2, av, 3);

        if (util->notice && ci->flags & util->notice)
            notice(whosends(ci), c->name, "%s command used for %s by %s",
                   util->name, u2->nick, u->nick);
    }
    return MOD_CONT;
}
Example #13
0
int do_sync(User *u, Channel *c) {
	struct c_userlist *cu, *next;
	/* Variables needed for building the cmd to remove voices.. */
	int count = 0, newac = 0;
	char modes[BUFSIZE], nicks[BUFSIZE], buf[BUFSIZE];
	char *end1, *end2;
	char **newav = scalloc(sizeof(char *) * 13, 1);
	end1 = modes;
	end2 = nicks;
	*end1 = 0;
	*end2 = 0;
	newav[newac] = c->name;
	newac++;

	if (!c->ci) {
		free(newav);
		return MOD_CONT;
	}

	if (ircdcap->tsmode) {
		snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
		newav[newac] = buf;
		newac++;
	}

	cu = c->users;
	while (cu) {
		/* We store the next user just in case current user ends up getting kicked off the channel. */
		next = cu->next;
		do_up_down(cu->user, c, "up", 0);

		/* We have to remove voices manually because the cores function doesn't care about that
		 * as it's not covered by secureops.. */
		if (chan_has_user_status(c, cu->user, CUS_VOICE) && !check_access(cu->user, c->ci, CA_AUTOVOICE)
				&& !check_access(cu->user, c->ci, CA_VOICEME) && !check_access(cu->user, c->ci, CA_VOICE)) {
			/* Add the user to the string to remove his voice.. */
			end1 += snprintf(end1, sizeof(modes) - (end1 - modes), "-v");
			end2 += snprintf(end2, sizeof(nicks) - (end2 - nicks), "%s ", GET_USER(cu->user));
			newav[newac+1] = GET_USER(cu->user);
			newac++;
			count++;

			/* Check whether the command hasn't grown too long yet.
			 * We don't allow more then 10 mode changes per command.. this should keep us safely below the 512 max length per cmd. */
			if (count == 10) {
				/* We've reached the maximum.. send the mode changes. */
				if (ircdcap->tsmode)
					newav[2] = modes;
				else
					newav[1] = modes;
				newac++;

				anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", modes, nicks);
				do_cmode(c->ci->bi->nick, newac, newav);

				/* Reset the buffer for the next set of changes.. */
				if (ircdcap->tsmode)
					newac = 2;
				else
					newac = 1;
				*end1 = 0;
				*end2 = 0;
				count = 0;
			}
		}

		cu = next;
	}

	/* If we still have some mode changes to send, do it now.. */
	if (count > 0) {
		if (ircdcap->tsmode)
			newav[2] = modes;
		else
			newav[1] = modes;
		newac++;

		anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", modes, nicks);
		do_cmode(c->ci->bi->nick, newac, newav);
	}

	noticeLang(c->ci->bi->nick, u, LANG_SYNC_DONE, c->name);

	free(newav);
	return MOD_CONT;
}
Example #14
0
void
plexus_cmd_bot_chan_mode (char *nick, char *chan)
{
  anope_cmd_mode (nick, chan, "%s %s %s", myIrcd->botchanumode, nick, nick);
}
Example #15
0
/**
 * The /cs forbid command.
 * @param u The user who issued the command
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
static int do_forbid(User * u)
{
    Channel *c;
    ChannelInfo *ci;
    char *chan = strtok(NULL, " ");
    char *reason = strtok(NULL, "");
    Entry *cur, *enext;

    /* Assumes that permission checking has already been done. */
    if (!chan || (ForceForbidReason && !reason)) {
        syntax_error(s_ChanServ, u, "FORBID",
                     (ForceForbidReason ? CHAN_FORBID_SYNTAX_REASON :
                      CHAN_FORBID_SYNTAX));
        return MOD_CONT;
    }
    if (*chan != '#') {
        notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED);
        return MOD_CONT;
    } else if (!anope_valid_chan(chan)) {
        notice_lang(s_ChanServ, u, CHAN_X_INVALID, chan);
        return MOD_CONT;
    }
    if (readonly)
        notice_lang(s_ChanServ, u, READ_ONLY_MODE);
    if ((ci = cs_findchan(chan)) != NULL) {
        delchan(ci);
        send_event(EVENT_CHAN_DROP, 1, chan);
    }
    ci = makechan(chan);
    if (ci) {
        ci->flags |= CI_VERBOTEN;
        ci->forbidby = sstrdup(u->nick);
        if (reason)
            ci->forbidreason = sstrdup(reason);

        if ((c = findchan(ci->name))) {
            struct c_userlist *cu, *next;
            char *av[3];

            /* Before banning everyone, it might be prudent to clear +e and +I lists.. 
             * to prevent ppl from rejoining.. ~ Viper */
            if (ircd->except && c->excepts && c->excepts->count) {
                av[0] = sstrdup("-e");
                for (cur = c->excepts->entries; cur; cur = enext) {
                    enext = cur->next;
                    av[1] = sstrdup(cur->mask);
                    anope_cmd_mode(whosends(ci), chan, "-e %s", cur->mask);
                    chan_set_modes(whosends(ci), c, 2, av, 0);
                    free(av[1]);
                }
                free(av[0]);
            }
            if (ircd->invitemode && c->invites && c->invites->count) {
                av[0] = sstrdup("-I");
                for (cur = c->invites->entries; cur; cur = enext) {
                    enext = cur->next;
                    av[1] = sstrdup(cur->mask);
                    anope_cmd_mode(whosends(ci), chan, "-I %s", cur->mask);
                    chan_set_modes(whosends(ci), c, 2, av, 0);
                    free(av[1]);
                }
                free(av[0]);
            }

            for (cu = c->users; cu; cu = next) {
                next = cu->next;

                if (is_oper(cu->user))
                    continue;

                av[0] = c->name;
                av[1] = cu->user->nick;
                av[2] = reason ? reason : "CHAN_FORBID_REASON";
                anope_cmd_kick(s_ChanServ, av[0], av[1], av[2]);
                do_kick(s_ChanServ, 3, av);
            }
        }

        if (WallForbid)
            anope_cmd_global(s_ChanServ,
                             "\2%s\2 used FORBID on channel \2%s\2",
                             u->nick, ci->name);

        if (ircd->chansqline) {
            anope_cmd_sqline(ci->name, ((reason) ? reason : "Forbidden"));
        }

        alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick,
             ci->name);
        notice_lang(s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan);
        send_event(EVENT_CHAN_FORBIDDEN, 1, chan);
    } else {
        alog("%s: Valid FORBID for %s by %s failed", s_ChanServ, ci->name,
             u->nick);
        notice_lang(s_ChanServ, u, CHAN_FORBID_FAILED, chan);
    }
    return MOD_CONT;
}
Example #16
0
int do_clear(User *u, Channel *c, int type) {
/* 1= Modes
 * 2= Bans
 * 3= Excepts
 * 4= Invites
 * 5= Ops
 * 6= Hops
 * 7= Voices
 * 8= Users */

	/* Clear Channel Modes */
	if (type == 1) {
		char *argv[2];

		notice(c->ci->bi->nick, c->name, "CLEAR MODES command from %s", u->nick);

		if (c->mode) {
			/* Clear modes the bulk of the modes */
			anope_cmd_mode(c->ci->bi->nick, c->name, "%s", ircd->modestoremove);
			argv[0] = sstrdup(ircd->modestoremove);
			chan_set_modes(c->ci->bi->nick, c, 1, argv, 0);
			free(argv[0]);

			if (c->key) {
				anope_cmd_mode(c->ci->bi->nick, c->name, "-k %s", c->key);
				argv[0] = sstrdup("-k");
				argv[1] = c->key;
				chan_set_modes(c->ci->bi->nick, c, 2, argv, 0);
				free(argv[0]);
			}
			if (ircd->Lmode && c->redirect) {
				anope_cmd_mode(c->ci->bi->nick, c->name, "-L %s", c->redirect);
				argv[0] = sstrdup("-L");
				argv[1] = c->redirect;
				chan_set_modes(c->ci->bi->nick, c, 2, argv, 0);
				free(argv[0]);
			}
			if (ircd->fmode && c->flood) {
				if (flood_mode_char_remove) {
					anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", flood_mode_char_remove, c->flood);
					argv[0] = sstrdup(flood_mode_char_remove);
					argv[1] = c->flood;
					chan_set_modes(c->ci->bi->nick, c, 2, argv, 0);
					free(argv[0]);
				}
			}
			check_modes(c);
		}

	/* Clear Channel Bans */
	} else if (type == 2) {
		char *av[2];
		Entry *ban, *next;

		notice(c->ci->bi->nick, c->name, "CLEAR BANS command from %s", u->nick);
		if (c->bans && c->bans->count) {
			if (ircd->svsmode_ucmode) {
				anope_cmd_svsmode_chan(c->name, "-b", NULL);
				av[0] = "-b";
				for (ban = c->bans->entries; ban; ban = next) {
					next = ban->next;
					av[1] = ban->mask;
					chan_set_modes(c->ci->bi->nick, c, 2, av, 0);
				}
			} else {
				av[0] = "-b";
				for (ban = c->bans->entries; ban; ban = next) {
					next = ban->next;
					av[1] = ban->mask;
					anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", av[0], av[1]);
					chan_set_modes(c->ci->bi->nick, c, 2, av, 0);
				}
			}
		}

	/* Clear Channel Excepts */
	} else if (ircd->except && type == 3) {
		char *av[2];
		Entry *except, *next;

		notice(c->ci->bi->nick, c->name, "CLEAR EXCEPTS command from %s", u->nick);
		if (c->excepts && c->excepts->count) {
			if (ircd->svsmode_ucmode) {
				anope_cmd_svsmode_chan(c->name, "-e", NULL);
				av[0] = "-e";
				for (except = c->excepts->entries; except; except = next) {
					next = except->next;
					av[1] = except->mask;
					chan_set_modes(c->ci->bi->nick, c, 2, av, 0);
				}
			} else {
				av[0] = "-e";
				for (except = c->excepts->entries; except; except = next) {
					next = except->next;
					av[1] = except->mask;
					anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", av[0], av[1]);
					chan_set_modes(c->ci->bi->nick, c, 2, av, 0);
				}
			}
		}
	} else if (!(ircd->except) && type == 3) {
		noticeLang(c->ci->bi->nick, u, LANG_EXCEPTS_UNSUPPORTED);

	/* Clear Channel Invites */
	} else if (ircd->invitemode && type == 4) {
		char *av[2];
		Entry *invite, *next;

		notice(c->ci->bi->nick, c->name, "CLEAR INVITES command from %s", u->nick);
		if (c->invites && c->invites->count) {
			if (ircd->svsmode_ucmode) {
				anope_cmd_svsmode_chan(c->name, "-e", NULL);
				av[0] = "-I";
				for (invite = c->invites->entries; invite; invite = next) {
					next = invite->next;
					av[1] = invite->mask;
					chan_set_modes(c->ci->bi->nick, c, 2, av, 0);
				}
			} else {
				av[0] = "-I";
				for (invite = c->invites->entries; invite; invite = next) {
					next = invite->next;
					av[1] = invite->mask;
					anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", av[0], av[1]);
					chan_set_modes(c->ci->bi->nick, c, 2, av, 0);
				}
			}
		}
	} else if (!(ircd->invitemode) && type == 4) {
		noticeLang(c->ci->bi->nick, u, LANG_INVITEMODE_UNSUPPORTED);

	/* Clear Channel OPs */
	} else if (type == 5) {
		char *av[6];  /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */
		int ac, isop, isadmin, isown, count, i;
		char buf[BUFSIZE], tmp[BUFSIZE], tmp2[BUFSIZE];
		struct c_userlist *cu, *next;

		notice(c->ci->bi->nick, c->name, "CLEAR OPS command from %s", u->nick);

		av[0] = c->name;
		if (ircd->svsmode_ucmode) {
			anope_cmd_svsmode_chan(c->name, "-o", NULL);
			if (ircd->owner) {
				anope_cmd_svsmode_chan(c->name, ircd->ownerunset, NULL);
			}
			if (ircd->protect || ircd->admin) {
				anope_cmd_svsmode_chan(c->name, ircd->adminunset, NULL);
			}
			for (cu = c->users; cu; cu = next) {
				next = cu->next;
				isop = chan_has_user_status(c, cu->user, CUS_OP);
				isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT);
				isown = chan_has_user_status(c, cu->user, CUS_OWNER);
				count = (isop ? 1 : 0) + (isadmin ? 1 : 0) + (isown ? 1 : 0);

				if (!isop && !isadmin && !isown)
					continue;

				snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ?
						ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : ""));

				if (ircdcap->tsmode) {
					snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
					av[1] = buf;
					av[2] = tmp;
					/* We have to give as much nicks as modes.. - Viper */
					for (i = 0; i < count; i++)
						av[i+3] = cu->user->nick;
					ac = 3 + i;
				} else {
					av[1] = tmp;
					/* We have to give as much nicks as modes.. - Viper */
					for (i = 0; i < count; i++)
						av[i+2] = cu->user->nick;
					ac = 2 + i;
				}
				do_cmode(c->ci->bi->nick, ac, av);
			}
		} else {
			for (cu = c->users; cu; cu = next) {
				next = cu->next;
				isop = chan_has_user_status(c, cu->user, CUS_OP);
				isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT);
				isown = chan_has_user_status(c, cu->user, CUS_OWNER);
				count = (isop ? 1 : 0) + (isadmin ? 1 : 0) + (isown ? 1 : 0);

				if (!isop && !isadmin && !isown)
					continue;

				snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ? 
						ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : ""));
				/* We need to send the IRCd a nick for every mode.. - Viper */
				snprintf(tmp2, BUFSIZE, "%s %s %s", (isop ? cu->user->nick : ""), 
						(isadmin ? cu->user->nick : ""), (isown ? cu->user->nick : ""));

				if (ircdcap->tsmode) {
					snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
					av[1] = buf;
					av[2] = tmp;
					/* We have to give as much nicks as modes.. - Viper */
					for (i = 0; i < count; i++)
						av[i+3] = cu->user->nick;
					ac = 3 + i;
					anope_cmd_mode(c->ci->bi->nick, av[0], "%s %s", av[2], tmp2);
				} else {
					av[1] = tmp;
					/* We have to give as much nicks as modes.. - Viper */
					for (i = 0; i < count; i++)
						av[i+2] = cu->user->nick;
					ac = 2 + i;
					anope_cmd_mode(c->ci->bi->nick, av[0], "%s %s", av[1], tmp2);
				}
				do_cmode(c->ci->bi->nick, ac, av);
			}
		}

	/* Clear Channel HOPs */
	} else if (ircd->halfop && type == 6) {
		char *av[4];
		struct c_userlist *cu, *next;
		char buf[BUFSIZE];
		int ac;

		notice(c->ci->bi->nick, c->name, "CLEAR HOPS command from %s", u->nick);

		av[0] = c->name;
		if (ircdcap->tsmode)
			av[2] = sstrdup("-h");
		else
			av[1] = sstrdup("-h");

		if (ircd->svsmode_ucmode) {
			anope_cmd_svsmode_chan(c->name, "-h", NULL);

			for (cu = c->users; cu; cu = next) {
				next = cu->next;
				if (!chan_has_user_status(c, cu->user, CUS_HALFOP))
					continue;

				if (ircdcap->tsmode) {
					snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
					av[1] = buf;
					av[3] = cu->user->nick;
					ac = 4;
				} else {
					av[2] = cu->user->nick;
					ac = 3;
				}

				do_cmode(c->ci->bi->nick, ac, av);
			}
		} else {
			for (cu = c->users; cu; cu = next) {
				next = cu->next;
				if (!chan_has_user_status(c, cu->user, CUS_HALFOP))
					continue;

				if (ircdcap->tsmode) {
					snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
					av[1] = buf;
					av[3] = cu->user->nick;
					ac = 4;
				} else {
					av[2] = cu->user->nick;
					ac = 3;
				}

				anope_cmd_mode(c->ci->bi->nick, c->name, "-h %s", cu->user->nick);
				do_cmode(c->ci->bi->nick, ac, av);
			}
		}

		if (ircdcap->tsmode)
			free(av[2]);
		else
			free(av[1]);

	} else if (!(ircd->halfop) && type == 6) {
		noticeLang(c->ci->bi->nick, u, LANG_HOPS_UNSUPPORTED);

	/* Clear Channel Voices */
    } else if (type == 7) {
		char *av[4];
		struct c_userlist *cu, *next;
		char buf[BUFSIZE];
		int ac;

		notice(c->ci->bi->nick, c->name, "CLEAR VOICES command from %s", u->nick);

		av[0] = c->name;
		if (ircdcap->tsmode)
			av[2] = sstrdup("-v");
		else
			av[1] = sstrdup("-v");

		if (ircd->svsmode_ucmode) {
			anope_cmd_svsmode_chan(av[0], "-v", NULL);

			for (cu = c->users; cu; cu = next) {
				next = cu->next;
				if (!chan_has_user_status(c, cu->user, CUS_VOICE))
					continue;

				if (ircdcap->tsmode) {
					snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
					av[1] = buf;
					av[3] = cu->user->nick;
					ac = 4;
				} else {
					av[2] = cu->user->nick;
					ac = 3;
				}

				do_cmode(c->ci->bi->nick, ac, av);
			}
		} else {
			for (cu = c->users; cu; cu = next) {
				next = cu->next;
				if (!chan_has_user_status(c, cu->user, CUS_VOICE))
					continue;

				if (ircdcap->tsmode) {
					snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
					av[1] = buf;
					av[3] = cu->user->nick;
					ac = 4;
				} else {
					av[2] = cu->user->nick;
					ac = 3;
				}

				anope_cmd_mode(c->ci->bi->nick, c->name, "-v %s", cu->user->nick);
				do_cmode(c->ci->bi->nick, ac, av);
			}
		}

		if (ircdcap->tsmode)
			free(av[2]);
		else
			free(av[1]);

	/* Clear Channel Users */
	} else if (type == 8) {
		char *av[3];
		struct c_userlist *cu, *next;
		char buf[256];

		snprintf(buf, sizeof(buf), "CLEAR USERS command from %s", u->nick);
		notice(c->ci->bi->nick, c->name, buf);

		av[0] = c->name;
		av[2] = buf;
		for (cu = c->users; cu; cu = next) {
			next = cu->next;
			av[1] = cu->user->nick;
			anope_cmd_kick(c->ci->bi->nick, av[0], av[1], av[2]);
			do_kick(c->ci->bi->nick, 3, av);
		}
	}

	/* Should NEVER happen, therefor if it does, stop processing */
	else {
		alog("[bs_fantasy_ext] An error has occured while processing CLEAR !!!");
		return MOD_STOP;
	}

	return MOD_CONT;
}
Example #17
0
static int my_cs_appendtopic(User * u)
{
    char *cur_buffer;
    char *chan;
    char *newtopic;
    char topic[1024];
    Channel *c;
    ChannelInfo *ci;

    cur_buffer = moduleGetLastBuffer();
    chan = myStrGetToken(cur_buffer, ' ', 0);
    newtopic = myStrGetTokenRemainder(cur_buffer, ' ', 1);

    if (!chan || !newtopic) {
        moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX);
    } else if (!(c = findchan(chan))) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (!(ci = c->ci)) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
    } else if (ci->flags & CI_VERBOTEN) {
        notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
    } else if (!is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else {
        if (ci->last_topic) {
            snprintf(topic, sizeof(topic), "%s %s", ci->last_topic,
                     newtopic);
            free(ci->last_topic);
        } else {
            strscpy(topic, newtopic, sizeof(topic));
        }

        ci->last_topic = *topic ? sstrdup(topic) : NULL;
        strscpy(ci->last_topic_setter, u->nick, NICKMAX);
        ci->last_topic_time = time(NULL);

        if (c->topic)
            free(c->topic);
        c->topic = *topic ? sstrdup(topic) : NULL;
        strscpy(c->topic_setter, u->nick, NICKMAX);
        if (ircd->topictsbackward)
            c->topic_time = c->topic_time - 1;
        else
            c->topic_time = ci->last_topic_time;

        if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC))
            alog("%s: %s!%s@%s changed topic of %s as services admin.",
                 s_ChanServ, u->nick, u->username, u->host, c->name);
        if (ircd->join2set) {
            if (whosends(ci) == s_ChanServ) {
                anope_cmd_join(s_ChanServ, c->name, c->creation_time);
                anope_cmd_mode(NULL, c->name, "+o %s", GET_BOT(s_ChanServ));
            }
        }
        anope_cmd_topic(whosends(ci), c->name, u->nick, topic, c->topic_time);
        if (ircd->join2set) {
            if (whosends(ci) == s_ChanServ) {
                anope_cmd_part(s_ChanServ, c->name, NULL);
            }
        }
    }
    Anope_Free(chan);
    Anope_Free(newtopic);
    return MOD_CONT;
}
Example #18
0
int do_core_kickban(User * u, Channel *c, char *target, char *reason) {
	ChannelInfo *ci = c->ci;
	User *u2;
	int is_same, exists;
	char *av[2];

	if (!target)
		target = u->nick;

	is_same = (target == u->nick) ? 1 : (stricmp(target, u->nick) == 0);

	if (is_same) {
		u2 = u;
		exists = 1;
	} else
		exists = ((u2 = finduser(target)) ? 1 : 0);

	if (!is_same ? !check_access(u, ci, CA_BAN) : !check_access(u, ci, CA_BANME)) {
		notice_lang(ci->bi->nick, u, ACCESS_DENIED);
	} else if (!is_same && exists && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	} else if (exists && ((ircd->protectedumode && is_protected(u2)) && !is_founder(u, ci))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	/**
	 * Dont ban the user on channels where he is excepted
	 * to prevent services <-> server wars.
	 **/
	} else if (exists && (ircd->except && is_excepted(ci, u2))) {
		notice_lang(ci->bi->nick, u, CHAN_EXCEPTED, u2->nick, ci->name);
	} else if (!exists && (ircd->except && is_excepted_mask(ci, target))) {
		notice_lang(ci->bi->nick, u, CHAN_EXCEPTED, target, ci->name);
	} else if (exists && RestrictKB && ((!is_founder(u, ci) && is_services_oper(u2)) ||
			(is_founder(u, ci) && is_services_admin(u2)))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	} else if (stricmp(target, ci->bi->nick) == 0) {
		bot_raw_ban(u, ci, u->nick, "Oops!");
	} else {
		if (exists) {
			if (is_on_chan(ci->c, u2)) {
				if (!reason)
					bot_raw_ban(u, ci, target, "Requested");
				else
					bot_raw_ban(u, ci, target, reason);
			}

		} else if (my_match_wild_nocase("*@*", target)) {
			char mask[BUFSIZE];

			/* If we get a *@* target we need to add the *!... */
			if (!my_match_wild_nocase("*!*@*", target))
				snprintf(mask, BUFSIZE, "*!%s", target);
			else
				snprintf(mask, BUFSIZE, "%s", target);

			/* Only continue if the mask doesn't match an exception or is otherwise prohibited.. */
			if (check_banmask(u, c, mask)) {
				struct c_userlist *cu = NULL, *next = NULL;

				av[0] = "+b";
				av[1] = mask;

				anope_cmd_mode(ci->bi->nick, c->name, "+b %s", av[1]);
				chan_set_modes(ci->bi->nick, c, 2, av, 1);

				cu = c->users;
				while (cu) {
					next = cu->next;
					/* This only checks against the cloacked host & vhost for normal users.
					 * IPs are only checked when triggered by an oper.. */
					if (is_oper(u) ? match_usermask_full(mask, cu->user, true) : match_usermask(mask, cu->user)) {
						if (!reason)
							bot_raw_kick(u, ci, cu->user->nick, "Requested");
						else
							bot_raw_kick(u, ci, cu->user->nick, reason);
					}
					cu = next;
				}
			}
		} else
			noticeLang(ci->bi->nick, u, LANG_REQ_NICK_OR_MASK);
	}
	return MOD_CONT;
}