Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / cmd_global_setbot.c
index a9fac8232e8ec9a7e3247bcfb3955c527821cf79..0654dd1776055303e80a62bb83381d3c5664c6c3 100644 (file)
@@ -1,5 +1,5 @@
 /* cmd_global_setbot.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
@@ -70,11 +70,17 @@ CMD_BIND(global_cmd_setbot) {
         else if(!stricmp(argv[1], "prefered")) log_event = global_cmd_setbot_prefered(user, row, value);
         else if(!stricmp(argv[1], "maxchan")) log_event = global_cmd_setbot_maxchan(user, row, value);
         else if(!stricmp(argv[1], "priority")) log_event = global_cmd_setbot_priority(user, row, value);
-        else if(!stricmp(argv[1], "trigger")) log_event = global_cmd_setbot_nick(user, row, value);
+        else if(!stricmp(argv[1], "trigger")) log_event = global_cmd_setbot_trigger(user, row, value);
         else {
             reply(getTextBot(), user, "NS_SETBOT_SETTING", argv[1]);
         }
         if(log_event) {
+            if(!stricmp(argv[1], "serverpass") && value) { //censor server password 
+                char cmd_args[MAXLEN];
+                sprintf(cmd_args, "%d SERVERPASS ***", botid);
+                free(event->arguments);
+                event->arguments = strdup(cmd_args);
+            }
             logEvent(event);
         }
     } else {
@@ -346,12 +352,14 @@ static int global_cmd_setbot_serverpass(struct UserNode *user, MYSQL_ROW bot, ch
     char *val = bot[4];
     int ret = 0;
     if(value) {
+        if(!strcmp(value, "*")) 
+            value = "";
         struct ClientSocket *client;
         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
             if(client->clientid == atoi(bot[15])) {
                 if(client->pass)
                     free(client->pass);
-                client->pass = strdup(value);
+                client->pass = (value ? strdup(value) : NULL);
                 if(client->flags & SOCKET_FLAG_READY)
                     reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
                 break;
@@ -509,6 +517,7 @@ static int global_cmd_setbot_trigger(struct UserNode *user, MYSQL_ROW bot, char
             return 0;
         }
         printf_mysql_query("UPDATE `bots` SET `defaulttrigger` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
+        flush_trigger_cache(atoi(bot[5]), atoi(bot[15]));
         reply(getTextBot(), user, "NS_SETBOT_TRIGGER_NOTE");
         val = value;
         ret = 1;