diff options
author | Wouter Coekaerts <coekie@irssi.org> | 2005-08-15 22:32:26 +0000 |
---|---|---|
committer | coekie <coekie@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2005-08-15 22:32:26 +0000 |
commit | fa6d77429a77330fc58b3b7ae35508a3740510b4 (patch) | |
tree | c38b67f0c14ab81bf82a8b53ff07bba68e971214 /scripts/splitlong.pl | |
parent | 74b4c072230c0ee12c72b3800d20290e8f391105 (diff) | |
download | irssi-fa6d77429a77330fc58b3b7ae35508a3740510b4.zip |
Update scripts to most recent version from scripts.irssi.org
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3931 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'scripts/splitlong.pl')
-rw-r--r-- | scripts/splitlong.pl | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/scripts/splitlong.pl b/scripts/splitlong.pl index 0df23426..e88840bc 100644 --- a/scripts/splitlong.pl +++ b/scripts/splitlong.pl @@ -1,52 +1,60 @@ # /set splitlong_max_length # specifies the maximum length of a msg, automatically chosen when set to "0" +# default: 0 +# +# /set splitlong_line_start +# /set splitlong_line_end +# self-explanatory +# defaults: "... ", " ..." ### use strict; use vars qw($VERSION %IRSSI); -#don't know which version exactly, probably even works with 0.7.98.4 use Irssi 20011001; -$VERSION = "0.17"; +$VERSION = "0.20"; %IRSSI = ( authors => "Bjoern \'fuchs\' Krombholz", contact => "bjkro\@gmx.de", name => "splitlong", licence => "Public Domain", description => "Split overlong PRIVMSGs to msgs with length allowed by ircd", - changed => "Wed Mar 8 03:03:10 CET 2002", - changes => "fixed some strange bug, depends on new switches to msg command (-nick|-channel)" + changed => "Wed Jun 25 00:17:00 CET 2003", + changes => "Actually the real 0.19 (now 0.20), but upload didn't work some month ago, target problem fixed..." ); sub sig_command_msg { - my ($cmd, $server, $winitem, $TEST) = @_; - my ($type, $target, $data) = $cmd =~ /^(\S*)\s(\S*)\s(.*)/; + my ($cmd, $server, $winitem) = @_; + my ( $param, $target,$data) = $cmd =~ /^(-\S*\s)?(\S*)\s(.*)/; + my $maxlength = Irssi::settings_get_int('splitlong_max_length'); + my $lstart = Irssi::settings_get_str('splitlong_line_start'); + my $lend = Irssi::settings_get_str('splitlong_line_end'); if ($maxlength == 0) { # 497 = 510 - length(":" . "!" . " PRIVMSG " . " :"); $maxlength = 497 - length($server->{nick} . $server->{userhost} . $target); } - my $maxlength2 = $maxlength - length("... "); + my $maxlength2 = $maxlength - length($lend); if (length($data) > ($maxlength)) { my @spltarr; while (length($data) > ($maxlength2)) { my $pos = rindex($data, " ", $maxlength2); - push @spltarr, substr($data, 0, ($pos < ($maxlength/10 + 4)) ? $maxlength2 : $pos) . " ..."; - - $data = "... " . substr($data, ($pos < ($maxlength/10 + 4)) ? $maxlength2 : $pos+1); + push @spltarr, substr($data, 0, ($pos < ($maxlength/10 + 4)) ? $maxlength2 : $pos) . $lend; + $data = $lstart . substr($data, ($pos < ($maxlength/10 + 4)) ? $maxlength2 : $pos+1); } push @spltarr, $data; foreach (@spltarr) { - Irssi::signal_emit("command msg", "$type $target $_", $server, $winitem); + Irssi::signal_emit("command msg", "$target $_", $server, $winitem); } Irssi::signal_stop(); } } Irssi::settings_add_int('misc', 'splitlong_max_length', 0); - +Irssi::settings_add_str('misc', 'splitlong_line_start', "... "); +Irssi::settings_add_str('misc', 'splitlong_line_end', " ..."); Irssi::command_bind('msg', 'sig_command_msg'); |