From: Ralf Ertzinger Date: Thu, 12 Feb 2009 16:01:31 +0000 (+0100) Subject: - Handle autosave on module unload/irssi exit X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=xmlrtorrent.git;a=commitdiff_plain - Handle autosave on module unload/irssi exit --- diff --git a/xmlrtorrent.pl b/xmlrtorrent.pl index 397d72c..fae32f7 100644 --- a/xmlrtorrent.pl +++ b/xmlrtorrent.pl @@ -25,8 +25,16 @@ my @outputstack = (undef); my $PARAMS = { '_QUEUE' => {}, + '_AUTOSAVE' => 1, }; +# Handle module unload/irssi shutdown +sub UNLOAD { + if ($conf->{'xmlrtorrent'}->{'_AUTOSAVE'}) { + cmd_save(); + } +} + # activate debug here my $debug = 0; @@ -86,6 +94,16 @@ my $xmlrtorrent_commands = { $debug = 0; write_irssi('Disabled debugging'); }, + + 'autosave' => sub { + $conf->{'xmlrtorrent'}->{'_AUTOSAVE'} = 1; + write_irssi('Autosave enabled'); + }, + + 'noautosave' => sub { + $conf->{'xmlrtorrent'}->{'_AUTOSAVE'} = 0; + write_irssi('Autosave disabled'); + }, }; # This is shamelessly stolen from pythons urlgrabber