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