added possibility to select a bot used for the statistics
authorpk910 <philipp@zoelle1.de>
Tue, 11 Dec 2012 23:58:26 +0000 (00:58 +0100)
committerpk910 <philipp@zoelle1.de>
Tue, 11 Dec 2012 23:58:26 +0000 (00:58 +0100)
neonserv.example.conf
src/modules/stats.mod/module.c

index 9bab950f9756f0bf283c697bf1d64c44ffdac200..b10eca7b2557175fd368f57e2b991d7186e3cb5e 100644 (file)
         "protected" = 0;
         "hide_networkname" = 0; //hide network name
         "hide_botnick" = 0; //hide bot nick, ident, host
         "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
     };
         "hide_chancount" = 0; //hide joined channel count
         "hide_usercount" = 0; //hide number of users the bot can see
     };
index c81e3a6b12a14ecbea820690013d8d19e3ade7aa..4780077c49739e35666736f293626eb1573df819 100644 (file)
@@ -94,21 +94,27 @@ static TIMEQ_CALLBACK(stats_timer_callback) {
     if(get_int_field(tmp))
         pkgpos += sprintf(pkgbuf + pkgpos, "*\n");
     else {
     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)) {
         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;
                 bot1 = bot;
-            else if((bot->flags & SOCKET_FLAG_PREFERRED))
+            else if(bot->botid == 1 && (bot->flags & SOCKET_FLAG_PREFERRED))
                 bot2 = bot;
                 bot2 = bot;
-            else
+            else if((bot->flags & SOCKET_FLAG_PREFERRED))
                 bot3 = bot;
                 bot3 = bot;
+            else
+                bot4 = bot;
         }
         if(bot1)
             bot = bot1;
         else if(bot2)
             bot = bot2;
         }
         if(bot1)
             bot = bot1;
         else if(bot2)
             bot = bot2;
-        else
+        else if(bot3)
             bot = 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
         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