X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2Fmodules%2FNeonServ.mod%2Fcmd_neonserv_inviteme.c;h=f7f2a82794ec22723e7c6c7c51d9e0d6dcdb3751;hp=bbe7a3070b221fbd9c0915fe293c8269365890d4;hb=9a3c990b3720debc49136ef00df80be6b2223839;hpb=d46f9474c87208e9e62f3b5c814f6d014b8a5cf5 diff --git a/src/modules/NeonServ.mod/cmd_neonserv_inviteme.c b/src/modules/NeonServ.mod/cmd_neonserv_inviteme.c index bbe7a30..f7f2a82 100644 --- a/src/modules/NeonServ.mod/cmd_neonserv_inviteme.c +++ b/src/modules/NeonServ.mod/cmd_neonserv_inviteme.c @@ -22,15 +22,45 @@ */ CMD_BIND(neonserv_cmd_inviteme) { - if(getChanUser(user, chan)) { - reply(textclient, user, "NS_INVITEME_ON_CHAN", chan->name); - /* BUG - This check does not work if the user is invisible (CHMODE +D/+d) - to fix this we'd need to request the full userlist... - this is really senseless to invite a simple user so we simply mark this bug as unsolvable. - */ - return; + if(argc && !stricmp(argv[0], "all")) { + //invite to all channels where autoinvite is enabled + MYSQL_RES *res, *res2; + MYSQL_ROW chanuserrow, defaultrow = NULL; + printf_mysql_query("SELECT `chanuser_access`, `chanuser_flags`, `channel_name`, `channel_getinvite` FROM `chanusers` LEFT JOIN `channels` ON `chanuser_cid` = `channel_id` LEFT JOIN `users` ON `chanuser_uid` = `user_id` WHERE `user_user` = '%s' AND `chanuser_flags` >= '%d'", escape_string(user->auth), DB_CHANUSER_AUTOINVITE); + res = mysql_use(); + struct ChanUser *bchanuser; + struct ClientSocket *bot; + while((chanuserrow = mysql_fetch_row(res)) != NULL) { + int userflags = atoi(chanuserrow[1]); + if(!(userflags & DB_CHANUSER_AUTOINVITE)) continue; + if(!(chan = getChanByName(chanuserrow[2]))) continue; //no bot is in the channel + if((bchanuser = getChanUser(client->user, chan)) && (bchanuser->flags & CHANUSERFLAG_OPPED)) + bot = client; + else { + bot = getBotForChannel(chan); + } + if(getChanUser(user, chan)) continue; //user is already in the channel + if(chanuserrow[3] == NULL && defaultrow == NULL) { + printf_mysql_query("SELECT `channel_getinvite` FROM `channels` WHERE `channel_name` = 'defaults'"); + res2 = mysql_use(); + defaultrow = mysql_fetch_row(res2); + } + if(atoi(chanuserrow[0]) >= atoi((chanuserrow[3] ? chanuserrow[3] : defaultrow[0]))) { + putsock(bot, "INVITE %s %s", user->nick, chan->name); + reply(textclient, user, "NS_INVITEME_DONE", chan->name); + } + } + } else { + if(getChanUser(user, chan)) { + reply(textclient, user, "NS_INVITEME_ON_CHAN", chan->name); + /* BUG + This check does not work if the user is invisible (CHMODE +D/+d) + to fix this we'd need to request the full userlist... + this is really senseless to invite a simple user so we simply mark this bug as unsolvable. + */ + return; + } + putsock(client, "INVITE %s %s", user->nick, chan->name); + reply(textclient, user, "NS_INVITEME_DONE", chan->name); } - putsock(client, "INVITE %s %s", user->nick, chan->name); - reply(textclient, user, "NS_INVITEME_DONE", chan->name); }