X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fcmd_neonserv_kickban.c;fp=src%2Fcmd_neonserv_kickban.c;h=0000000000000000000000000000000000000000;hb=706e48b1e666054030c491d864f740071e390038;hp=1123cd7b5a12dbb9d16f6f38c57f855184738202;hpb=b53d0c5f88063f075a48a0426f9d5d6b3490b9fc;p=NeonServV5.git diff --git a/src/cmd_neonserv_kickban.c b/src/cmd_neonserv_kickban.c deleted file mode 100644 index 1123cd7..0000000 --- a/src/cmd_neonserv_kickban.c +++ /dev/null @@ -1,169 +0,0 @@ -/* cmd_neonserv_kickban.c - NeonServ v5.3 - * Copyright (C) 2011-2012 Philipp Kreil (pk910) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "cmd_neonserv.h" - -/* -* argv[0] nick[,*auth[,*!*@mask[...]]] -* argv[1-*] reason -*/ -static USERLIST_CALLBACK(neonserv_cmd_kickban_userlist_lookup); -static void neonserv_cmd_kickban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nicks, char *reason); - -struct neonserv_cmd_kickban_cache { - struct ClientSocket *client, *textclient; - struct UserNode *user; - struct Event *event; - char *nicks; - char *reason; -}; - -CMD_BIND(neonserv_cmd_kickban) { - struct neonserv_cmd_kickban_cache *cache = malloc(sizeof(*cache)); - if (!cache) { - perror("malloc() failed"); - return; - } - cache->client = client; - cache->textclient = getTextBot(); - cache->user = user; - cache->event = event; - cache->nicks = strdup(argv[0]); - if(argc > 1) { - cache->reason = strdup(merge_argv(argv, 1, argc)); - } else - cache->reason = NULL; - get_userlist_with_invisible(chan, neonserv_cmd_kickban_userlist_lookup, cache); -} - -static USERLIST_CALLBACK(neonserv_cmd_kickban_userlist_lookup) { - struct neonserv_cmd_kickban_cache *cache = data; - neonserv_cmd_kickban_async1(cache->client, cache->textclient, cache->user, chan, cache->event, cache->nicks, (cache->reason ? cache->reason : "Bye.")); - free(cache->nicks); - if(cache->reason) - free(cache->reason); - free(cache); -} - -static void neonserv_cmd_kickban_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, struct Event *event, char *nicks, char *reason) { - int i, kicked_users = 0, provided_nicks = 0; - char *nick, *nextnick; - struct UserNode *cuser; - struct ChanUser *chanuser; - char usermask[NICKLEN+USERLEN+HOSTLEN+3]; - nextnick = nicks; - while((nick = nextnick)) { - nextnick = strstr(nick, ","); - if(nextnick) { - *nextnick = '\0'; - nextnick++; - } - if(!*nick) continue; - if(is_ircmask(nick)) { - //KICK HOSTMASK - struct ChanUser *kickban_chanuser[chan->usercount]; - int kick_chanuser_pos = 0; - for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) { - cuser = chanuser->user; - sprintf(usermask, "%s!%s@%s", cuser->nick, cuser->ident, cuser->host); - if(!match(nick, usermask)) { - provided_nicks++; - if(isNetworkService(chanuser->user)) { - reply(textclient, user, "NS_SERVICE_IMMUNE", chanuser->user->nick); - continue; - } - if(cuser == user || ((cuser->flags & USERFLAG_ISAUTHED) && !stricmp(user->auth, cuser->auth))) { - reply(textclient, user, "NS_YOU_PROTECTED"); - continue; - } - if(isUserProtected(chan, cuser, user)) { - reply(textclient, user, "NS_USER_PROTECTED", cuser->nick); - continue; - } - kickban_chanuser[kick_chanuser_pos++] = chanuser; - if(kick_chanuser_pos > 4 && (kick_chanuser_pos * 3) > chan->usercount && !isGodMode(user)) { - kick_chanuser_pos = 0; - reply(textclient, user, "NS_LAME_MASK", nick); - break; - } - } - } - for(i = 0; i < kick_chanuser_pos; i++) { - if(i == 0) { - putsock(client, "MODE %s +b %s", chan->name, nick); - } - kicked_users++; - putsock(client, "KICK %s %s :(%s) %s", chan->name, kickban_chanuser[i]->user->nick, user->nick, reason); - } - } else if(*nick == '*') { - //KICK AUTH - nick++; - cuser = NULL; - if(!stricmp(user->auth, nick)) { - reply(textclient, user, "NS_YOU_PROTECTED"); - continue; - } - for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) { - if((chanuser->user->flags & USERFLAG_ISAUTHED) && !stricmp(chanuser->user->auth, nick)) { - provided_nicks++; - if(isNetworkService(chanuser->user)) { - reply(textclient, user, "NS_SERVICE_IMMUNE", chanuser->user->nick); - continue; - } - if(!cuser) { - //check if the user is protected - if(isUserProtected(chan, chanuser->user, user)) { - reply(textclient, user, "NS_USER_PROTECTED", chanuser->user->nick); - break; //all other users are also protected... - } - cuser = chanuser->user; - } - kicked_users++; - putsock(client, "MODE %s +b %s", chan->name, generate_banmask(cuser, usermask)); - putsock(client, "KICK %s %s :(%s) %s", chan->name, cuser->nick, user->nick, reason); - } - } - } else { - provided_nicks++; - cuser = searchUserByNick(nick); - if(!cuser) continue; - chanuser = getChanUser(cuser, chan); - if(!chanuser) continue; - if(isNetworkService(cuser)) { - reply(textclient, user, "NS_SERVICE_IMMUNE", cuser->nick); - continue; - } - if(cuser == user || ((cuser->flags & USERFLAG_ISAUTHED) && !stricmp(user->auth, cuser->auth))) { - reply(textclient, user, "NS_YOU_PROTECTED"); - continue; - } - if(isUserProtected(chan, cuser, user)) { - reply(textclient, user, "NS_USER_PROTECTED", cuser->nick); - continue; - } - kicked_users++; - putsock(client, "MODE %s +b %s", chan->name, generate_banmask(cuser, usermask)); - putsock(client, "KICK %s %s :(%s) %s", chan->name, cuser->nick, user->nick, reason); - } - } - if(kicked_users == provided_nicks) - reply(getTextBot(), user, "NS_KICKBAN_DONE", kicked_users, chan->name); - else - reply(getTextBot(), user, "NS_KICKBAN_FAIL", client->user->nick); - if(kicked_users) - logEvent(event); -}