use Irssi 20020101.0001 (); use strict; use Irssi; use vars qw($VERSION %IRSSI); $VERSION = "0.1"; %IRSSI = ( authors => 'dme', contact => 'dme@dme.org', name => 'jlo', description => 'Joiners and leavers in the status bar.', license => 'GNU GPLv2', url => 'http://www.dme.org' ); my (%jlo); # I got annoyed that in channels like #emacs, #xen or #ubuntu the # majority of the traffic was notices about people arriving and # leaving. In smaller channels it's nice to be able to see when a # friend arrives or disappears. This script is the solution. # # The script adds a new statusbar element called "joiners_leavers", # which is a (short) history of people who arrive and leave the # channel. # # To use the script: # /script load jlo # /statusbar window add joiners_leavers -after act # # For best effect, you need to set the join, part and quit messages to # empty in your configuration. Something like: # # formats = { # "fe-common/core" = { # join = ""; # part = ""; # quit = ""; # }; # }; # # There are probably a variety of interesting things to do here, # including flexible formatting (colour?), using an entire status # line, etc. # # Please send feedback, complaints or improvements. sub joiners_leavers { my ($item, $get_size_only) = @_; my ($wi, $s, $c); $wi = !Irssi::active_win() ? undef : Irssi::active_win()->{active}; if(!ref $wi || $wi->{type} ne "CHANNEL") { # only works on channels return; } $s = $wi->{server}->{address}; $c = $wi->{name}; $item->default_handler($get_size_only, $jlo{$s.$c}, undef, 1); } sub changed { my ($server, $channel, $nick, $direction) = @_; $server = $server->{address}; $jlo{$server.$channel} = substr($direction.$nick." ".$jlo{$server.$channel}, 0, 80);; # this seems heavyweight, but there doesn't seem to be another way # to force just the statusbar to update. Irssi::command('redraw'); } # "message join", SERVER_REC, char *channel, char *nick, char *address sub joiner { my ($server, $channel, $nick, $address) = @_; changed($server, $channel, $nick, "+"); } # "message part", SERVER_REC, char *channel, char *nick, char *address, char *reasonsub sub leaver { my ($server, $channel, $nick, $address, $reason) = @_; changed($server, $channel, $nick, "-"); } # "message quit", SERVER_REC, char *nick, char *address, char *reason sub quitter { my ($server, $nick, $address, $reason) = @_; foreach (Irssi::Server::channels($server)) { changed($server, $_->{name}, $nick, "!"); } } Irssi::statusbar_item_register('joiners_leavers', '$0', 'joiners_leavers'); Irssi::signal_add('message join', 'joiner'); Irssi::signal_add('message part', 'leaver'); Irssi::signal_add('message quit', 'quitter');