# this is a just an adaption of dispatch.pl script by Sebastian 'yath' Schmidt
# to say the line instead of sending to the server if it is not recognized as
# a command

use strict;
use warnings;
use Irssi qw( settings_get_bool active_win signal_stop 
              settings_add_bool signal_add_first );
use Irssi::Irc;
use vars qw($VERSION %IRSSI);

$VERSION = '0.5';
%IRSSI = (
    authors     => 'Mathieu Doidy',
    name        => 'say-unknown',
    description => 'just say the line if it starts by a / and is not recognized as a command',
    license     => 'GNU GPL v2',
    url         => 'http://irssi.roulaize.net',
    changed     => '10/10/2003'
);

sub event_default_command {
	my ($command, $server) = @_;
	return if (settings_get_bool("say-unknown_commands") == 0 || !$server);
	active_win->command("/say /$command");
	signal_stop();
}

settings_add_bool("misc", "say-unknown_commands", 1);
signal_add_first("default command", "event_default_command");
