1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-13 05:03:45 -04:00

run syncscripts.sh

sync buf.pl to version 3.00
sync usercount.pl to version 1.20
This commit is contained in:
ailin-nemui 2018-11-09 11:11:10 +01:00
parent 2847b751e3
commit 60d2364989
2 changed files with 60 additions and 63 deletions

View File

@ -1,22 +1,24 @@
use strict; use strict;
use vars qw($VERSION %IRSSI); use vars qw($VERSION %IRSSI);
use Storable;
use 5.014000;
use Irssi qw(command signal_add signal_add_first active_win use Irssi qw(command signal_add signal_add_first active_win
settings_get_str settings_get_bool channels windows settings_get_str settings_get_bool channels windows
settings_add_str settings_add_bool get_irssi_dir settings_add_str settings_add_bool get_irssi_dir
window_find_refnum signal_stop); window_find_refnum signal_stop);
$VERSION = '2.20'; $VERSION = '3.00';
%IRSSI = ( %IRSSI = (
authors => 'Juerd', authors => 'Juerd',
contact => 'juerd@juerd.nl', contact => 'juerd@juerd.nl',
name => 'Scroll buffer restorer', name => 'Scroll buffer restorer',
description => 'Saves the buffer for /upgrade, so that no information is lost', description => 'Saves the buffer for /upgrade, so that no information is lost',
license => 'Public Domain', license => 'Public Domain',
url => 'http://juerd.nl/irssi/', url => 'http://juerd.nl/irssi/',
changed => 'Thu Sep 22 01:37 CEST 2016', changed => 'Thu Mar 29 10:00 CEST 2018',
changes => 'Fixed file permissions (leaked everything via filesystem)', changes => 'Fixed file permissions (leaked everything via filesystem), rewritten to use Storable and print to correct levels',
note1 => 'This script HAS TO BE in your scripts/autorun!', note1 => 'This script HAS TO BE in your scripts/autorun!',
note2 => 'Perl support must be static or in startup', note2 => 'Perl support must be static or in startup',
); );
# Q: How can I get a very smooth and clean upgrade? # Q: How can I get a very smooth and clean upgrade?
@ -40,30 +42,28 @@ my %suppress;
sub _filename { sprintf '%s/scrollbuffer', get_irssi_dir } sub _filename { sprintf '%s/scrollbuffer', get_irssi_dir }
sub upgrade { sub upgrade {
my $fn = _filename; my $out = { suppress => [ map $_->{server}->{address} . $_->{name}, channels ] };
my $old_umask = umask 0077;
open my $fh, q{>}, $fn or die "open $fn: $!";
umask $old_umask;
print $fh join("\0", map $_->{server}->{address} . $_->{name}, channels), "\n";
for my $window (windows) { for my $window (windows) {
next unless defined $window; next unless defined $window;
next if $window->{name} eq 'status'; next if $window->{name} eq 'status';
my $view = $window->view; my $view = $window->view;
my $line = $view->get_lines; my $line = $view->get_lines;
my $lines = 0; my $lines = 0;
my $buf = ''; my $buf = '';
if (defined $line){ my $output;
{ if (defined $line) {
$buf .= $line->get_text(1) . "\n"; {
$line = $line->next; push @$output, { level => $line->{info}{level}, data => $line->get_text(1) };
$lines++; $line = $line->next;
redo if defined $line; redo if defined $line;
} }
} }
printf $fh "%s:%s\n%s", $window->{refnum}, $lines, $buf; push @{$out->{windows}}, { refnum => $window->{refnum}, lines => $output };
} }
close $fh; my $old_umask = umask 0077;
my $fn = _filename;
store($out, $fn) or die "Could not store data to $fn";
umask $old_umask;
unlink sprintf("%s/sessionconfig", get_irssi_dir); unlink sprintf("%s/sessionconfig", get_irssi_dir);
command 'layout save'; command 'layout save';
command 'save'; command 'save';
@ -71,33 +71,30 @@ sub upgrade {
sub restore { sub restore {
my $fn = _filename; my $fn = _filename;
open my $fh, q{<}, $fn or die "open $fn: $!"; my $in = retrieve($fn) or die "Could not retrieve data from $fn";
unlink $fn or warn "unlink $fn: $!"; unlink $fn or warn "unlink $fn: $!";
my @suppress = split /\0/, readline $fh; my @suppress = @{$in->{suppress}};
if (settings_get_bool 'upgrade_suppress_join') { @suppress{@suppress} = (2) x @suppress if (settings_get_bool 'upgrade_suppress_join');
chomp $suppress[-1];
@suppress{@suppress} = (2) x @suppress;
}
active_win->command('^window scroll off'); active_win->command('^window scroll off');
while (my $bla = readline $fh){ for my $win (@{$in->{windows}}) {
chomp $bla; my $window = window_find_refnum $win->{refnum};
my ($refnum, $lines) = split /:/, $bla; next unless $window;
next unless $lines; my @lines = @{ $win->{lines} || [] };
my $window = window_find_refnum $refnum; next unless @lines;
unless (defined $window){
readline $fh for 1..$lines; my $view = $window->view;
next; $view->remove_all_lines();
} $view->redraw();
my $view = $window->view; for my $line (@lines) {
$view->remove_all_lines(); my $level = $line->{level};
$view->redraw(); my $data = $line->{data};
my $buf = ''; $window->gui_printtext_after($window->last_line_insert, $level, "$data\n");
$buf .= readline $fh for 1..$lines; }
my $sep = settings_get_str 'upgrade_separator'; my $sep = settings_get_str 'upgrade_separator';
$sep .= "\n" if $sep ne ''; $window->gui_printtext_after($window->last_line_insert, MSGLEVEL_CLIENTNOTICE, "\cO$sep\n") if $sep ne '';
$window->gui_printtext_after(undef, MSGLEVEL_CLIENTNOTICE, "$buf\cO$sep"); $view->redraw();
$view->redraw();
} }
active_win->command('^window scroll on'); active_win->command('^window scroll on');
active_win->command('^scrollback end'); active_win->command('^scrollback end');
@ -110,7 +107,7 @@ sub suppress {
$key_part =~ s/^://; $key_part =~ s/^://;
my $key = $first->{address} . $key_part; my $key = $first->{address} . $key_part;
if (exists $suppress{$key} and $suppress{$key}--) { if (exists $suppress{$key} and $suppress{$key}--) {
signal_stop(); signal_stop();
delete $suppress{$key} unless $suppress{$key}; delete $suppress{$key} unless $suppress{$key};
} }
} }

View File

@ -1,7 +1,7 @@
use strict; use strict;
use Irssi 20040119.2359 (); use Irssi 20040119.2359 ();
use vars qw($VERSION %IRSSI); use vars qw($VERSION %IRSSI);
$VERSION = "1.19"; $VERSION = "1.20";
%IRSSI = ( %IRSSI = (
authors => 'David Leadbeater, Timo Sirainen, Georg Lukas', authors => 'David Leadbeater, Timo Sirainen, Georg Lukas',
contact => 'dgl@dgl.cx, tss@iki.fi, georg@boerde.de', contact => 'dgl@dgl.cx, tss@iki.fi, georg@boerde.de',
@ -128,7 +128,7 @@ sub calc_users() {
} }
# Server doesn't support halfops? # Server doesn't support halfops?
if($server->isupport("PREFIX") !~ /\%/) { if($server->can('isupport') && $server->isupport("PREFIX") !~ /\%/) {
$halfops = undef; $halfops = undef;
} else { } else {
$halfops = undef unless Irssi::settings_get_bool('usercount_show_halfops'); $halfops = undef unless Irssi::settings_get_bool('usercount_show_halfops');