follow.pl

Code Index:

    >> use Irssi 20011211 qw(signal_add command);
    
    Loads the Irssi module, requiring at least version 20011211 and telling
    it to export signal_add() and command() into our package.
    This kind of version checking came available in the 20011208-snapshot.
    Having te Irssi:: subs exported came available in the 20011211-snapshot.
    
    >> sub sig_own
    
    Warns the user: chatting while having windows switch all the time is
    foolish, because your text gets sent to whatever window has the focus
    when you press enter.
    
    >> signal_add
    
    This was exported into our package, so we can use signal_add() without the
    "Irssi::" prefix. Since the 20011207 snapshot, you can add multiple signals
    using a single add_signal(). If you want to do so, use a hash reference
    (either { foo => bar, foo2 => bar2 } or \%hash).
    
    >> sub { ... }
    >> \&subname
    
    These are references to subs(code). The first one is a reference to an
    anonymous sub, the second one refers to a named one. Anonymous code
    references allow for easy placement of oneliners :)
    Irssi understands codereferences since the 20011207 snapshot.
    Using references is better than having a string with the function name,
    imho.

   1 # This is useful with irssiproxy, to monitor irc on a separate terminal,
   2 # or if you just want to sit back and watch conversations. It just
   3 # lets Irssi go to the active window whenever there's any activity.
   4 # 
   5 # It was made to demonstrate Irssi's new Perl capabilities...
   6 # 
   7 # Juerd <juerd@juerd.nl>
   8 
   9 use strict;
  10 use vars qw($VERSION %IRSSI);
  11 
  12 use Irssi qw(command_bind active_win);
  13 $VERSION = '1.10';
  14 %IRSSI = (
  15     authors     => 'Juerd',
  16     contact     => 'juerd@juerd.nl',
  17     name        => 'Follower',
  18     description => 'Automatically switch to active windows',
  19     license     => 'Public Domain',
  20     url         => 'http://juerd.nl/irssi/',
  21     changed     => 'Thu Mar 19 11:00 CET 2002',
  22 );
  23 
  24 use Irssi 20011211 qw(signal_add command);
  25 
  26 sub sig_own {
  27     my ($server, $msg, $target, $orig_target) = @_;
  28     $server->print($target, 'Chatting with follow.pl loaded is very foolish.');
  29 }
  30 
  31 signal_add {
  32 	    'window hilight'         => sub { command 'window goto active' },
  33 	    'message own_public'     => \&sig_own,
  34 	    'message own_private'    => \&sig_own,
  35 	    'message irc own_action' => \&sig_own
  36 };
  37 
  38 
  39