use strict;
use vars qw($VERSION %IRSSI);

use Irssi;
$VERSION = '20021003';
%IRSSI = (
    authors     => 'Keith Ward',
    contact     => 'archer@priorityonline.net',
    name        => 'oops',
    description =>
	'turns \'ls\' in the beginning of a sent line into the names or whois commands
	Also fixes misc /win without a / based upon the original by niklas	
	',
    license => 'Public Domain',
);

sub send_text {

    #"send text", char *line, SERVER_REC, WI_ITEM_REC
    my ( $data, $server, $witem ) = @_;
    if ( $witem
        && ( $witem->{type} eq "CHANNEL" )
        && ( $data =~ /(^ls |^ls$)/ ) )
    {
        $witem->command("names $witem->{name}");
        Irssi::signal_stop();
    }
    if ($witem && ( $data =~ /(^\ \/win\ |^win\ )/ )) {
	    my @a;
	    @a = split(/win /, $data);
	    chomp($a[1]);
	    my $win = Irssi::window_find_refnum($a[1]);
	    if ($win) {
		    $win->set_active();
		    Irssi::signal_stop();
	    }
    }
    if ( $witem && ( $witem->{type} eq "QUERY" ) && ( $data =~ /(^ls |^ls$)/ ) )
    {
        $witem->command("whois $witem->{name}");
        Irssi::signal_stop();
    }
}

Irssi::signal_add 'send text' => 'send_text'

