aboutsummaryrefslogtreecommitdiff
path: root/spaceslash.pl
blob: 73ea73aee913d2b394d9aed16d65ed757bd7c97a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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);