1
0
mirror of https://github.com/irssi/irssi.git synced 2024-06-09 06:20:45 +00:00

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
This commit is contained in:
Wouter Coekaerts 2005-08-15 22:32:26 +00:00 committed by coekie
parent 74b4c07223
commit fa6d77429a
3 changed files with 416 additions and 137 deletions

View File

@ -1,28 +1,28 @@
# Highly experimental. use it at your own risk.
use strict;
use vars qw($VERSION %IRSSI);
use Irssi 20020120; # 21/01/2002, 18:00 cvs commit
# at http://juerd.nl/irssi/temporary.deb for debian sid
$VERSION = "2.06";
use Irssi qw(command signal_add signal_add_first active_win
settings_get_str settings_get_bool channels windows
settings_add_str settings_add_bool get_irssi_dir
window_find_refnum signal_stop);
$VERSION = '2.13';
%IRSSI = (
authors => "Juerd",
contact => "juerd\@juerd.nl",
name => "Scroll buffer thingy",
description => "Saves the buffer for /upgrade",
license => "Public Domain",
url => "http://juerd.nl/irssi/",
changed => "Tue Feb 28 16:22 CET 2002",
changes => "+logging workaround (untested, suggested by darix)"
authors => 'Juerd',
contact => 'juerd@juerd.nl',
name => 'Scroll buffer restorer',
description => 'Saves the buffer for /upgrade, so that no information is lost',
license => 'Public Domain',
url => 'http://juerd.nl/irssi/',
changed => 'Mon May 13 19:41 CET 2002',
changes => 'Severe formatting bug removed * oops, I ' .
'exposed Irssi to ircII foolishness * sorry ' .
'** removed logging stuff (this is a fix)',
note1 => 'This script HAS TO BE in your scripts/autorun!',
note2 => 'Perl support must be static or in startup',
);
# Saves the Irssi scrollbuffer and displays it after /UPGADEing.
# Additionaly saves your settings and layout.
# HAS TO BE in $irssidir/scripts/autorun (don't forget to load the
# perl module if you have to... put /load perl in $irssidir/startup)
# Q: How can I get a very smooth and clean upgrade?
#
# A: /set -clear upgrade_separator
# /set upgrade_suppress_join ON (default)
# /set channel_sync OFF
@ -31,6 +31,7 @@ $VERSION = "2.06";
# Q: Is it possible to save my command history?
# Q: Can I prevent the screen from blinking?
# Q: Can you make it faster?
#
# A: Probably not, but if you can do it, tell me how.
use Irssi::TextUI;
@ -39,94 +40,83 @@ use Data::Dumper;
my %suppress;
sub upgrade {
open (BUF, sprintf('>%s/scrollbuffer', Irssi::get_irssi_dir()));
my $logging = Irssi::settings_get_bool('autolog') || 0;
print BUF join("\0", map $_->{server}->{address} . $_->{name}, Irssi::channels()), "\n";
print BUF "$logging\n";
for my $window (Irssi::windows()){
open BUF, sprintf('>%s/scrollbuffer', get_irssi_dir) or die $!;
print BUF join("\0", map $_->{server}->{address} . $_->{name}, channels), "\n";
for my $window (windows) {
next unless defined $window;
next if $window->{name} eq 'status';
my $view = $window->view();
my $line = $view->get_lines();
my $view = $window->view;
my $line = $view->get_lines;
my $lines = 0;
my $buf = '';
if (defined $line){
{
$buf .= $line->get_text(1) . "\n";
$line = $line->next();
$line = $line->next;
$lines++;
redo if defined $line;
}
}
printf BUF ("%s:%s\n%s", $window->{refnum}, $lines, $buf);
printf BUF "%s:%s\n%s", $window->{refnum}, $lines, $buf;
}
close BUF;
unlink sprintf("%s/sessionconfig", Irssi::get_irssi_dir());
Irssi::command('/layout save');
Irssi::command('/set autolog off') if $logging;
Irssi::command('/save');
unlink sprintf("%s/sessionconfig", get_irssi_dir);
command 'layout save';
command 'save';
}
sub restore {
open (BUF, sprintf('<%s/scrollbuffer', Irssi::get_irssi_dir()));
open BUF, sprintf('<%s/scrollbuffer', get_irssi_dir) or die $!;
my @suppress = split /\0/, <BUF>;
my $logging = <BUF>;
chomp $logging;
if (Irssi::settings_get_bool('upgrade_suppress_join')) {
if (settings_get_bool 'upgrade_suppress_join') {
chomp $suppress[-1];
@suppress{@suppress} = (2) x @suppress;
}
Irssi::active_win()->command('/^window scroll off');
active_win->command('^window scroll off');
while (my $bla = <BUF>){
chomp $bla;
my ($refnum, $lines) = split /:/, $bla;
next unless $lines;
my $window = Irssi::window_find_refnum($refnum);
my $window = window_find_refnum $refnum;
unless (defined $window){
<BUF> for 1..$lines;
Irssi::print("no $refnum?");
next;
}
my $view = $window->view();
my $view = $window->view;
$view->remove_all_lines();
$view->redraw();
my $buf = '';
$buf .= <BUF> for 1..$lines;
my $sep = Irssi::settings_get_str('upgrade_separator');
my $sep = settings_get_str 'upgrade_separator';
$sep .= "\n" if $sep ne '';
$window->gui_printtext_after(undef, MSGLEVEL_CLIENTNOTICE, "$buf\cO$sep");
$view->redraw();
}
Irssi::active_win()->command('/^window scroll on');
Irssi::active_win()->command('/^scrollback end');
Irssi::command('/set autolog on') if $logging;
active_win->command('^window scroll on');
active_win->command('^scrollback end');
}
sub suppress {
my ($first, $second) = @_;
return unless scalar keys %suppress
and Irssi::settings_get_bool('upgrade_suppress_join');
return
unless scalar keys %suppress
and settings_get_bool 'upgrade_suppress_join';
my $key = $first->{address} .
(grep { (s/^://, /^[#!+&]/) } split ' ', $second)[0];
(grep { (s/^://, /^[#!+&]/) } split ' ', $second)[0];
if (exists $suppress{$key} and $suppress{$key}--) {
Irssi::signal_stop();
signal_stop();
delete $suppress{$key} unless $suppress{$key};
}
}
# Don't use these :P they're for testing
#Irssi::command_bind('emulate_upgrade', 'upgrade');
#Irssi::command_bind('emulate_restore', 'restore');
settings_add_str 'buffer', 'upgrade_separator' => '=Upgrade=';
settings_add_bool 'buffer', 'upgrade_suppress_join' => 1;
Irssi::settings_add_str('buffer', 'upgrade_separator', '=Upgrade=');
Irssi::settings_add_bool('buffer', 'upgrade_suppress_join', 1);
signal_add_first 'session save' => 'upgrade';
signal_add_first 'session restore' => 'restore';
signal_add 'event 366' => 'suppress';
signal_add 'event join' => 'suppress';
Irssi::signal_add_first('session save', 'upgrade');
Irssi::signal_add_first('session restore', 'restore');
Irssi::signal_add('event 366', 'suppress');
Irssi::signal_add('event join', 'suppress');
unless (-f sprintf('%s/scripts/autorun/buf.pl', Irssi::get_irssi_dir())) {
unless (-f sprintf('%s/scripts/autorun/buf.pl', get_irssi_dir)) {
Irssi::print('PUT THIS SCRIPT IN ~/.irssi/scripts/autorun/ BEFORE /UPGRADING!!');
Irssi::print('And don\'t forget to /load perl using ~/.irssi/autostart');
}

View File

@ -1,93 +1,254 @@
# $Id: mail.pl,v 1.1 2002/03/10 21:33:46 cras Exp $
$VERSION = "2.0";
$VERSION = "2.92";
%IRSSI = (
authors => "Matti Hiljanen, Timo Sirainen",
contact => "matti\@hiljanen.com, tss\@iki.fi",
authors => "Timo Sirainen, Matti Hiljanen, Joost Vunderink, Bart Matthaei",
contact => "tss\@iki.fi, matti\@hiljanen.com, joost\@carnique.nl, bart\@dreamflow.nl",
name => "mail",
description => "Mail counter statusbar item with maildir support",
description => "Fully customizable mail counter statusbar item with multiple mailbox and multiple Maildir support",
license => "Public Domain",
url => "http://matin.maapallo.org/softa/irssi, http://irssi.org, http://scripts.irssi.de",
url => "http://irssi.org, http://scripts.irssi.de",
);
# Mail counter statusbar item
# for irssi 0.8.1 by Timo Sirainen
#
# Maildir support added by Matti Hiljanen
#
# /SET maildir_mode - ON/OFF
# /SET mail_file - specifies mbox file/Maildir location
# /SET mail_refresh_time - in seconds, how often to check for new mail
# /SET mail_ext_program - specify external mail checker program
# Multiple Maildir/mbox and customization support added by Joost Vunderink
# OLD mailtreatment switch added by Bart Matthaei.
# Improved some regexps in maildirmode by Bart Matthaei.
# Maildirmode regexps (hopefully) fixed for good by Matti Hiljanen.
#
# You can add any number of mailboxes or Maildirs to watch for new mail in.
# Give them any name and <name>:<count> will appear in your mail
# statusbar item, where <count> is the number of unread messages.
# If only 1 mailbox/Maildir is defined, the statusbar item will have the
# familiar form [Mail: <count>].
# If you set mail_show_message to ON, irssi will print a message in the
# active window whenever new mail arrives.
#
# Check /mailbox help for help.
use Irssi::TextUI;
my $maildirmode = 0; # maildir=1, file(spools)=0
my $old_is_not_new = 0;
my $extprog;
my ($last_refresh_time, $refresh_tag);
# for mbox caching
my $last_size, $last_mtime, $last_mailcount, $last_mode;
sub mbox_count {
my $mailfile = shift;
my $count = 0;
my $maildirmode=Irssi::settings_get_bool('maildir_mode');
if ($extprog ne "") {
$count = `$extprog`;
chomp $count;
} else {
if (!$maildirmode) {
if (-f $mailfile) {
my @stat = stat($mailfile);
my $size = $stat[7];
my $mtime = $stat[9];
# list of mailboxes
my %mailboxes = ();
my %new_mails_in_box = ();
my $nummailboxes = 0;
# if the file hasn't changed, get the count from cache
return $last_mailcount if ($last_size == $size && $last_mtime == $mtime);
$last_size = $size;
$last_mtime = $mtime;
# the string to be stored in Irssi's mail_mailboxes setting
my $mailboxsetting = "";
my $f = gensym;
return 0 if (!open($f, $mailfile));
while (<$f>) {
$count++ if (/^From /);
$count-- if (/^Subject: .*FOLDER INTERNAL DATA/);
}
close($f);
$last_mailcount = $count;
}
} else {
opendir(DIR, "$mailfile/cur") or return 0;
while (defined(my $file = readdir(DIR))) {
next if $file =~ /S/ || $file =~ /^(.|..)$/;
$count++;
}
closedir(DIR);
opendir(DIR, "$mailfile/new") or return 0;
while (defined(my $file = readdir(DIR))) {
next if $file =~ /^(.|..)$/;
$count++;
}
closedir(DIR);
}
}
return $count;
sub cmd_print_help {
Irssi::print(
"MAILBOX ADD <num> <file|dir>\n".
"MAILBOX DEL <num>\n".
"MAILBOX SHOW\n\n".
"Statusbar item to keep track of how many (new) emails there are in ".
"each of your mailboxes/Maildirs.\n\n".
"/MAILBOX ADD <name> <file|dir>\n".
" - Adds a mailbox or a Maildir to the list.\n".
"/MAILBOX DEL <name>\n".
" - Removes mailbox or Maildir named <name> from the list.\n".
"/MAILBOX SHOW\n".
" - Shows a list of the defined mailboxes.\n\n".
"Use the following commands to change the behaviour:\n\n".
"/SET MAILDIRMODE on|off\n".
" - If maildirmode is on, the mailboxes in the list are assumed to be ".
"directories. Otherwise they are assumed to be spool files.\n".
" Default: off.\n".
"/SET MAIL_OLDNOTNEW on|off\n".
" - If switched on, mail marked als \"OLD\" will not be treated as new.\n".
" Default: off.\n".
"/SET MAIL_EXT_PROGRAM <prog>\n".
" - <prog> will be used to check for mail.\n".
"/SET MAIL_REFRESH_TIME <num>\n".
" - Sets the time between checks to <num> seconds.\n Default: 60.\n".
"/SET MAIL_SHOW_MESSAGE on|off\n".
" - If this is on, a message will be printed in the active window ".
"whenever new email is received.\n Default: off.\n".
"/SET MAIL_SHOW_ONLY_UNREAD on|off\n".
" - If you don't want to see a mailbox if it does not contain any new ".
"mail, set this to on.\n Default: on.\n" .
"/SET MAIL_SEPARATOR <char>\n".
" - Sets the character to be printed between each mailbox.\n".
" The default is a comma.\n".
"/SET MAIL_FORMAT <format>\n".
" - Sets the format of each mailbox.\n".
" Allowed variables:\n".
" %%n = mailbox name\n".
" %%u = number of unread mail\n".
" %%r = number of read mail\n".
" %%t = total amount of mail\n".
" The default format is %%n:%%u/%%t.\n".
"\nSee also: STATUSBAR"
,MSGLEVEL_CRAP);
}
sub mbox_count {
my $mailfile = shift;
my $unread = 0;
my $read = 0;
my $maildirmode=Irssi::settings_get_bool('maildir_mode');
my $old_is_not_new=Irssi::settings_get_bool('mail_oldnotnew');
if ($extprog ne "") {
$total = `$extprog`;
chomp $unread;
} else {
if (!$maildirmode) {
if (-f $mailfile) {
my @stat = stat($mailfile);
my $size = $stat[7];
my $mtime = $stat[9];
# if the file hasn't changed, get the count from cache
return $last_mailcount if ($last_size == $size && $last_mtime == $mtime);
$last_size = $size;
$last_mtime = $mtime;
my $f = gensym;
return 0 if (!open($f, $mailfile));
# count new mails only
my $internal_removed = 0;
while (<$f>) {
$unread++ if (/^From /);
if(!$old_is_not_new) {
$unread-- if (/^Status: R/);
} else {
$unread-- if (/^Status: [OR]/);
}
$read++ if (/^From /);
# Remove folder internal data, but only once
if (/^Subject: .*FOLDER INTERNAL DATA/) {
if ($internal_removed == 0) {
$internal_removed = 1;
$read--;
$unread--;
}
}
}
close($f);
}
} else {
opendir(DIR, "$mailfile/cur") or return 0;
while (defined(my $file = readdir(DIR))) {
next if $file =~ /^(.|..)$/;
# Maildir flags: http://cr.yp.to/proto/maildir.html
# My old regexps were useless if the MUA added any
# non-default flags -qvr
#
# deleted mail
next if $file =~ /\:.*?T.*?$/;
if($old_is_not_new) {
# when mail gets moved from new to cur it's name _always_
# changes from uniq to uniq:info, even when it's still not
# read. I assume "old mail" means mail which hasn't been read
# yet but it has been "acknowledged" by the user. (it's been
# moved to cur) -qvr
if ($file =~ /\:.*?$/) {
$read++;
next;
}
} else {
if ($file =~ /\:.*?S.*?$/) {
$read++;
next;
}
}
$unread++;
}
closedir(DIR);
opendir(DIR, "$mailfile/new") or return 0;
while (defined(my $file = readdir(DIR))) {
next if $file =~ /^(.|..)$/;
$unread++;
}
closedir(DIR);
}
}
if ($unread eq "" || $unread < 0) {
$unread = 0;
}
if ($read eq "" || $read < 0) {
$read = 0;
}
$last_mailcount = $unread;
return ($unread, $read);
}
# Checks for mail and sets the statusbar item to the right string.
# Also shows a message in the active window if that setting is set.
sub mail {
my ($item, $get_size_only) = @_;
$count = mbox_count(Irssi::settings_get_str('mail_file'));
if ($count == 0) {
my $result;
my $format = Irssi::settings_get_str('mail_format');
my $unread = 0;
my $read = 0;
my $total = 0;
# check all mailboxes for new email
foreach $name (keys(%mailboxes)) {
my $box = $mailboxes{$name};
# replace "~/" at the beginning by the user's home dir
$box =~ s/^~\//$ENV{'HOME'}\//;
($unread, $read) = mbox_count($box);
$unread = "0" if ($unread eq "");
$read = "0" if ($read eq "");
$total = $unread + $read;
$total = "0" if ($total eq "");
next if (Irssi::settings_get_bool('mail_show_only_unread') && $unread == 0);
if ($total eq "") { $total = 0; }
if (length($result) > 0) {
$result .= Irssi::settings_get_str('mail_separator');
}
my $string = $format;
$string =~ s/%n/$name/;
$string =~ s/%u/$unread/;
$string =~ s/%r/$read/;
$string =~ s/%t/$total/;
$result .= $string;
# Show -!- You have <num> new messages in <name>.
# Show this only if there are any new, unread messages.
if (Irssi::settings_get_bool('mail_show_message') &&
$unread > $new_mails_in_box{$name}) {
$new_mails = $unread - $new_mails_in_box{$name};
if ($nummailboxes == 1) {
Irssi::print("You have $new_mails new message" . ($new_mails != 1 ? "s." : "."), MSGLEVEL_CRAP);
} else {
Irssi::print("You have $new_mails new message" . ($new_mails != 1 ? "s " : " ") . "in $name.", MSGLEVEL_CRAP);
}
}
$new_mails_in_box{$name} = $unread;
}
if (length($result) == 0) {
# no mail - don't print the [Mail: ] at all
if ($get_size_only) {
$item->{min_size} = $item->{max_size} = 0;
}
} else {
$item->default_handler($get_size_only, undef, $count, 1);
$item->default_handler($get_size_only, undef, $result, 1);
}
}
@ -95,6 +256,116 @@ sub refresh_mail {
Irssi::statusbar_items_redraw('mail');
}
# Adds the mailboxes from a string. Only to be used during startup.
sub add_mailboxes {
my $boxstring = $_[0];
my @boxes = split(/,/, $boxstring);
foreach $dbox(@boxes) {
my $name = $dbox;
$name = substr($dbox, 0, index($dbox, '='));
my $box = $dbox;
$box = substr($dbox, index($dbox, '=') + 1, length($dbox));
addmailbox($name, $box);
}
}
sub addmailbox {
my ($name, $box) = @_;
if (exists($mailboxes{$name})) {
if ($box eq $mailboxes{$name}) {
Irssi::print("Mailbox $name already set to $box", MSGLEVEL_CRAP);
} else {
Irssi::print("Mailbox $name changed to $box", MSGLEVEL_CRAP);
$new_mails_in_box{$name} = 0;
}
} else {
Irssi::print("Mailbox $name added: " . $box, MSGLEVEL_CRAP);
$new_mails_in_box{$name} = 0;
$nummailboxes++;
}
$mailboxes{$name} = $box;
}
sub delmailbox {
my $name = $_[0];
if (exists($mailboxes{$name})) {
Irssi::print("Mailbox $name removed", MSGLEVEL_CRAP);
delete($mailboxes{$name});
delete($new_mails_in_box{$name});
$nummailboxes--;
} else {
Irssi::print("No such mailbox $name. Use /mailbox show to see a list.", MSGLEVEL_CRAP);
}
}
sub update_settings_string {
my $setting;
foreach $name (keys(%mailboxes)) {
$setting .= $name . "=" . $mailboxes{$name} . ",";
}
Irssi::settings_set_str("mail_mailboxes", $setting);
}
sub cmd_addmailbox {
my ($name, $box) = split(/ +/, $_[0]);
if ($name eq "" || $box eq "") {
Irssi::print("Use /mailbox add <name> <mailbox> to add a mailbox.", MSGLEVEL_CRAP);
return;
}
addmailbox($name, $box);
update_settings_string();
refresh_mail();
}
sub cmd_delmailbox {
my $name = $_[0];
if ($name eq "") {
Irssi::print("Use /mailbox del <name> to delete a mailbox.", MSGLEVEL_CRAP);
return;
}
delmailbox($name);
update_settings_string();
refresh_mail();
}
sub cmd_showmailboxes {
if ($nummailboxes == 0) {
Irssi::print("No mailboxes defined.", MSGLEVEL_CRAP);
return;
}
Irssi::print("Mailboxes:", MSGLEVEL_CRAP);
foreach $box (keys(%mailboxes)) {
Irssi::print("$box: " . $mailboxes{$box}, MSGLEVEL_CRAP);
}
}
sub cmd_mailboxes {
my ($data, $server, $item) = @_;
if ($data =~ m/^[(show)|(add)|(del)]/i ) {
Irssi::command_runsub ('mailbox', $data, $server, $item);
}
else {
Irssi::print("Use /mailbox (show|add|del).")
}
}
sub init_mailboxes {
# Add the mailboxes at startup of the script
my $boxes = Irssi::settings_get_str('mail_mailboxes');
if (length($boxes) > 0) {
add_mailboxes($boxes);
}
}
sub read_settings {
$extprog = Irssi::settings_get_str('mail_ext_program');
my $time = Irssi::settings_get_int('mail_refresh_time');
@ -106,27 +377,37 @@ sub read_settings {
}
return if ($mode == $last_mode);
$last_mode = $mode;
if (!$mode) {
Irssi::settings_set_str('mail_file', "$ENV{'MAIL'}");
} else {
Irssi::settings_set_str('mail_file', "$ENV{'HOME'}/Maildir");
}
refresh_mail;
}
if (!$maildirmode) {
Irssi::settings_add_str('misc', 'mail_file', $ENV{'MAIL'});
my $default = "1=" . $ENV{'MAIL'} . ",";
Irssi::settings_add_str('misc', 'mail_mailboxes', $default);
} else {
Irssi::settings_add_str('misc', 'mail_file', "$ENV{'HOME'}/Maildir");
my $default = "1=~/Maildir/,";
Irssi::settings_add_str('misc', 'mail_mailboxes', $default);
}
Irssi::command_bind('mailbox show', 'cmd_showmailboxes');
Irssi::command_bind('mailbox add', 'cmd_addmailbox');
Irssi::command_bind('mailbox del', 'cmd_delmailbox');
Irssi::command_bind('mailbox help', 'cmd_print_help');
Irssi::command_bind('mailbox', 'cmd_mailboxes');
Irssi::settings_add_str('misc', 'mail_ext_program', '');
Irssi::settings_add_int('misc', 'mail_refresh_time', 60);
Irssi::settings_add_bool('misc', 'maildir_mode', "$maildirmode");
Irssi::settings_add_bool('misc', 'mail_oldnotnew', "$old_is_not_new");
Irssi::settings_add_str('misc', 'mail_separator', ",");
Irssi::settings_add_bool('misc', 'mail_show_message', "0");
Irssi::settings_add_str('misc', 'mail_format', '%n:%u/%t');
Irssi::settings_add_bool('misc', 'mail_show_only_unread', "1");
Irssi::statusbar_item_register('mail', '{sb Mail: $0-}', 'mail');
read_settings();
init_mailboxes();
Irssi::signal_add('setup changed', 'read_settings');
refresh_mail();

View File

@ -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');