diff --git a/plugins/admin.py b/plugins/admin.py index 4966ffa..2131ad6 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -13,11 +13,9 @@ def admins(inp, bot=None): return ", ".join(admins) -@hook.command("quit", autohelp=False) -@hook.command("exit", autohelp=False) -@hook.command(autohelp=False) +@hook.command(autohelp=False, adminOnly=True) def stop(inp, input=None, db=None, notice=None): - ".stop [reason] -- Kills the bot, with [reason] as its quit message." + ".stop [reason] -- Kills the bot with [reason] as its quit message." if not input.nick in input.bot.config["admins"]: notice("Only bot admins can use this command!") return @@ -29,13 +27,10 @@ def stop(inp, input=None, db=None, notice=None): subprocess.call("./cloudbot stop", shell=True) -@hook.command("reboot", autohelp=False) -@hook.command(autohelp=False) +@hook.command("reboot", autohelp=False, adminonly=True) +@hook.command(autohelp=False, adminonly=True) def restart(inp, input=None, db=None, notice=None): - ".restart [reason] -- Restarts the bot, with [reason] as its quit message." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return + ".restart [reason] -- Restarts the bot with [reason] as its quit message." if inp: input.conn.send("QUIT :Restarted by " + input.nick + " (" + inp + ")") else: @@ -44,74 +39,53 @@ def restart(inp, input=None, db=None, notice=None): os.execl("./cloudbot", "restart") -@hook.command("clearlogs", autohelp=False) -@hook.command(autohelp=False) +@hook.command("clearlogs", autohelp=False, adminonly=True) +@hook.command(autohelp=False, adminonly=True) def clear(inp, input=None, db=None, notice=None): - ".clear -- Clears the bot's log(s)." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return + ".clear -- Clears the bots log(s)." time.sleep(5) subprocess.call("./cloudbot clear", shell=True) -@hook.command +@hook.command(adminonly=True) def join(inp, input=None, db=None, notice=None): ".join -- Joins ." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Attempting to join " + inp + "...") input.conn.send("JOIN " + inp) -@hook.command +@hook.command(adminonly=True) def cycle(inp, input=None, db=None, notice=None): ".cycle -- Cycles ." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Attempting to cycle " + inp + "...") input.conn.send("PART " + inp) input.conn.send("JOIN " + inp) -@hook.command +@hook.command(adminonly=True) def part(inp, input=None, notice=None): ".part -- Parts from ." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Attempting to part from " + inp + "...") input.conn.send("PART " + inp) -@hook.command +@hook.command(adminonly=True) def nick(inp, input=None, notice=None): ".nick -- Changes the bots nickname to ." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Changing nick to " + inp + ".") input.conn.send("NICK " + inp) -@hook.command +@hook.command(adminonly=True) def raw(inp, input=None, notice=None): ".raw -- Sends a RAW IRC command." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return notice("Raw command sent.") input.conn.send(inp) -@hook.command +@hook.command(adminonly=True) def kick(inp, input=None, notice=None): ".kick [channel] [reason] -- kicks a user." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return split = inp.split(" ") if split[0][0] == "#": chan = split[0] @@ -138,14 +112,11 @@ def kick(inp, input=None, notice=None): input.conn.send(out) -@hook.command +@hook.command(adminonly=True) def say(inp, input=None, notice=None): ".say [channel] -- Makes the bot say in [channel]. "\ "If [channel] is blank the bot will say the in "\ "the channel the command was used in." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return split = inp.split(" ") if split[0][0] == "#": message = "" @@ -162,8 +133,8 @@ def say(inp, input=None, notice=None): input.conn.send(out) -@hook.command("me") -@hook.command +@hook.command("me", adminonly=True) +@hook.command(adminonly=True) def act(inp, input=None, notice=None): ".act [channel] -- Makes the bot act out in [channel] "\ "If [channel] is blank the bot will act the in "\ @@ -187,12 +158,9 @@ def act(inp, input=None, notice=None): input.conn.send(out) -@hook.command +@hook.command(adminonly=True) def topic(inp, input=None, notice=None): ".topic [channel] -- Change the topic of a channel." - if not input.nick in input.bot.config["admins"]: - notice("Only bot admins can use this command!") - return split = inp.split(" ") if split[0][0] == "#": out = "PRIVMSG %s :%s" % (split[0], message) diff --git a/plugins/factoids.py b/plugins/factoids.py index f6c3b4e..0bccc64 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -43,8 +43,8 @@ def multiwordReplace(text, wordDic): return rc.sub(translate, text) -@hook.command("r") -@hook.command +@hook.command("r", adminonly=True) +@hook.command(adminonly=True) def remember(inp, nick='', db=None, say=None, input=None, notice=None): ".remember [+] -- Remembers with . Add + to to append." if input.nick not in input.bot.config["admins"]: @@ -89,8 +89,8 @@ def remember(inp, nick='', db=None, say=None, input=None, notice=None): return -@hook.command("f") -@hook.command +@hook.command("f", adminonly=True) +@hook.command(adminonly=True) def forget(inp, db=None, input=None, notice=None): ".forget -- Forgets a remembered ." if input.nick not in input.bot.config["admins"]: @@ -113,7 +113,7 @@ def forget(inp, db=None, input=None, notice=None): @hook.command("info") @hook.regex(r'^\? ?(.+)') -def question(inp, say=None, db=None, bot=None): +def factoid(inp, say=None, db=None, bot=None): "? -- Shows what data is associated with ." try: prefix_on = bot.config["plugins"]["factoids"]["prefix"] diff --git a/plugins/help.py b/plugins/help.py index 59e351f..bde3d17 100755 --- a/plugins/help.py +++ b/plugins/help.py @@ -12,13 +12,14 @@ def help(inp, input=None, bot=None, say=None, notice=None): for command, (func, args) in bot.commands.iteritems(): fn = re.match(r'^plugins.(.+).py$', func._filename) if fn.group(1).lower() not in disabled: - if command not in disabled_comm: - if func.__doc__ is not None: - if func in funcs: - if len(funcs[func]) < len(command): + if not args.get('adminonly', False) or input.nick in input.bot.config["admins"]: + if command not in disabled_comm: + if func.__doc__ is not None: + if func in funcs: + if len(funcs[func]) < len(command): + funcs[func] = command + else: funcs[func] = command - else: - funcs[func] = command commands = dict((value, key) for key, value in funcs.iteritems()) @@ -30,7 +31,7 @@ def help(inp, input=None, bot=None, say=None, notice=None): well.append(x) well.sort() for x in well: - if len(out[0]) + len(str(x)) > 440: + if len(out[0]) + len(str(x)) > 405: out[1] += " " + str(x) else: out[0] += " " + str(x) diff --git a/plugins/sieve.py b/plugins/sieve.py index 108390e..305c1e3 100755 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -37,6 +37,6 @@ def sieve_suite(bot, input, func, kind, args): admins = bot.config.get('admins', []) if input.host not in admins and input.nick not in admins: - return None + return return input