From 70af0ead69cb868ab37e7cdb58542c34aa5b5e6d Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Thu, 13 Jan 2011 07:57:10 +0000 Subject: added joinforward: a script to make sure when you try joining a forwaraded channel, all subsequent "/join #original" will point you at the new one (untested so far) --- joinforward/joinforward.pl | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 joinforward/joinforward.pl (limited to 'joinforward') diff --git a/joinforward/joinforward.pl b/joinforward/joinforward.pl new file mode 100644 index 0000000..0b685ba --- /dev/null +++ b/joinforward/joinforward.pl @@ -0,0 +1,54 @@ +use strict; +use warnings; + + +use Irssi; +use Irssi::Irc; +use Irssi::TextUI; + +use Data::Dumper; + + +our $VERSION = '0.1'; +our %IRSSI = ( + authors => 'shabble', + contact => 'shabble+irssi@metavore.org', + name => 'joinforward.pl', + description => '', + license => 'Public Domain', + ); + +my $forwards; + + +init(); + + +sub init() { + Irssi::signal_add('event 470', 'sig_470'); + Irssi::signal_add('event 473', 'sig_473'); +} + +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+(.*)$/) { + $forwards->{$1} = $2; + } +} + +sub sig_473 { + my ($server, $args, $sender) = @_; + #" 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 (exists $forwards->{$1}) { + $server->command("window goto " . $forwards->{$1}); + } + } + + + } +} -- cgit v1.2.3 From 581039cdd329b1ffc20eb8c434cd595c844c0803 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Thu, 13 Jan 2011 07:57:28 +0000 Subject: changed it to actually /join rather than /window goto. --- joinforward/joinforward.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'joinforward') diff --git a/joinforward/joinforward.pl b/joinforward/joinforward.pl index 0b685ba..26630b2 100644 --- a/joinforward/joinforward.pl +++ b/joinforward/joinforward.pl @@ -45,7 +45,7 @@ sub sig_473 { my $nick = quotemeta(Irssi::parse_special('$N')); if ($args =~ m/^$nick\s+(#.*?)\s+/) { if (exists $forwards->{$1}) { - $server->command("window goto " . $forwards->{$1}); + $server->command("join " . $forwards->{$1}); } } -- cgit v1.2.3 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(-) (limited to 'joinforward') 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