Changed method of checking for admin powers, small tweaks
This commit is contained in:
parent
7e00677c03
commit
c168a179e3
4 changed files with 32 additions and 63 deletions
|
@ -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 <channel> -- Joins <channel>."
|
||||
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 <channel> -- Cycles <channel>."
|
||||
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 <channel> -- Parts from <channel>."
|
||||
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 <nick> -- Changes the bots nickname to <nick>."
|
||||
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 <command> -- 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] <user> [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] <message> -- Makes the bot say <message> in [channel]. "\
|
||||
"If [channel] is blank the bot will say the <message> 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] <action> -- Makes the bot act out <action> in [channel] "\
|
||||
"If [channel] is blank the bot will act the <action> 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] <topic> -- 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)
|
||||
|
|
|
@ -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 <word> [+]<data> -- Remembers <data> with <word>. Add + to <data> 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 <word> -- Forgets a remembered <word>."
|
||||
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):
|
||||
"?<word> -- Shows what data is associated with <word>."
|
||||
try:
|
||||
prefix_on = bot.config["plugins"]["factoids"]["prefix"]
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue