X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FIRCParser.c;h=c22f595544a9622fd39e78b065974146f5a3896d;hb=410cb79dd46afc2da46d2ac3fc2010a77ccb9f0e;hp=c8d61d2917a4fcb5a5db601f74d78860bc40f337;hpb=8cdb9939ec5f90e931fce1be1aaab1baa206e205;p=NeonServV5.git diff --git a/src/IRCParser.c b/src/IRCParser.c index c8d61d2..c22f595 100644 --- a/src/IRCParser.c +++ b/src/IRCParser.c @@ -29,6 +29,9 @@ struct irc_cmd *irc_commands = NULL; static struct UserNode *registering_users = NULL; +int statistics_privmsg = 0; +int statistics_network_users = 0; +int statistics_network_channels = 0; static void parse_line(struct ClientSocket *client, char *line); static void register_irc_function(char *command, irc_cmd_t *func); @@ -323,6 +326,8 @@ static IRC_CMD(raw_privmsg) { if(argv[0][0] == '#') { //Channel message struct ChanNode *chan = getChanByName(argv[0]); if(chan && chan->chanbot == client->user) { + if(statistics_enabled) + statistics_privmsg++; if(argv[1][0] == '\001') { char *cmd = &argv[1][1]; char *text = strstr(cmd, " "); @@ -455,9 +460,41 @@ static IRC_CMD(raw_367) { return 1; } +static IRC_CMD(raw_251) { + if(argc < 2) return 0; + char *total_user_str = argv[1]; + char total_visible[20], total_invisible[20]; + int i, total_visible_pos = 0, total_invisible_pos = 0; + while(*total_user_str) { + if(*total_user_str == ' ') { + i++; + } else if(i == 2) { + if(total_visible_pos < 20) + total_visible[total_visible_pos++] = *total_user_str; + } else if(i == 5) { + if(total_invisible_pos < 20) + total_invisible[total_invisible_pos++] = *total_user_str; + } + total_user_str++; + } + total_visible[total_visible_pos] = '\0'; + total_invisible[total_invisible_pos] = '\0'; + statistics_network_users = atoi(total_visible) + atoi(total_invisible); + return 1; +} + +static IRC_CMD(raw_254) { + if(argc < 3) return 0; + statistics_network_channels = atoi(argv[1]); + statistics_update(); + return 1; +} + void init_parser() { //all the raws we receive... register_irc_function("001", raw_001); + register_irc_function("251", raw_251); + register_irc_function("254", raw_254); register_irc_function("324", raw_324); register_irc_function("367", raw_367); register_irc_function("INVITE", raw_invite);