X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2Fmodules%2Fstats.mod%2Fmodule.c;h=4780077c49739e35666736f293626eb1573df819;hp=ff5f8f6afb344de0ca14775ae62be0fe8c149662;hb=d29f5ec1df18f814aaaa96dcd86ed40b17821bb0;hpb=fc61be208ca6dbf2fd915591c8dc7e5ef5779891 diff --git a/src/modules/stats.mod/module.c b/src/modules/stats.mod/module.c index ff5f8f6..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, *bot2, *bot3; + 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 @@ -129,6 +135,7 @@ static TIMEQ_CALLBACK(stats_timer_callback) { int chanuser_count = getChanUserCount(); pkgpos += sprintf(pkgbuf + pkgpos, "%d %d\n", user_count, chanuser_count); } + pkgpos += sprintf(pkgbuf + pkgpos, "%lu\n", getStartTime()); pkgbuf[pkgpos] = 0; //send package #ifndef WIN32 @@ -143,20 +150,21 @@ static TIMEQ_CALLBACK(stats_timer_callback) { if (!host) return; si_other.sin_addr = *(struct in_addr*)host->h_addr; } + sendto(sock, pkgbuf, pkgpos, 0, &si_other, sizeof(si_other)); #else struct sockaddr_in si_other; int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock == -1) return; si_other.sin_family = AF_INET; si_other.sin_port = htons(STATS_UPDATE_PORT); - si_other.sin_addr.s_addr = inet_addr(client->host); + si_other.sin_addr.s_addr = inet_addr(STATS_UPDATE_HOST); if (si_other.sin_addr.s_addr == INADDR_NONE) { - struct hostent *host = gethostbyname(client->host); + struct hostent *host = gethostbyname(STATS_UPDATE_HOST); if(!host) return; memcpy(&(si_other.sin_addr), host->h_addr_list[0], 4); } + sendto(sock, pkgbuf, pkgpos, 0, (struct sockaddr *) &si_other, sizeof(si_other)); #endif - sendto(sock, pkgbuf, pkgpos, 0, &si_other, sizeof(si_other)); close(sock); }