X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2Fmodules%2FNeonBackup.mod%2Fcmd_neonbackup_recover.c;fp=src%2Fmodules%2FNeonBackup.mod%2Fcmd_neonbackup_recover.c;h=dc71276cd25ad158fc936c78ae697e5d7f5df84b;hp=0000000000000000000000000000000000000000;hb=74e0bf2c7822764abb9f74ccbda5f2950cb9996a;hpb=9826cc87d81d9adb6ca8819b46e7e83dcbb63020 diff --git a/src/modules/NeonBackup.mod/cmd_neonbackup_recover.c b/src/modules/NeonBackup.mod/cmd_neonbackup_recover.c new file mode 100644 index 0000000..dc71276 --- /dev/null +++ b/src/modules/NeonBackup.mod/cmd_neonbackup_recover.c @@ -0,0 +1,56 @@ +/* cmd_neonbackup_recover.c - NeonServ v5.6 + * 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_neonbackup.h" + +/* +* no argv +*/ +static struct ClientSocket *neonbackup_cmd_recover_get_bot(int clientid) { + struct ClientSocket *bot; + for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { + if(bot->clientid == clientid) + return bot; + } + return NULL; +} + +CMD_BIND(neonbackup_cmd_recover) { + MYSQL_RES *res; + MYSQL_ROW row; + printf_mysql_query("SELECT `channels`.`channel_name`, `bots`.`id` FROM `bot_channels`, `bots`, `channels` WHERE `bots`.`id` = `botid` AND `channel_id` = `chanid` AND `active` = 1"); + res = mysql_use(); + + struct ClientSocket *bot; + struct ChanUser *chanuser; + while ((row = mysql_fetch_row(res)) != NULL) { + chan = getChanByName(row[0]); + if(!chan) + continue; + bot = neonbackup_cmd_recover_get_bot(atoi(row[1])); + if(!bot) + continue; + if(!(chanuser = getChanUser(bot->user, chan))) { + requestInvite(bot->user, chan); + reply(textclient, user, "NS_INVITE_DONE", bot->user->nick, chan->name); + } else if(!chanuser->flags & CHANUSERFLAG_OPPED) { + requestOp(bot->user, chan); + reply(textclient, user, "NS_OP_DONE", chan->name); + } + } + logEvent(event); +}