use strict; use warnings; use Xchat qw( :all ); register( my $NAME = "KB Statusify", my $VERSION = "002", "Show kick and ban events in the status tab" ); my $PREFIX = "\cB$NAME\cB\t "; my $CMD = 'kb_statusify'; my $USAGE = "Usage: /$CMD , toggles kicks/bans in status tab"; my @hooks; Xchat::print "\cB$NAME $VERSION\cB by b0at (use /$CMD)"; hook_command($CMD, sub { my ($w, $e) = @_; my $switch = lc $w->[1]; if( $switch eq 'on' ) { push @hooks, hook_print( $_, \&statusify, { data => $_ } ) for # list of text events to go to the status window wholesale "Kick", "You Kicked", "Channel Ban", "Channel UnBan"; push @hooks, hook_print( "Raw Modes", \&statusify, {data=>"Raw Modes"} ); } elsif( $switch eq 'off' ) { unhook $_ for @hooks; @hooks = (); } elsif( $switch eq 'status' ) { Xchat::print( "$PREFIX Now ".( @hooks ? 'on' : 'off' ) ) } else { Xchat::print $USAGE; } return EAT_XCHAT; }, {help_text=>$USAGE}); command("$CMD on"); # default to on sub statusify { my ($values, $name) = @_; if( $name eq "Raw Modes" ) { # check raw modes for a +/-b my (undef, $modes) = split(' ', $values->[1], 3); return EAT_NONE unless $modes =~ /[+-]b/; } # avoid emit-hook loop return EAT_NONE unless ( caller )[0] eq 'main'; # get correct server context my $server = get_server_tab() or return EAT_NONE; hook_timer(0, sub{ # emit after this handler set_context( $server->{context} ); emit_print($name, @{$values}); return Xchat::REMOVE; }); return EAT_XCHAT; # hide from this context } sub get_server_tab { my $current = get_info('server'); for( get_list('channels') ) { if( $_->{type} == 1 # server tab type # on this server (can you find family server tab?) and $_->{server} eq $current ) { return $_; } } return; # no server tab; } __END__ b0at 13 June 2005 public domain