From: pk910 Date: Tue, 11 Dec 2012 23:58:26 +0000 (+0100) Subject: added possibility to select a bot used for the statistics X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=commitdiff_plain;h=d29f5ec1df18f814aaaa96dcd86ed40b17821bb0 added possibility to select a bot used for the statistics --- diff --git a/neonserv.example.conf b/neonserv.example.conf index 9bab950..b10eca7 100644 --- a/neonserv.example.conf +++ b/neonserv.example.conf @@ -125,6 +125,7 @@ "protected" = 0; "hide_networkname" = 0; //hide network name "hide_botnick" = 0; //hide bot nick, ident, host + // "use_bot" = "BotNick"; //use this bot for the statistics "hide_chancount" = 0; //hide joined channel count "hide_usercount" = 0; //hide number of users the bot can see }; diff --git a/src/modules/stats.mod/module.c b/src/modules/stats.mod/module.c index c81e3a6..4780077 100644 --- a/src/modules/stats.mod/module.c +++ b/src/modules/stats.mod/module.c @@ -94,21 +94,27 @@ static TIMEQ_CALLBACK(stats_timer_callback) { if(get_int_field(tmp)) pkgpos += sprintf(pkgbuf + pkgpos, "*\n"); else { - struct ClientSocket *bot, *bot1 = NULL, *bot2 = NULL, *bot3 = NULL; + sprintf(tmp, "modules/%s/use_bot", modname); + char *botname = get_string_field(tmp); + struct ClientSocket *bot, *bot1 = NULL, *bot2 = NULL, *bot3 = NULL, *bot4 = NULL; for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { - if(bot->botid == 1 && (bot->flags & SOCKET_FLAG_PREFERRED)) + if(botname && !stricmp(bot->nick, botname)) bot1 = bot; - else if((bot->flags & SOCKET_FLAG_PREFERRED)) + else if(bot->botid == 1 && (bot->flags & SOCKET_FLAG_PREFERRED)) bot2 = bot; - else + else if((bot->flags & SOCKET_FLAG_PREFERRED)) bot3 = bot; + else + bot4 = bot; } if(bot1) bot = bot1; else if(bot2) bot = bot2; - else + else if(bot3) bot = bot3; + else + bot = bot4; if(bot) { pkgpos += sprintf(pkgbuf + pkgpos, "%s!%s@%s %d\n", (bot->user ? bot->user->nick : "*"), (bot->user ? bot->user->ident : "*"), (bot->host ? bot->host : "*"), bot->port); } else