#!/usr/bin/perl

use warnings;
use strict;

use Irssi qw/signal_continue signal_stop active_server command signal_add/;

our $VERSION = "0.1";
our %IRSSI = (
	authors     => 'Urchlay',
	contact     => 'Urchlay on NewNet',
	name        => 'spaceslash',
	description => 'treat " /command" as though the space weren\'t there',
	license     => 'Same as Perl',
	url         => 'none',
);

sub sig_send_text {
	if($_[0] =~ s{^\s+/}{/}) {
		if($_[0] =~ s{/\s+/\s*}{/}) {
			signal_continue(@_);
			return;
		}

		signal_stop();
		my $s = active_server();
		if($s) {
			$s->command($_[0]);
		} else {
			command($_[0]);
		}
	}
}

signal_add("send text", \&sig_send_text);