From 03929dac2a29664878d2c971648a4fe1fb698462 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:19:02 +0200 Subject: Adding upstream version 20231031. Signed-off-by: Daniel Baumann --- scripts/follow.pl | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 scripts/follow.pl (limited to 'scripts/follow.pl') diff --git a/scripts/follow.pl b/scripts/follow.pl new file mode 100644 index 0000000..74274e4 --- /dev/null +++ b/scripts/follow.pl @@ -0,0 +1,72 @@ +# This is useful with irssiproxy, to monitor irc on a separate terminal, +# or if you just want to sit back and watch conversations. It just +# lets Irssi go to the active window whenever there's any activity. +# +# It was made to demonstrate Irssi's new Perl capabilities... +# +# Juerd + +use strict; +use vars qw($VERSION %IRSSI); + +use Irssi qw(command_bind active_win); +$VERSION = '1.10'; +%IRSSI = ( + authors => 'Juerd', + contact => 'juerd@juerd.nl', + name => 'Follower', + description => 'Automatically switch to active windows', + license => 'Public Domain', + url => 'http://juerd.nl/irssi/', + changed => 'Thu Mar 19 11:00 CET 2002', +); + +use Irssi 20011211 qw(signal_add command); + +sub sig_own { + my ($server, $msg, $target, $orig_target) = @_; + $server->print($target, 'Chatting with follow.pl loaded is very foolish.'); +} + +signal_add { + 'window hilight' => sub { command 'window goto active' }, + 'message own_public' => \&sig_own, + 'message own_private' => \&sig_own, + 'message irc own_action' => \&sig_own +}; + + + +=comment + + >> 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. + +=cut -- cgit v1.2.3