All pastes #910367 Raw Edit

attempted irssi scripting

public text v1 · immutable
·published 2008-02-19 22:06 UTC
rendered paste body
#!/usr/bin/perl

use warnings;
use strict;

use Irssi;

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*}{/}) {
			Irssi::signal_continue(@_);
			return;
		}

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

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