# Copyright (C) David Leadbeater (dgl), 29-07-03, GNU GPLv2
# Irssi script to remove excess spaces from sent lines

my $cmdchar = '/';
setcmdchars();

Irssi::signal_add('setup changed', \&setcmdchars);
Irssi::signal_add_first('send command',\&snd_cmd);

sub snd_cmd {
   my($command, $server, $wi) = @_;

   $command =~ s/\s+$// unless $command =~ /^\Q$cmdchar/;

   Irssi::signal_continue($command, $server, $wi);
}

sub setcmdchars {
   $cmdchar = substr(Irssi::settings_get_str('cmdchars'), 0, 1);
   $cmdchar ||= '/';
}

