diff options
| author | Alexander Færøy | 2014-05-31 13:10:46 +0200 | 
|---|---|---|
| committer | Alexander Færøy | 2014-05-31 13:10:46 +0200 | 
| commit | 2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch) | |
| tree | 1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/autowrap.pl | |
| parent | 2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff) | |
| download | scripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2 | |
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/autowrap.pl')
| -rw-r--r-- | scripts/autowrap.pl | 38 | 
1 files changed, 38 insertions, 0 deletions
| diff --git a/scripts/autowrap.pl b/scripts/autowrap.pl new file mode 100644 index 0000000..c110c91 --- /dev/null +++ b/scripts/autowrap.pl @@ -0,0 +1,38 @@ +use strict;
 +use Text::Wrap;
 +
 +use vars qw($VERSION %IRSSI);
 +$VERSION = '2007031900';
 +%IRSSI = (
 +	authors		=> 'Bitt Faulk',
 +	contact		=> 'lxsfx3h02@sneakemail.com',
 +	name		=> 'autowrap',
 +	description	=> 'Automatically wraps long sent messages into multiple shorter sent messages',
 +	license		=> 'BSD',
 +	url		=> 'none',
 +	modules		=> 'Text::Wrap',
 +);
 +
 +sub event_send_text () {
 +	my ($line, $server_rec, $wi_item_rec) = @_;
 +	my @shortlines;
 +	if (length($line) <= 400) {
 +		return;
 +	} else {
 +		# split line, recreate multiple "send text" events
 +		local($Text::Wrap::columns) = 400;
 +		@shortlines = split(/\n/,wrap('','',$line));
 +		foreach (@shortlines) {
 +			if ($_ >= 400) {
 +				Irssi::print("autowrap: unable to split long line.  sent as-is");
 +				return;
 +			}
 +		}
 +		foreach (@shortlines) {
 +			Irssi::signal_emit('send text', $_,  $server_rec, $wi_item_rec);
 +		}
 +		Irssi::signal_stop();
 +	}
 +}
 +
 +Irssi::signal_add_first('send text', "event_send_text");
 | 
