From 052a7431471a3c26481e02b74dad1d817a7797a1 Mon Sep 17 00:00:00 2001 From: neersighted Date: Tue, 28 Feb 2012 00:34:04 -0800 Subject: [PATCH] aded restart --- lib/restart.sh | 12 ++++++------ plugins/admin.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/restart.sh b/lib/restart.sh index a42d484..f10a54e 100755 --- a/lib/restart.sh +++ b/lib/restart.sh @@ -1,10 +1,10 @@ #!/bin/sh -wait 5 -if [ -f ../control.sh ]; then - ../control.sh restart -elif [ -f ../bot.sh ]; then - ../bot.sh restart +sleep 5 +if [ -f ./control.sh ]; then + ./control.sh restart +elif [ -f ./bot.sh ]; then + ./bot.sh restart else - ../bot.py + ./bot.py fi exit 0 \ No newline at end of file diff --git a/plugins/admin.py b/plugins/admin.py index d4bec00..668e2a6 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -3,9 +3,10 @@ # Improved by Lukeroge from util import hook import sys +import subprocess import time -@hook.command +@hook.command(autohelp=False) def quit(inp, input=None, db=None, notice=None): ".quit [reason] -- Kills the bot, with [reason] reason as its quit message.." if not input.nick in input.bot.config["admins"]: @@ -18,6 +19,19 @@ def quit(inp, input=None, db=None, notice=None): time.sleep(3) sys.exit() +@hook.command(autohelp=False) +def restart(inp, input=None, db=None, notice=None): + ".restart [reason] -- Restarts the bot, with [reason] reason as its quit message.." + if not input.nick in input.bot.config["admins"]: + notice("Only bot admins can use this command!") + return + if inp: + input.conn.send("QUIT :Bot restarted by "+input.nick+" (" + inp + ")") + else: + input.conn.send("QUIT :Bot restarted by "+input.nick+" (no reason)") + time.sleep(3) + subprocess.call(['lib/restart.sh']) + sys.exit() @hook.command def join(inp, input=None, db=None, notice=None):