fixed cmd_register and cmd_unregister for "zero-bot" support
authorpk910 <philipp@zoelle1.de>
Wed, 14 Dec 2011 15:44:12 +0000 (16:44 +0100)
committerpk910 <philipp@zoelle1.de>
Wed, 14 Dec 2011 15:44:12 +0000 (16:44 +0100)
src/cmd_global_register.c
src/cmd_global_unregister.c

index a0c42587defee4804b438b5b4a046589908ec615..b22fc5840f008d0b0ded13be2038756134fc461a 100644 (file)
@@ -50,7 +50,7 @@ CMD_BIND(global_cmd_register) {
     printf_mysql_query("SELECT `botid`, `botclass` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` LEFT JOIN `channels` ON `bot_channels`.`chanid` = `channels`.`channel_id` WHERE `channel_name` = '%s'", escape_string(channel));
     res = mysql_use();
     while ((row = mysql_fetch_row(res)) != NULL) {
-        if(atoi(row[1]) == client->botid) {
+        if(atoi(row[1]) == client->botid && (client->botid || client->clientid == atoi(row[0]))) {
             reply(getTextBot(), user, "NS_REGISTER_ALREADY", argv[0], client->user->nick);
             return;
         } else
index 99669afe62d22ee9e49f4f0b994542da050e15a6..ca36363ebdcd7e8101c78ff3a4fd04b5461c2835 100644 (file)
@@ -37,7 +37,10 @@ CMD_BIND(global_cmd_unregister) {
         reply(getTextBot(), user, "NS_UNREGISTER_NOT_REGISTERED", argv[0], client->user->nick);
         return;
     }
-    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);
+    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);
+    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);
     res = mysql_use();
     if ((row = mysql_fetch_row(res)) == NULL) {
         reply(getTextBot(), user, "NS_UNREGISTER_NOT_REGISTERED", argv[0], client->user->nick);