From 3c79d690604ce1e7441de65879a094d01ff76403 Mon Sep 17 00:00:00 2001 From: pk910 Date: Fri, 23 Dec 2011 23:53:57 +0100 Subject: [PATCH] fixed cmd_register & cmd_unregister (fixed some zero-bot issues) --- src/cmd_global_register.c | 5 ++++- src/cmd_global_unregister.c | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cmd_global_register.c b/src/cmd_global_register.c index dd94f93..6cf8586 100644 --- a/src/cmd_global_register.c +++ b/src/cmd_global_register.c @@ -209,7 +209,10 @@ static void global_cmd_register_async1(struct ClientSocket *client, struct Clien userid = (int) mysql_insert_id(mysql_conn); } } - printf_mysql_query("SELECT `id`, `max_channels`, `defaulttrigger`, `nick` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1' ORDER BY `register_priority` DESC", client->botid); + if(client->botid) + printf_mysql_query("SELECT `id`, `max_channels`, `defaulttrigger`, `nick` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1' ORDER BY `register_priority` DESC", client->botid); + else + printf_mysql_query("SELECT `id`, `max_channels`, `defaulttrigger`, `nick` FROM `bots` WHERE `botid` = '%d' AND `active` = '1'", client->clientid); res = mysql_use(); int botid = 0; while ((row = mysql_fetch_row(res)) != NULL) { diff --git a/src/cmd_global_unregister.c b/src/cmd_global_unregister.c index 48b0d03..7af1682 100644 --- a/src/cmd_global_unregister.c +++ b/src/cmd_global_unregister.c @@ -38,18 +38,19 @@ CMD_BIND(global_cmd_unregister) { return; } if(client->botid == 0) - 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); + 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); else - 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); + 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); 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) + if(bot->clientid == botid && (!botid || bot->clientid == clientid)) break; } if(bot && strcmp(row[2], "1")) { -- 2.20.1