added "nowho" parameter to debug userlist and fixed memory leak in DBHelper.c
[NeonServV5.git] / src / cmd_global_unregister.c
index 48b0d03de1908b57eff360ddc0cb91864a6b0e29..206e763bbb15f497b28f0bfd7fe9e556524509f6 100644 (file)
@@ -1,5 +1,5 @@
 /* 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
 CMD_BIND(global_cmd_unregister) {
     MYSQL_RES *res;
     MYSQL_ROW row;
-    char *channel = argv[0];
+    char *channel;
+    if(argc)
+        channel = argv[0];
+    else
+        channel = (chan ? chan->name : "");
     if(!is_valid_chan(channel)) {
         reply(getTextBot(), user, "NS_INVALID_CHANNEL_NAME", argv[0]);
         return;
@@ -52,10 +56,10 @@ CMD_BIND(global_cmd_unregister) {
         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);
 }