1 # /set splitlong_max_length
2 # specifies the maximum length of a msg, automatically chosen when set to "0"
5 # /set splitlong_line_start
6 # /set splitlong_line_end
8 # defaults: "... ", " ..."
11 use vars qw($VERSION %IRSSI);
17 authors => "Bjoern \'fuchs\' Krombholz",
18 contact => "bjkro\@gmx.de",
20 licence => "Public Domain",
21 description => "Split overlong PRIVMSGs to msgs with length allowed by ircd",
22 changed => "Wed Jun 25 00:17:00 CET 2003",
23 changes => "Actually the real 0.19 (now 0.20), but upload didn't work some month ago, target problem fixed..."
27 my ($cmd, $server, $winitem) = @_;
28 my ( $param, $target,$data) = $cmd =~ /^(-\S*\s)?(\S*)\s(.*)/;
30 my $maxlength = Irssi::settings_get_int('splitlong_max_length');
31 my $lstart = Irssi::settings_get_str('splitlong_line_start');
32 my $lend = Irssi::settings_get_str('splitlong_line_end');
34 if ($maxlength == 0) {
35 # 497 = 510 - length(":" . "!" . " PRIVMSG " . " :");
36 $maxlength = 497 - length($server->{nick} . $server->{userhost} . $target);
38 my $maxlength2 = $maxlength - length($lend);
40 if (length($data) > ($maxlength)) {
43 while (length($data) > ($maxlength2)) {
44 my $pos = rindex($data, " ", $maxlength2);
45 push @spltarr, substr($data, 0, ($pos < ($maxlength/10 + 4)) ? $maxlength2 : $pos) . $lend;
46 $data = $lstart . substr($data, ($pos < ($maxlength/10 + 4)) ? $maxlength2 : $pos+1);
51 Irssi::signal_emit("command msg", "$target $_", $server, $winitem);
57 Irssi::settings_add_int('misc', 'splitlong_max_length', 0);
58 Irssi::settings_add_str('misc', 'splitlong_line_start', "... ");
59 Irssi::settings_add_str('misc', 'splitlong_line_end', " ...");
60 Irssi::command_bind('msg', 'sig_command_msg');