Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void do_akick(User *u)
- {
- char *chan = strtok(NULL, " ");
- char *cmd = strtok(NULL, " ");
- char *mask = strtok(NULL, " ");
- char *reason = strtok_remaining();
- ChannelInfo *ci = NULL;
- int i;
- int is_list = (cmd && (stricmp(cmd,"LIST") == 0
- || stricmp(cmd,"VIEW") == 0
- || stricmp(cmd,"COUNT") == 0));
- if (!chan
- || !cmd
- || (!mask && (stricmp(cmd, "ADD") == 0 || stricmp(cmd, "DEL") == 0))
- ) {
- syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX);
- } else if (!(ci = get_channelinfo(chan))) {
- notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
- } else if (ci->flags & CF_VERBOTEN) {
- notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
- } else if (!check_access_cmd(u, ci, "AKICK", is_list ? "LIST" : cmd)
- && !is_services_admin(u)) {
- if (ci->founder && valid_ngi(u) && ci->founder == u->ngi->id)
- notice_lang(s_ChanServ, u, CHAN_IDENTIFY_REQUIRED, s_ChanServ,
- chan);
- else
- notice_lang(s_ChanServ, u, ACCESS_DENIED);
- } else if (stricmp(cmd, "ADD") == 0) {
- char *mask2, *user, *host;
- const char *nick;
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
- put_channelinfo(ci);
- return;
- }
- /* Make sure we have a valid nick!user@host mask (fill in missing
- * parts with "*"). Error out on @ in nick (also catches a@b!c),
- * missing host, or empty nick/user/host. */
- mask2 = sstrdup(mask);
- nick = mask2;
- user = strchr(mask2, '!');
- if (user) {
- *user++ = 0;
- } else {
- nick = "*";
- user = mask2;
- }
- host = strchr(user, '@');
- if (host)
- *host++ = 0;
- if (!*nick || !*user || !host || !*host || strchr(nick, '@')) {
- notice_lang(s_ChanServ, u, BAD_NICKUSERHOST_MASK);
- free(mask2);
- put_channelinfo(ci);
- return;
- }
- mask = smalloc(strlen(nick)+strlen(user)+strlen(host)+3);
- sprintf(mask, "%s!%s@%s", nick, user, host);
- free(mask2);
- ARRAY_SEARCH(ci->akick, mask, mask, stricmp, i);
- if (i < ci->akick_count) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS,
- ci->akick[i].mask, chan);
- free(mask);
- } else if (ci->akick_count >= CSAutokickMax) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT,
- CSAutokickMax);
- free(mask);
- } else {
- ARRAY_EXTEND(ci->akick);
- ci->akick[i].channel = ci; /* i points at new entry, from above */
- ci->akick[i].mask = mask;
- ci->akick[i].reason = reason ? sstrdup(reason) : NULL;
- time(&ci->akick[i].set);
- ci->akick[i].lastused = 0;
- memset(ci->akick[i].who, 0, NICKMAX); // Avoid leaking random data
- strbcpy(ci->akick[i].who, u->nick);
- notice_lang(s_ChanServ, u, CHAN_AKICK_ADDED, mask, chan);
- if (ci->flags & CF_OPNOTICE) {
- char *chan_tmp = smalloc(sizeof(char) * (strlen(chan)+2));
- chan_tmp[0] = '@';
- strcpy(&chan_tmp[1], chan);
- notice(s_ChanServ, chan_tmp, "AKICK command used for %s in %s by %s",
- mask, chan, u->nick);
- free(chan_tmp);
- }
- }
- } else if (stricmp(cmd, "DEL") == 0) {
- if (readonly) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED);
- put_channelinfo(ci);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement