X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodules%2Fglobal.mod%2Fcmd_global_setbot.c;h=c81fd7ff4708f47eed38d71882e930e9fed16ea8;hb=HEAD;hp=ad93242c801421936db430510724f228ff3a8c70;hpb=de5f0224c8b119f1be15457262bd6e66f160657f;p=NeonServV5.git diff --git a/src/modules/global.mod/cmd_global_setbot.c b/src/modules/global.mod/cmd_global_setbot.c index ad93242..c81fd7f 100644 --- a/src/modules/global.mod/cmd_global_setbot.c +++ b/src/modules/global.mod/cmd_global_setbot.c @@ -1,4 +1,4 @@ -/* cmd_global_setbot.c - NeonServ v5.4 +/* 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 @@ -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;