2023-03-21 18:46:09 +00:00
|
|
|
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)
|
2019-06-24 04:23:26 +00:00
|
|
|
|
|
|
|
@plugin.group("admin")
|
|
|
|
def admin(self,channel,nick,subcmd,*args):
|
|
|
|
if not self.is_admin: return True
|
2023-03-21 18:39:45 +00:00
|
|
|
if subcmd not in "down pull save reload ping".split(): return True
|
2019-06-24 04:23:26 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
@admin.command("down")
|
|
|
|
def admin_down(self,channel,nick,subcmd,*args):
|
2023-03-21 18:46:09 +00:00
|
|
|
if HOOKED: atexit.unregister(saved)
|
2019-06-24 04:23:26 +00:00
|
|
|
self.tasks.stop()
|
|
|
|
self.tasks.save_state(0)
|
|
|
|
self._bot.die("Stopping...")
|
|
|
|
sys.exit(0)
|
|
|
|
|
2019-06-25 02:23:22 +00:00
|
|
|
@admin.command("pull")
|
|
|
|
def admin_pull(self,channel,nick,subcmd,*args):
|
|
|
|
if subprocess.run(["/usr/bin/git","pull"]).returncode==0:
|
|
|
|
self.say(channel,nick+": Pull successful!")
|
|
|
|
else:
|
|
|
|
self.say(channel,nick+": Pull failed!")
|
2019-11-01 14:59:10 +00:00
|
|
|
self.load_modules()
|
2019-07-17 05:32:52 +00:00
|
|
|
|
|
|
|
@admin.command("save")
|
|
|
|
def admin_save(self,channel,nick,subcmd,*args):
|
|
|
|
self.tasks.save_state(0)
|
2019-10-31 15:25:48 +00:00
|
|
|
|
|
|
|
@admin.command("reload")
|
|
|
|
def reloadPlugins(bot,channel,nick,*args):
|
2023-03-21 18:46:09 +00:00
|
|
|
if HOOKED: atexit.unregister(saved)
|
2019-10-31 15:25:48 +00:00
|
|
|
bot.load_modules()
|
2023-03-21 18:39:45 +00:00
|
|
|
|
|
|
|
@admin.command("ping")
|
|
|
|
def ping(self,channel,nick,*args):
|
|
|
|
self.say(channel,nick+": Pong!")
|