diff options
| author | Alexander Færøy | 2014-05-31 13:10:46 +0200 |
|---|---|---|
| committer | Alexander Færøy | 2014-05-31 13:10:46 +0200 |
| commit | 2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch) | |
| tree | 1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/netswitch.pl | |
| parent | 2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff) | |
| download | scripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2 | |
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/netswitch.pl')
| -rw-r--r-- | scripts/netswitch.pl | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/netswitch.pl b/scripts/netswitch.pl new file mode 100644 index 0000000..01f499a --- /dev/null +++ b/scripts/netswitch.pl @@ -0,0 +1,43 @@ +use strict;
+use Irssi;
+use Irssi::Irc;
+
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.0.0";
+%IRSSI = (
+ authors => 'Roeland Nieuwenhuis',
+ contact => 'irc@trancer.nl',
+ name => 'netswitch',
+ description => 'Set all windows not bound to a network to a specified network.',
+ license => 'BSD',
+ url => 'http://trancer.nl',
+ changed => 'Mon May 24 2010',
+);
+
+sub cmd_netswitch {
+ my $netname = shift;
+ my $destserv;
+
+ if ($netname eq "") {
+ $destserv = Irssi::active_server() if $netname eq "";
+ } else {
+ my $cn = Irssi::server_find_tag($netname);
+ unless ($cn) {
+ Irssi::active_win->print("Unknown network: $netname");
+ return;
+ }
+ $destserv = $cn;
+ }
+
+ for my $win (Irssi::windows()) {
+ for my $witem($win->items or $win) {
+ $witem->change_server($destserv) unless defined $witem->{'type'} && ($witem->{'type'} eq "CHANNEL" || $witem->{'type'} eq "QUERY");
+ }
+ }
+ Irssi::active_win->print("All windows changed network to $destserv->{'tag'}");
+}
+
+Irssi::active_win->print("%GNetswitcher $VERSION loaded%n. Use /netswitch <netname> to switch all windows that are not CHANNEL or QUERY to <netname>. If you call /netswitch without arguments it will switch to the network of the active window.");
+
+Irssi::command_bind("netswitch", "cmd_netswitch");
|
