use Irssi;

sub swap_default_command {
	my ($command, $server) = @_;
	if ($command =~ /^([0-9]+)(.*)$/) {
		my ($window_num) = $1;
		my ($suffix) = $2;
		if ($suffix =~ /^\s*$/) {	# trailing spaces allowed
			Irssi::command("window $window_num");
		} else {
			Irssi::print("Are you trying to switch to another window? Aborting unknown command.");
		}
		Irssi::signal_stop();
	}
}

Irssi::signal_add_first('default command', 'swap_default_command');
