From 3d2f2e18cd0df714f74b03347b568f33e61bbe0c Mon Sep 17 00:00:00 2001 From: pk910 Date: Mon, 12 Sep 2011 04:53:11 +0200 Subject: [PATCH] use the correct channel ID in cmd_unregister --- cmd_neonserv_unregister.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd_neonserv_unregister.c b/cmd_neonserv_unregister.c index 83b374e..2137403 100644 --- a/cmd_neonserv_unregister.c +++ b/cmd_neonserv_unregister.c @@ -10,7 +10,16 @@ static CMD_BIND(neonserv_cmd_unregister) { reply(getTextBot(), user, "NS_INVALID_CHANNEL_NAME", argv[0]); return; } - printf_mysql_query("SELECT `botid`, `bot_channels`.`id` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chan->channel_id, client->botid); + int chanid; + printf_mysql_query("SELECT `channel_id` FROM `channels` WHERE `channel_name` = '%s'", escape_string(channel)); + res = mysql_use(); + if ((row = mysql_fetch_row(res)) != NULL) { + chanid = atoi(row[0]); + } else { + reply(getTextBot(), user, "NS_UNREGISTER_NOT_REGISTERED", argv[0], client->user->nick); + return; + } + printf_mysql_query("SELECT `botid`, `bot_channels`.`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); -- 2.20.1