Skip to content

Instantly share code, notes, and snippets.

@terakilobyte
Created November 4, 2018 00:36
Show Gist options
  • Save terakilobyte/488f49368aba9c87e64b7ed550b085b3 to your computer and use it in GitHub Desktop.
Save terakilobyte/488f49368aba9c87e64b7ed550b085b3 to your computer and use it in GitHub Desktop.
rough example
admins_and_mods = ["tremorai", "swarmlogic", "firecopy"]
def do_command(message):
def command(nick):
print(message)
return command
def do_admin_command(message):
def command(nick):
if nick in admins_and_mods:
print("admin command")
else:
print(f"{nick} is unauthorized")
return command
def notfound(message):
print('what?')
commands = {
"github": do_command("github"),
"discord": do_command("discord"),
"setproject": do_admin_command("setproject")
}
commands.get('github', notfound)("tremorai")
commands.get('foo', notfound)("tremorai")
commands.get('discord', notfound)("firecopy")
commands.get('setproject', notfound)("foo")
commands.get('setproject', notfound)('swarmlogic')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment