1 # ho_stats_y.pl
 2 #
 3 # $Id: ho_stats_y.pl,v 1.6 2004/08/21 09:25:58 jvunder REL_0_3 $
 4 #
 5 # Part of the Hybrid Oper Script Collection
 6 #
 7 # Reformats /stats y output.
 8 #
 9 
10 use strict;
11 use vars qw($VERSION %IRSSI $SCRIPT_NAME);
12 
13 use Irssi;
14 use Irssi::Irc;
15 use HOSC::again;
16 use HOSC::again 'HOSC::Base';
17 use HOSC::again 'HOSC::Tools';
18 
19 # ---------------------------------------------------------------------
20 
21 $SCRIPT_NAME = "Stats Y reformatting";
22 ($VERSION) = '$Revision: 1.6 $' =~ / (\d+\.\d+) /;
23 %IRSSI = (
24     authors     => 'JamesOff',
25     contact     => 'james@jamesoff.net',
26     name        => 'stats_y',
27     description => 'Reformats stats y',
28     license     => 'GPL v2',
29     url         => 'http://www.jamesoff.net',
30 );
31 
32 # Script rewritten using formats by Garion.
33 
34 # 1218.34 Y opers 90 0 100 10485760 100.0 1000.0
35 # 1228.37 [@    Manic] Y:name:ping:max conns:total for class:sendq:max local: max global
36 
37 sub format_y_stats {
38     my ($server, $data, $nick, $address) = @_;
39 
40     my ($name, $ping, $max_conns, $total, $sendq, $local, $global, $cur) = 
41         $data =~ /\w+ Y ([\w-]+) (\d+) (\d+) (\d+) :?(\d+)\/?\d* ?(\S+)? ?(\S+)? ?(\d+)?/;
42     $sendq = int($sendq);
43 
44     if (defined $cur) {
45         Irssi::printformat(MSGLEVEL_CRAP, 'ho_stats_y_header_plus', 
46             $name, $cur);
47     } else {
48         Irssi::printformat(MSGLEVEL_CRAP, 'ho_stats_y_header', $name);
49     }
50     Irssi::printformat(MSGLEVEL_CRAP, 'ho_stats_y_pingconn', 
51         $ping, $max_conns);
52     Irssi::printformat(MSGLEVEL_CRAP, 'ho_stats_y_totalsendq', 
53         $total, $sendq);
54     if ($local) {
55         Irssi::printformat(MSGLEVEL_CRAP, 'ho_stats_y_localglobal', 
56             $local, $global);
57     }
58 }
59 
60 Irssi::theme_register([
61     'ho_stats_y_header',
62     'Class %Y$0%n',
63 
64     'ho_stats_y_header_plus',
65     'Class %Y$0%n (%G$1%n)',
66 
67     'ho_stats_y_pingconn',
68     '  Ping:      %_$[-6]0%_   Max conns: %_$[-6]1%_',
69 
70     'ho_stats_y_totalsendq',
71     '  Total:     %_$[-6]0%_   SendQ:  %_$[-9]1%_',
72 
73     'ho_stats_y_localglobal',
74     '  Max local: %_$[-6]0%_   global:    %_$[-6]1%_',
75 ]);
76 
77 
78 Irssi::signal_add("event 218", "format_y_stats");


syntax highlighted by Code2HTML, v. 0.9.1