- Handle autosave on module unload/irssi exit master
authorRalf Ertzinger <sun@lain.camperquake.de>
Thu, 12 Feb 2009 16:01:31 +0000 (17:01 +0100)
committerRalf Ertzinger <sun@lain.camperquake.de>
Thu, 12 Feb 2009 16:01:31 +0000 (17:01 +0100)
xmlrtorrent.pl

index 397d72c..fae32f7 100644 (file)
@@ -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