From: pk910 Date: Tue, 21 Aug 2012 16:53:28 +0000 (+0200) Subject: added bot/ircop mark to cmd_nicklist X-Git-Tag: v5.5~19 X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=commitdiff_plain;h=cdebdaa89c585c948a7abbfcda22fed6b029d9da added bot/ircop mark to cmd_nicklist --- diff --git a/database.sql b/database.sql index bb4ea6b..d378118 100644 --- a/database.sql +++ b/database.sql @@ -38,6 +38,7 @@ CREATE TABLE IF NOT EXISTS `bots` ( `botclass` int(10) NOT NULL, `textbot` tinyint(1) NOT NULL, `queue` tinyint(1) NOT NULL, + `secret` tinyint(1) NOT NULL, `defaulttrigger` varchar(10) NOT NULL, `max_channels` int(5) NOT NULL, `register_priority` int(2) NOT NULL, diff --git a/database.upgrade.sql b/database.upgrade.sql index b7c9ac1..bb26d92 100644 --- a/database.upgrade.sql +++ b/database.upgrade.sql @@ -182,3 +182,7 @@ ADD `oper_pass` VARCHAR( 50 ) NULL AFTER `oper_user`; ALTER TABLE `users` ADD `user_block_invites` TINYINT NOT NULL AFTER `user_reply_privmsg`; -- version: 19 + +ALTER TABLE `bots` ADD `secret` TINYINT( 1 ) NOT NULL AFTER `queue`; + +-- version: 20 diff --git a/src/ClientSocket.h b/src/ClientSocket.h index b4e7d44..ddbb60f 100644 --- a/src/ClientSocket.h +++ b/src/ClientSocket.h @@ -33,6 +33,7 @@ #define SOCKET_FLAG_CHANGENICK 0x800 #define SOCKET_FLAG_REQUEST_INVITE 0x1000 #define SOCKET_FLAG_REQUEST_OP 0x2000 +#define SOCKET_FLAG_SECRET_BOT 0x4000 #define SOCKET_HAVE_BOTCLASSVALUE1 0x10000000 #define SOCKET_HAVE_BOTCLASSVALUE2 0x20000000 diff --git a/src/IRCParser.c b/src/IRCParser.c index 0188de9..0f6c692 100644 --- a/src/IRCParser.c +++ b/src/IRCParser.c @@ -188,10 +188,13 @@ static IRC_CMD(raw_join) { event_registered(user, from); user->flags &= ~USERFLAG_WAS_REGISTERING; } else if(!(chan->flags & CHANFLAG_RECEIVED_USERLIST)) { + if(!isBot(user)) + return 1; //ignore join + chanuser = addChanUser(chan, user); chanuser->visCount = 1; - if(isBot(user) && isModeSet(chan->modes, 'D')) //if the bot joins a channel it could also be invisible + if(isModeSet(chan->modes, 'D')) //if the bot joins a channel it could also be invisible chanuser->flags |= CHANUSERFLAG_INVISIBLE; get_userlist_with_invisible(chan, 0, got_channel_userlist, chanuser); diff --git a/src/bots.c b/src/bots.c index 5097e8d..ef55ef6 100644 --- a/src/bots.c +++ b/src/bots.c @@ -40,7 +40,7 @@ static void start_zero_bots() { MYSQL_RES *res, *res2; MYSQL_ROW row; - printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '0' AND `active` = '1'"); + printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind`, `secret` FROM `bots` WHERE `botclass` = '0' AND `active` = '1'"); res = mysql_use(); while ((row = mysql_fetch_row(res)) != NULL) { @@ -48,6 +48,7 @@ static void start_zero_bots() { client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0); client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0); client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0); + client->flags |= (strcmp(row[11], "0") ? SOCKET_FLAG_SECRET_BOT : 0); client->botid = 0; client->clientid = atoi(row[7]); connect_socket(client); diff --git a/src/modules/DummyServ.mod/bot_DummyServ.c b/src/modules/DummyServ.mod/bot_DummyServ.c index c250510..3d6ac1e 100644 --- a/src/modules/DummyServ.mod/bot_DummyServ.c +++ b/src/modules/DummyServ.mod/bot_DummyServ.c @@ -75,7 +75,7 @@ static void start_bots(int type) { MYSQL_ROW row; if(type == MODSTATE_STARTSTOP) { - printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); + printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind`, `secret` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); res = mysql_use(); while ((row = mysql_fetch_row(res)) != NULL) { @@ -83,6 +83,7 @@ static void start_bots(int type) { client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0); client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0); client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0); + client->flags |= (strcmp(row[11], "0") ? SOCKET_FLAG_SECRET_BOT : 0); client->flags |= SOCKET_FLAG_SILENT; client->botid = BOTID; client->clientid = atoi(row[7]); diff --git a/src/modules/NeonBackup.mod/bot_NeonBackup.c b/src/modules/NeonBackup.mod/bot_NeonBackup.c index 62e3918..b412426 100644 --- a/src/modules/NeonBackup.mod/bot_NeonBackup.c +++ b/src/modules/NeonBackup.mod/bot_NeonBackup.c @@ -88,7 +88,7 @@ static void start_bots(int type) { MYSQL_ROW row; if(type == MODSTATE_STARTSTOP) { - printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); + printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind`, `secret` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); res = mysql_use(); while ((row = mysql_fetch_row(res)) != NULL) { @@ -96,6 +96,7 @@ static void start_bots(int type) { client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0); client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0); client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0); + client->flags |= (strcmp(row[11], "0") ? SOCKET_FLAG_SECRET_BOT : 0); client->flags |= SOCKET_FLAG_REQUEST_INVITE | SOCKET_FLAG_REQUEST_OP; client->botid = BOTID; client->clientid = atoi(row[7]); diff --git a/src/modules/NeonFun.mod/bot_NeonFun.c b/src/modules/NeonFun.mod/bot_NeonFun.c index d2352c9..dbef386 100644 --- a/src/modules/NeonFun.mod/bot_NeonFun.c +++ b/src/modules/NeonFun.mod/bot_NeonFun.c @@ -92,7 +92,7 @@ static void start_bots(int type) { MYSQL_ROW row; if(type == MODSTATE_STARTSTOP) { - printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); + printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind`, `secret` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); res = mysql_use(); while ((row = mysql_fetch_row(res)) != NULL) { @@ -100,6 +100,7 @@ static void start_bots(int type) { client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0); client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0); client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0); + client->flags |= (strcmp(row[11], "0") ? SOCKET_FLAG_SECRET_BOT : 0); client->flags |= SOCKET_FLAG_SILENT; client->flags |= SOCKET_FLAG_REQUEST_INVITE | SOCKET_FLAG_REQUEST_OP; client->botid = BOTID; diff --git a/src/modules/NeonHelp.mod/bot_NeonHelp.c b/src/modules/NeonHelp.mod/bot_NeonHelp.c index 5aa2316..410ad1c 100644 --- a/src/modules/NeonHelp.mod/bot_NeonHelp.c +++ b/src/modules/NeonHelp.mod/bot_NeonHelp.c @@ -122,7 +122,7 @@ static void start_bots(int type) { MYSQL_ROW row; if(type == MODSTATE_STARTSTOP) { - printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); + printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind`, `secret` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); res = mysql_use(); while ((row = mysql_fetch_row(res)) != NULL) { @@ -130,6 +130,7 @@ static void start_bots(int type) { client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0); client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0); client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0); + client->flags |= (strcmp(row[11], "0") ? SOCKET_FLAG_SECRET_BOT : 0); client->flags |= SOCKET_FLAG_SILENT; client->flags |= SOCKET_FLAG_REQUEST_INVITE | SOCKET_FLAG_REQUEST_OP; client->botid = BOTID; diff --git a/src/modules/NeonServ.mod/bot_NeonServ.c b/src/modules/NeonServ.mod/bot_NeonServ.c index 8433db8..477bf4f 100644 --- a/src/modules/NeonServ.mod/bot_NeonServ.c +++ b/src/modules/NeonServ.mod/bot_NeonServ.c @@ -359,6 +359,8 @@ static const struct default_language_entry msgtab[] = { {"NS_NICKLIST_STATE", "State"}, {"NS_NICKLIST_ACCESS", "Access"}, {"NS_NICKLIST_SYNC", "use `nicklist sync` to fix all red and orange entrys in the list above (add opped users with %d and voiced with %d access)"}, + {"NS_NICKLIST_ACCESS_BOT", "Bot"}, + {"NS_NICKLIST_ACCESS_OPER", "Operator"}, {"NS_SETBOT_UNKNOWN", "`%d` is an unknown botid."}, /* {ARGS: 50} */ {"NS_SETBOT_HEADER", "$bSettings for botid `%d`:$b"}, /* {ARGS: 50} */ {"NS_SETBOT_SETTING", "$b%s$b is an unknown bot setting."}, /* {ARGS: "strangeSetting"} */ @@ -465,13 +467,14 @@ static void start_bots(int type) { MYSQL_ROW row; if(type == MODSTATE_STARTSTOP) { - printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); + printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind`, `secret` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); res = mysql_use(); while ((row = mysql_fetch_row(res)) != NULL) { client = create_socket(row[3], atoi(row[4]), row[10], row[5], row[0], row[1], row[2]); client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0); client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0); client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0); + client->flags |= (strcmp(row[11], "0") ? SOCKET_FLAG_SECRET_BOT : 0); client->flags |= SOCKET_FLAG_REQUEST_INVITE | SOCKET_FLAG_REQUEST_OP; client->botid = BOTID; client->clientid = atoi(row[7]); diff --git a/src/modules/NeonServ.mod/cmd_neonserv_nicklist.c b/src/modules/NeonServ.mod/cmd_neonserv_nicklist.c index d8fe67a..1287ad6 100644 --- a/src/modules/NeonServ.mod/cmd_neonserv_nicklist.c +++ b/src/modules/NeonServ.mod/cmd_neonserv_nicklist.c @@ -122,12 +122,13 @@ static void neonserv_cmd_nicklist_async1(struct ClientSocket *client, struct Cli char *content[4]; int userlistlen, i, j; int db_enfops, db_enfvoice; - int caccess, synced_user; + int caccess, synced_user, accessbufpos; struct ChanUser *chanusers[chan->usercount]; struct ChanUser *chanuser; + struct ClientSocket *bot; int chanuser_count; char statebuf[5]; - char accessbuf[9]; + char accessbuf[50]; char viscountbuf[5]; int uaccess; @@ -199,20 +200,20 @@ static void neonserv_cmd_nicklist_async1(struct ClientSocket *client, struct Cli uaccess = db_enfvoice; } else { //fail... - sprintf(accessbuf, "\00307%d\003", uaccess); + accessbufpos = sprintf(accessbuf, "\00307%d\003", uaccess); break; } neonserv_cmd_nicklist_synchronize_user(chan, chanuser->user, uaccess); - sprintf(accessbuf, "\00309%d\003", uaccess); + accessbufpos = sprintf(accessbuf, "\00309%d\003", uaccess); synced_user = 1; } else { synced_user = 1; - sprintf(accessbuf, "\00307%d\003", uaccess); + accessbufpos = sprintf(accessbuf, "\00307%d\003", uaccess); } } else if((uaccess >= db_enfops && !(chanuser->flags & CHANUSERFLAG_OPPED)) || (uaccess >= db_enfvoice && !(chanuser->flags & CHANUSERFLAG_OPPED_OR_VOICED))) - sprintf(accessbuf, "\00303%d\003", uaccess); + accessbufpos = sprintf(accessbuf, "\00303%d\003", uaccess); else - sprintf(accessbuf, "%d", uaccess); + accessbufpos = sprintf(accessbuf, "%d", uaccess); break; } } @@ -229,21 +230,49 @@ static void neonserv_cmd_nicklist_async1(struct ClientSocket *client, struct Cli uaccess = db_enfvoice; } else { uaccess = 0; - sprintf(accessbuf, "\003040\003"); + accessbufpos = sprintf(accessbuf, "\003040\003"); } if(uaccess && (chanuser->user->flags & USERFLAG_ISAUTHED)) { neonserv_cmd_nicklist_synchronize_user(chan, chanuser->user, uaccess); - sprintf(accessbuf, "\00309%d\003", uaccess); + accessbufpos = sprintf(accessbuf, "\00309%d\003", uaccess); synced_user = 1; } else if(uaccess) { - sprintf(accessbuf, "\003040\003"); + accessbufpos = sprintf(accessbuf, "\003040\003"); } } else { synced_user = 1; - sprintf(accessbuf, "\003040\003"); + accessbufpos = sprintf(accessbuf, "\003040\003"); } } else if(!uaccess) - sprintf(accessbuf, "0"); + accessbufpos = sprintf(accessbuf, "0"); + j = 0; + if(isBot(chanuser->user)) { + //check if bot is secret + for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { + if(bot->user == chanuser->user) + break; + } + if(bot && !(bot->flags & SOCKET_FLAG_SECRET_BOT)) { + if(j) + accessbufpos += sprintf(accessbuf+accessbufpos, ", "); + else { + accessbufpos += sprintf(accessbuf+accessbufpos, " ("); + j = 1; + } + accessbufpos += sprintf(accessbuf+accessbufpos, "%s", get_language_string(user, "NS_NICKLIST_ACCESS_BOT")); + } + } + if(chanuser->user->flags & USERFLAG_ISIRCOP) { + if(j) + accessbufpos += sprintf(accessbuf+accessbufpos, ", "); + else { + accessbufpos += sprintf(accessbuf+accessbufpos, " ("); + j = 1; + } + accessbufpos += sprintf(accessbuf+accessbufpos, "%s", get_language_string(user, "NS_NICKLIST_ACCESS_OPER")); + } + if(j) + accessbufpos += sprintf(accessbuf+accessbufpos, ")"); content[2] = accessbuf; if(flags & NEONSERV_CMD_NICKLIST_FLAG_VISCOUNT) { sprintf(viscountbuf, "%d", chanuser->visCount); diff --git a/src/modules/NeonSpam.mod/bot_NeonSpam.c b/src/modules/NeonSpam.mod/bot_NeonSpam.c index 3e714ac..1fd3a6f 100644 --- a/src/modules/NeonSpam.mod/bot_NeonSpam.c +++ b/src/modules/NeonSpam.mod/bot_NeonSpam.c @@ -152,7 +152,7 @@ static void start_bots(int type) { MYSQL_ROW row; if(type == MODSTATE_STARTSTOP) { - printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); + printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind`, `secret` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); res = mysql_use(); while ((row = mysql_fetch_row(res)) != NULL) { @@ -160,6 +160,7 @@ static void start_bots(int type) { client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0); client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0); client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0); + client->flags |= (strcmp(row[11], "0") ? SOCKET_FLAG_SECRET_BOT : 0); client->flags |= SOCKET_FLAG_REQUEST_INVITE | SOCKET_FLAG_REQUEST_OP; client->botid = BOTID; client->clientid = atoi(row[7]); diff --git a/src/modules/global.mod/cmd_global_bots.c b/src/modules/global.mod/cmd_global_bots.c index 6af36a4..c4d345d 100644 --- a/src/modules/global.mod/cmd_global_bots.c +++ b/src/modules/global.mod/cmd_global_bots.c @@ -25,7 +25,7 @@ CMD_BIND(global_cmd_bots) { struct Table *table; MYSQL_RES *res, *res2; MYSQL_ROW row, row2; - printf_mysql_query("SELECT `active`, `nick`, `server`, `port`, `pass`, `botclass`, `textbot`, `queue`, `defaulttrigger`, `max_channels`, `register_priority`, `id` FROM `bots`"); + printf_mysql_query("SELECT `active`, `nick`, `server`, `port`, `pass`, `botclass`, `textbot`, `queue`, `defaulttrigger`, `max_channels`, `register_priority`, `id`, `secret` FROM `bots`"); res = mysql_use(); table = table_init(7, mysql_num_rows(res) + 1, 0); char *content[7]; @@ -54,6 +54,8 @@ CMD_BIND(global_cmd_bots) { botflags[flagspos++] = 't'; if(!strcmp(row[7], "1")) botflags[flagspos++] = 'q'; + if(!strcmp(row[12], "1")) + botflags[flagspos++] = 's'; botflags[flagspos] = '\0'; content[4] = botflags; printf_mysql_query("SELECT COUNT(*) FROM `bot_channels` WHERE `botid` = '%s'", row[11]); diff --git a/src/modules/global.mod/cmd_global_setbot.c b/src/modules/global.mod/cmd_global_setbot.c index 32ccce5..0017de2 100644 --- a/src/modules/global.mod/cmd_global_setbot.c +++ b/src/modules/global.mod/cmd_global_setbot.c @@ -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; diff --git a/src/mysqlConn.c b/src/mysqlConn.c index 6fe11e7..e766410 100644 --- a/src/mysqlConn.c +++ b/src/mysqlConn.c @@ -16,7 +16,7 @@ */ #include "mysqlConn.h" -#define DATABASE_VERSION "19" +#define DATABASE_VERSION "20" static void show_mysql_error();