1 /* cmd_neonbackup_recover.c - NeonServ v5.6
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "cmd_neonbackup.h"
23 static struct ClientSocket *neonbackup_cmd_recover_get_bot(int clientid) {
24 struct ClientSocket *bot;
25 for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
26 if(bot->clientid == clientid)
32 CMD_BIND(neonbackup_cmd_recover) {
35 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");
38 struct ClientSocket *bot;
39 struct ChanUser *chanuser;
40 while ((row = mysql_fetch_row(res)) != NULL) {
41 chan = getChanByName(row[0]);
44 bot = neonbackup_cmd_recover_get_bot(atoi(row[1]));
47 if(!(chanuser = getChanUser(bot->user, chan))) {
48 requestInvite(bot->user, chan);
49 reply(textclient, user, "NS_INVITE_DONE", bot->user->nick, chan->name);
50 } else if(!chanuser->flags & CHANUSERFLAG_OPPED) {
51 requestOp(bot->user, chan);
52 reply(textclient, user, "NS_OP_DONE", chan->name);