From 7c0ff1f561c504752186650d54117ed946b21177 Mon Sep 17 00:00:00 2001 From: neersighted Date: Wed, 29 Feb 2012 12:11:51 -0800 Subject: [PATCH] updates, fixed .clear --- cloudbot | 21 +++++++++++++-------- lib/clear.py | 4 ++-- plugins/admin.py | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cloudbot b/cloudbot index e45547c..be897f7 100755 --- a/cloudbot +++ b/cloudbot @@ -15,10 +15,11 @@ red = "\033[1;31m" green = "\033[1;32m" usage = "usage: ./cloudbot {start|stop|restart|status}" -quit = nocol + "Goodbye! Thanks for using CloudBot!" +quit = "Goodbye! Thanks for using CloudBot!" pwd = os.getcwd() -clearlog = ": >./bot.log && " +clearlog1 = ": > ./bot.log && " +clearlog2 = ": > ./bot.log" command = ":" daemoncheck = subprocess.check_output("locate /usr/bin/daemon", shell=True) @@ -52,14 +53,14 @@ if daemon: if backend == "daemon": start = "daemon -n cloudbot -O " + pwd + \ "/bot.log -r python " + pwd + "/bot.py" - stop = clearlog + "daemon -n cloudbot --stop" - restart = clearlog + "daemon -n cloudbot --restart" + stop = clearlog1 + "daemon -n cloudbot --stop" + restart = clearlog1 + "daemon -n cloudbot --restart" pid = "pidof /usr/bin/daemon" elif backend == "screen": start = "screen -S cloudbot -dm python" + pwd +\ "/bot.py >>" + pwd + "/bot.log 2>&1" - stop = clearlog + "kill `pidof /usr/bin/screen`" - restart = clearlog + "daemon -n cloudbot --restart" + stop = clearlog1 + "kill `pidof /usr/bin/screen`" + restart = clearlog1 + "daemon -n cloudbot --restart" pid = "pidof /usr/bin/screen" else: print error5 @@ -67,13 +68,13 @@ elif screen: if backend == "daemon": start = "daemon -n cloudbot -O " + pwd + \ "/bot.log -r python " + pwd + "/bot.py" - stop = clearlog + "daemon -n cloudbot --stop" + stop = clearlog1 + "daemon -n cloudbot --stop" restart = stop + " && " + start pid = "pidof /usr/bin/daemon" elif backend == "screen": start = "screen -S cloudbot -dm python" + pwd +\ "/bot.py >>" + pwd + "/bot.log 2>&1" - stop = clearlog + "kill `pidof /usr/bin/screen`" + stop = clearlog1 + "kill `pidof /usr/bin/screen`" restart = stop + " && " + start pid = "pidof /usr/bin/screen" else: @@ -109,6 +110,8 @@ try: elif (sys.argv[1] == 'status'): command = pid print green + "Bot is running! " + nocol + elif (sys.argv[1] == 'clear'): + command = clearlog2 else: print usage exit @@ -141,6 +144,8 @@ try: print "Bot is not running, cannot restart!" elif (sys.argv[1] == 'status'): print red + "Bot is not running!" + nocol + elif (sys.argv[1] == 'clear'): + command = clearlog2 else: print usage exit diff --git a/lib/clear.py b/lib/clear.py index 756002e..97168b8 100755 --- a/lib/clear.py +++ b/lib/clear.py @@ -4,8 +4,8 @@ import sys import os import subprocess -if os.path.isfile("./bot.log"): - clear = ": >./bot.log" +if os.path.isfile("./cloudbot"): + clear = "./cloudbot clear" else: clear = ":" diff --git a/plugins/admin.py b/plugins/admin.py index 3bccaec..75b507d 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -37,9 +37,9 @@ def restart(inp, input=None, db=None, notice=None): sys.exit() -@hook.command +@hook.command(autohelp=False) def clear(inp, input=None, db=None, notice=None): - ".clear -- Clears the bot's log" + ".clear -- Clears the bot's log." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") return