X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=xmlrtorrent.git;a=blobdiff_plain;f=xmlrtorrent.pl;fp=xmlrtorrent.pl;h=fae32f70fa8507027a561e1d09aa3dafce711c8a;hp=397d72c78d15328ce9382c11744e2ab9b15b9377;hb=2026573bcc0493b09a1a95fa1c16e976c9a0ec6e;hpb=58be7bbed0e4ba7be83d0bd3093bcc69571a2a0c 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