diff options
author | Tom Feist <shabble@metavore.org> | 2011-01-18 00:18:42 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2011-01-18 00:18:42 +0000 |
commit | 38fc24c53dab0d594f5094908cd294c7a22d7985 (patch) | |
tree | c798ee8cf286eca7b8e81309230625577e47bf73 /joinforward/joinforward.pl | |
parent | joinforward/joinforward: a first pass at a script which observes redirection (diff) | |
download | irssi-scripts-38fc24c53dab0d594f5094908cd294c7a22d7985.tar.gz irssi-scripts-38fc24c53dab0d594f5094908cd294c7a22d7985.zip |
try to keep track of forwarded channels (#foo -> ##foo) and /j takes you to teh
right place.
Diffstat (limited to '')
-rw-r--r-- | joinforward/joinforward.pl | 25 |
1 files 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}); } |