/* cmd_global_unregister.c - NeonServ v5.3
- * Copyright (C) 2011 Philipp Kreil (pk910)
+ * 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
return;
}
if(client->botid == 0)
- printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended`, `bots`.`id` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '0' AND `botid` = '%d'", chanid, client->clientid);
+ printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '0' AND `botid` = '%d'", chanid, client->clientid);
else
- printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended`, `bots`.`id` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chanid, client->botid);
+ printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chanid, client->botid);
res = mysql_use();
if ((row = mysql_fetch_row(res)) == NULL) {
reply(getTextBot(), user, "NS_UNREGISTER_NOT_REGISTERED", argv[0], client->user->nick);
return;
}
int botid = atoi(row[0]);
- int clientid = atoi(row[3]);
struct ClientSocket *bot;
for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
- if(bot->clientid == botid && (!botid || bot->clientid == clientid))
+ if(bot->clientid == botid)
break;
}
+ printf_mysql_query("DELETE FROM `bot_channels` WHERE `id` = '%s'", row[1]);
+ reply(getTextBot(), user, "NS_UNREGISTER_DONE", channel);
if(bot && strcmp(row[2], "1")) {
putsock(bot, "PART %s :Channel unregistered.", channel);
}
- printf_mysql_query("DELETE FROM `bot_channels` WHERE `id` = '%s'", row[1]);
- reply(getTextBot(), user, "NS_UNREGISTER_DONE", channel);
logEvent(event);
}