added bot/ircop mark to cmd_nicklist
[NeonServV5.git] / src / modules / global.mod / cmd_global_setbot.c
index 32ccce5793f29276a0e131fc00331a7f30ede947..0017de2b79cd3fcf598365ec6c3bf7e32798f86b 100644 (file)
@@ -35,6 +35,7 @@ static int global_cmd_setbot_serverpass(struct ClientSocket *textclient, struct
 static int global_cmd_setbot_class(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
 static int global_cmd_setbot_queue(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
 static int global_cmd_setbot_prefered(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
+static int global_cmd_setbot_secret(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
 static int global_cmd_setbot_maxchan(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
 static int global_cmd_setbot_priority(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
 static int global_cmd_setbot_trigger(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value);
@@ -43,7 +44,7 @@ CMD_BIND(global_cmd_setbot) {
     MYSQL_RES *res;
     MYSQL_ROW row;
     int botid = atoi(argv[0]);
-    printf_mysql_query("SELECT `active`, `nick`, `server`, `port`, `pass`, `botclass`, `textbot`, `queue`, `defaulttrigger`, `max_channels`, `register_priority`, `bind`, `ident`, `realname`, `ssl`, `id` FROM `bots` WHERE `id` = '%d'", botid);
+    printf_mysql_query("SELECT `active`, `nick`, `server`, `port`, `pass`, `botclass`, `textbot`, `queue`, `defaulttrigger`, `max_channels`, `register_priority`, `bind`, `ident`, `realname`, `ssl`, `id`, `secret` FROM `bots` WHERE `id` = '%d'", botid);
     res = mysql_use();
     if(!(row = mysql_fetch_row(res))) {
         reply(textclient, user, "NS_SETBOT_UNKNOWN", botid);
@@ -68,6 +69,7 @@ CMD_BIND(global_cmd_setbot) {
         else if(!stricmp(argv[1], "botclass")) log_event = global_cmd_setbot_class(textclient, user, row, value);
         else if(!stricmp(argv[1], "queue")) log_event = global_cmd_setbot_queue(textclient, user, row, value);
         else if(!stricmp(argv[1], "prefered")) log_event = global_cmd_setbot_prefered(textclient, user, row, value);
+        else if(!stricmp(argv[1], "secret")) log_event = global_cmd_setbot_secret(textclient, user, row, value);
         else if(!stricmp(argv[1], "maxchan")) log_event = global_cmd_setbot_maxchan(textclient, user, row, value);
         else if(!stricmp(argv[1], "priority")) log_event = global_cmd_setbot_priority(textclient, user, row, value);
         else if(!stricmp(argv[1], "trigger")) log_event = global_cmd_setbot_trigger(textclient, user, row, value);
@@ -97,6 +99,7 @@ CMD_BIND(global_cmd_setbot) {
         global_cmd_setbot_class(textclient, user, row, NULL);
         global_cmd_setbot_queue(textclient, user, row, NULL);
         global_cmd_setbot_prefered(textclient, user, row, NULL);
+        global_cmd_setbot_secret(textclient, user, row, NULL);
         global_cmd_setbot_maxchan(textclient, user, row, NULL);
         global_cmd_setbot_priority(textclient, user, row, NULL);
         global_cmd_setbot_trigger(textclient, user, row, NULL);
@@ -476,6 +479,35 @@ static int global_cmd_setbot_prefered(struct ClientSocket *textclient, struct Us
     return ret;
 }
 
+static int global_cmd_setbot_secret(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
+    int val = (strcmp(bot[16], "0") ? 1 : 0);
+    int ret = 0;
+    if(value) {
+        if(!strcmp(value, "0") || !stricmp(value, "off") || !stricmp(value, get_language_string(user, "NS_SET_OFF"))) {
+            val = 0;
+        } else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
+            val = 1;
+        } else {
+            reply(textclient, user, "NS_SET_INVALID_BOOLEAN", value);
+            return 0;
+        }
+        struct ClientSocket *client;
+        for(client = getBots(0, NULL); client; client = getBots(0, client)) {
+            if(client->clientid == atoi(bot[15])) {
+                if(val)
+                    client->flags |= SOCKET_FLAG_SECRET_BOT;
+                else
+                    client->flags &= ~SOCKET_FLAG_SECRET_BOT;
+                break;
+            }
+        }
+        printf_mysql_query("UPDATE `bots` SET `secret` = '%d' WHERE `id` = '%s'", val, bot[15]);
+        ret = 1;
+    }
+    reply(textclient, user, "\002SECRET     \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
+    return ret;
+}
+
 static int global_cmd_setbot_maxchan(struct ClientSocket *textclient, struct UserNode *user, MYSQL_ROW bot, char *value) {
     int val = atoi(bot[9]);
     int ret = 0;