diff options
Diffstat (limited to 'joinforward')
-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}); } |