From 2026573bcc0493b09a1a95fa1c16e976c9a0ec6e Mon Sep 17 00:00:00 2001 From: Ralf Ertzinger Date: Thu, 12 Feb 2009 17:01:31 +0100 Subject: [PATCH] - Handle autosave on module unload/irssi exit --- xmlrtorrent.pl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 -- 1.8.3.1