-/* cmd_global_setbot.c - NeonServ v5.5
+/* cmd_global_setbot.c - NeonServ v5.6
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
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);
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);
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);
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);
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;