#!/usr/bin/perl -w

use Irssi::Irc;
use Irssi;

$VERSION = "0.0.1";
%IRSSI = (
	authors => 'Ge0rG',
	contact => 'none',
	name => 'trailspace',
	description => 'removes trailing spaces from incoming and outgoing text messages',
	license => 'GNU GPL',
	url => 'none',
);

Irssi::signal_add_first(
    "message public" => sub {
        return unless $_[1] =~ s/ +$//g;
        #$_[1] .= "<sp>";
        Irssi::signal_emit("message public", @_);
        Irssi::signal_stop();
    }
);

Irssi::signal_add_first(
    "message private" => sub {
        return unless $_[1] =~ s/ +$//g;
        #$_[1] .= "<sp>";
        Irssi::signal_emit("message private", @_);
        Irssi::signal_stop();
    }
);

Irssi::signal_add_first(
    "message part" => sub {
        return unless $_[4] =~ s/ +$//g;
        #$_[1] .= "<sp>";
        Irssi::signal_emit("message part", @_);
        Irssi::signal_stop();
    }
);

Irssi::signal_add_first(
    "send text" => sub {
        return unless $_[0] =~ s/ +$//g;
        Irssi::signal_emit("send text", @_);
        Irssi::signal_stop();
    }
);

