changed Makefile; build all commands as an own file
[NeonServV5.git] / cmd_neonserv_unregister.c
index 2137403f80330c32ec19bf8f038ca48eac411405..8da366e9de0b22f9fb4067ea7d7cbcba74929ede 100644 (file)
@@ -1,8 +1,10 @@
 
+#include "cmd_neonserv.h"
+
 /*
 * argv[0] - channel
 */
-static CMD_BIND(neonserv_cmd_unregister) {
+CMD_BIND(neonserv_cmd_unregister) {
     MYSQL_RES *res;
     MYSQL_ROW row;
     char *channel = argv[0];
@@ -19,7 +21,7 @@ static CMD_BIND(neonserv_cmd_unregister) {
         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);
+    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);
@@ -31,9 +33,10 @@ static CMD_BIND(neonserv_cmd_unregister) {
         if(bot->clientid == botid)
             break;
     }
-    if(bot) {
+    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);
 }