X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodules%2FNeonServ.mod%2Fcmd_neonserv_inviteme.c;h=f7f2a82794ec22723e7c6c7c51d9e0d6dcdb3751;hb=9a3c990b3720debc49136ef00df80be6b2223839;hp=62f787c33c4e4436788f7ddc202b96609f116832;hpb=d80ff9e6b878be4f29854f4fe99f59efeb5e6e10;p=NeonServV5.git diff --git a/src/modules/NeonServ.mod/cmd_neonserv_inviteme.c b/src/modules/NeonServ.mod/cmd_neonserv_inviteme.c index 62f787c..f7f2a82 100644 --- a/src/modules/NeonServ.mod/cmd_neonserv_inviteme.c +++ b/src/modules/NeonServ.mod/cmd_neonserv_inviteme.c @@ -1,4 +1,4 @@ -/* cmd_neonserv_inviteme.c - NeonServ v5.5 +/* cmd_neonserv_inviteme.c - NeonServ v5.6 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -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); }