3 # Copyright 2011 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, version 3 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 mkdir("/tmp/irc", 0775);
21 open (STATS, '>/tmp/irc/stats.txt');
22 open (CHANS, '>/tmp/irc/channels.txt');
23 my $irc = new Net::IRC;
24 my $conn = $irc->newconn(Nick => 'srv254-stats', Server => 'localhost');
26 $conn->add_global_handler('luserclient', \&luserclient);
27 $conn->add_global_handler('luserchannels', \&luserchannels);
28 $conn->add_global_handler('endofmotd', \&ask);
29 $conn->add_global_handler('list', \&list);
30 $conn->add_global_handler('listend', \&quit);
34 my($self, $event) = @_;
35 if(($event->args)[1] =~ /There are (\d+) users and (\d+) invisible on (\d+) servers/) {
36 # printf STATS "".(($event->args)[1])."\n";
37 printf STATS "clients.value ".($1 + $2 -1)."\n";
38 printf STATS "servers.value $3\n";
43 my($self, $event) = @_;
44 if(($event->args)[1] =~ /^(\d+)/) {
45 printf STATS "channels.value $1\n";
50 my($self, $event) = @_;
55 my($self, $event) = @_;
56 printf CHANS (($event->args)[1])." ".(($event->args)[2])." ".(($event->args)[3])."\n";
60 my($self, $event) = @_;