New permissions system :D
This commit is contained in:
parent
d5ddc72a53
commit
9becfa9897
5 changed files with 103 additions and 63 deletions
|
@ -6,50 +6,8 @@ import time
|
|||
import subprocess
|
||||
|
||||
|
||||
@hook.command(adminonly=True)
|
||||
def addadmin(inp, notice=None, bot=None, config=None):
|
||||
"addadmin <nick|host> -- Make <nick|host> an admin. " \
|
||||
"(you can add multiple admins at once)"
|
||||
targets = inp.split()
|
||||
for target in targets:
|
||||
if target in bot.config["admins"]:
|
||||
notice("%s is already an admin." % target)
|
||||
else:
|
||||
notice("%s is now an admin." % target)
|
||||
bot.config["admins"].append(target)
|
||||
bot.config["admins"].sort()
|
||||
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
||||
return
|
||||
|
||||
|
||||
@hook.command(adminonly=True)
|
||||
def deladmin(inp, notice=None, bot=None, config=None):
|
||||
"deladmin <nick|host> -- Make <nick|host> a non-admin." \
|
||||
"(you can delete multiple admins at once)"
|
||||
targets = inp.split()
|
||||
for target in targets:
|
||||
if target in bot.config["admins"]:
|
||||
notice("%s is no longer an admin." % target)
|
||||
bot.config["admins"].remove(target)
|
||||
bot.config["admins"].sort()
|
||||
json.dump(bot.config, open('config', 'w'), sort_keys=True, indent=2)
|
||||
else:
|
||||
notice("%s is not an admin." % target)
|
||||
return
|
||||
|
||||
|
||||
@hook.command(autohelp=False)
|
||||
def admins(inp, notice=None, bot=None):
|
||||
"admins -- Lists bot's admins."
|
||||
if bot.config["admins"]:
|
||||
notice("Admins are: %s." % ", ".join(bot.config["admins"]))
|
||||
else:
|
||||
notice("There are no users with admin powers.")
|
||||
return
|
||||
|
||||
|
||||
@hook.command("quit", autohelp=False, adminonly=True)
|
||||
@hook.command(autohelp=False, adminonly=True)
|
||||
@hook.command("quit", autohelp=False, permissions=["botcontrol"])
|
||||
@hook.command(autohelp=False, permissions=["botcontrol"])
|
||||
def stop(inp, nick=None, conn=None):
|
||||
"stop [reason] -- Kills the bot with [reason] as its quit message."
|
||||
if inp:
|
||||
|
@ -60,7 +18,7 @@ def stop(inp, nick=None, conn=None):
|
|||
os.execl("./cloudbot", "cloudbot", "stop")
|
||||
|
||||
|
||||
@hook.command(autohelp=False, adminonly=True)
|
||||
@hook.command(autohelp=False, permissions=["botcontrol"])
|
||||
def restart(inp, nick=None, conn=None):
|
||||
"restart [reason] -- Restarts the bot with [reason] as its quit message."
|
||||
if inp:
|
||||
|
@ -71,20 +29,20 @@ def restart(inp, nick=None, conn=None):
|
|||
os.execl("./cloudbot", "cloudbot", "restart")
|
||||
|
||||
|
||||
@hook.command(autohelp=False, adminonly=True)
|
||||
@hook.command(autohelp=False, permissions=["botcontrol"])
|
||||
def clearlogs(inp, input=None):
|
||||
"clearlogs -- Clears the bots log(s)."
|
||||
subprocess.call(["./cloudbot", "clear"])
|
||||
|
||||
|
||||
@hook.command(adminonly=True)
|
||||
@hook.command(permissions=["botcontrol"])
|
||||
def join(inp, conn=None, notice=None):
|
||||
"join <channel> -- Joins <channel>."
|
||||
notice("Attempting to join %s..." % inp)
|
||||
conn.join(inp)
|
||||
|
||||
|
||||
@hook.command(autohelp=False, adminonly=True)
|
||||
@hook.command(autohelp=False, permissions=["botcontrol"])
|
||||
def part(inp, conn=None, chan=None, notice=None):
|
||||
"part <channel> -- Leaves <channel>." \
|
||||
"If [channel] is blank the bot will leave the " \
|
||||
|
@ -97,7 +55,7 @@ def part(inp, conn=None, chan=None, notice=None):
|
|||
conn.part(target)
|
||||
|
||||
|
||||
@hook.command(autohelp=False, adminonly=True)
|
||||
@hook.command(autohelp=False, permissions=["botcontrol"])
|
||||
def cycle(inp, conn=None, chan=None, notice=None):
|
||||
"cycle <channel> -- Cycles <channel>." \
|
||||
"If [channel] is blank the bot will cycle the " \
|
||||
|
@ -111,7 +69,7 @@ def cycle(inp, conn=None, chan=None, notice=None):
|
|||
conn.join(target)
|
||||
|
||||
|
||||
@hook.command(adminonly=True)
|
||||
@hook.command(permissions=["botcontrol"])
|
||||
def nick(inp, input=None, notice=None, conn=None):
|
||||
"nick <nick> -- Changes the bots nickname to <nick>."
|
||||
if not re.match("^[A-Za-z0-9_|.-\]\[]*$", inp.lower()):
|
||||
|
@ -121,14 +79,14 @@ def nick(inp, input=None, notice=None, conn=None):
|
|||
conn.set_nick(inp)
|
||||
|
||||
|
||||
@hook.command(adminonly=True)
|
||||
@hook.command(permissions=["botcontrol"])
|
||||
def raw(inp, conn=None, notice=None):
|
||||
"raw <command> -- Sends a RAW IRC command."
|
||||
notice("Raw command sent.")
|
||||
conn.send(inp)
|
||||
|
||||
|
||||
@hook.command(adminonly=True)
|
||||
@hook.command(permissions=["botcontrol"])
|
||||
def say(inp, conn=None, chan=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 " \
|
||||
|
@ -149,8 +107,8 @@ def say(inp, conn=None, chan=None, notice=None):
|
|||
conn.send(out)
|
||||
|
||||
|
||||
@hook.command("act", adminonly=True)
|
||||
@hook.command(adminonly=True)
|
||||
@hook.command("act", permissions=["botcontrol"])
|
||||
@hook.command(permissions=["botcontrol"])
|
||||
def me(inp, conn=None, chan=None, notice=None):
|
||||
"me [channel] <action> -- Makes the bot act out <action> in [channel]. " \
|
||||
"If [channel] is blank the bot will act the <action> in the channel the " \
|
||||
|
|
Reference in a new issue