Add hook on exit
This commit is contained in:
parent
5aef6ef3f3
commit
f993f58444
|
@ -1,4 +1,16 @@
|
|||
import plugin, subprocess
|
||||
import plugin, subprocess, atexit
|
||||
|
||||
HOOKED=False
|
||||
|
||||
def saved(bot):
|
||||
bot.tasks.save_state(0)
|
||||
|
||||
@plugin.listener
|
||||
def hook(self,*args):
|
||||
global HOOKED
|
||||
if HOOKED: return
|
||||
HOOKED=True
|
||||
atexit.register(saved,self)
|
||||
|
||||
@plugin.group("admin")
|
||||
def admin(self,channel,nick,subcmd,*args):
|
||||
|
@ -8,6 +20,7 @@ def admin(self,channel,nick,subcmd,*args):
|
|||
|
||||
@admin.command("down")
|
||||
def admin_down(self,channel,nick,subcmd,*args):
|
||||
if HOOKED: atexit.unregister(saved)
|
||||
self.tasks.stop()
|
||||
self.tasks.save_state(0)
|
||||
self._bot.die("Stopping...")
|
||||
|
@ -27,6 +40,7 @@ def admin_save(self,channel,nick,subcmd,*args):
|
|||
|
||||
@admin.command("reload")
|
||||
def reloadPlugins(bot,channel,nick,*args):
|
||||
if HOOKED: atexit.unregister(saved)
|
||||
bot.load_modules()
|
||||
|
||||
@admin.command("ping")
|
||||
|
|
Loading…
Reference in New Issue