From 38fc24c53dab0d594f5094908cd294c7a22d7985 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Tue, 18 Jan 2011 00:18:42 +0000 Subject: try to keep track of forwarded channels (#foo -> ##foo) and /j takes you to teh right place. --- joinforward/joinforward.pl | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/joinforward/joinforward.pl b/joinforward/joinforward.pl index 26630b2..1acd72a 100644 --- a/joinforward/joinforward.pl +++ b/joinforward/joinforward.pl @@ -24,26 +24,37 @@ my $forwards; init(); -sub init() { - Irssi::signal_add('event 470', 'sig_470'); - Irssi::signal_add('event 473', 'sig_473'); +sub init { + Irssi::signal_add('event 470', 'sig_470'); # forwarding (on freenode, anhywya) + Irssi::signal_add('event 473', 'sig_473'); # notinvited. + # or better to just overload /join? + Irssi::command_bind('fwdlist', 'cmd_fwdlist'); + print "Joinforward loaded"; +} + +sub cmd_fwdlist { + print "Known Forwards:"; + foreach my $fwd (sort keys %$forwards) { + print "$fwd -> " . $forwards->{$fwd}; + } } sub sig_470 { my ($server, $args, $sender) = @_; #'shibble #mac ##mac :Forwarding to another channel', - my $nick = quotemeta(Irssi::parse_special('$N')); - if ($args =~ m/^$nick (#.*?)\s+(#.*?)\s+(.*)$/) { + print "Sig 470: $args"; + if ($args =~ m/(#.*?)\s+(#.*?)/) { $forwards->{$1} = $2; + print "adding $1 -> $2"; } } sub sig_473 { my ($server, $args, $sender) = @_; + print "Sig 473: $args"; #" shibble #mac :Cannot join channel (+i) - you must be invited'," if ($server->{version} =~ m/ircd-seven/) { # assume freenode - my $nick = quotemeta(Irssi::parse_special('$N')); - if ($args =~ m/^$nick\s+(#.*?)\s+/) { + if ($args =~ m/^(#.*?)\s+/) { if (exists $forwards->{$1}) { $server->command("join " . $forwards->{$1}); } -- cgit v1.2.3