Hi, I like to have a "there are x users on our IRC server" message on our website. Maybe there are others out there who might want to do the same, that's why I'm writing this mail. Till now I used php: $sock = fsockopen("localhost", 6667); fputs($sock, "nick IdleTest\r"); fputs($sock, "user idle . . :Idle-Test\r"); $result = fgets($sock, 4096); $result = fgets($sock, 4096); $result = fgets($sock, 4096); $result = fgets($sock, 4096); $result = fgets($sock, 4096); $result = fgets($sock, 4096); $n = sscanf($result, ":irc.server.url %d IdleTest :There are %d users %s", &$comid, &$users, &$rest); fputs($sock, "quit\r"); fclose($sock); $users--; //subtract the telnet connection echo "There are $users users on our IRC server";
It works but I found this solution unsatisfying so I changed the ngircd code and recompiled. I added/changed after line 365 BOOLEAN timeout; int alte_anz = -1; int anz_user = 0; FILE * fp_users;
start = time( NULL ); while(( ! NGIRCd_SignalQuit ) && ( ! NGIRCd_SignalRestart )) { anz_user = Client_UserCount(); if(anz_user != alte_anz) { fp_users = fopen("/srv/www/htdocs/chat/chat.users", "w"); if(fp_users != NULL) { fprintf(fp_users, "%i\n", anz_user); fclose(fp_users); } alte_anz = anz_user; }
timeout = TRUE; ... in conn.c after Check_Connections( ); so it will constantly write the number of users on the server to a file (in this case a file in the web directory) when the number changes. All the changes are between the timeout variable so you can easily find them. If you need more flexibility you could make the filename (and the whole piece of code) an additional option (I found no fitting free character for it (maybe -u filename?) and don't need the flexibility). BTW: Why is there --version and --help but not -v and -h? Hope you like it/can need it too.
Yours, Jens