diff --git a/botconfig.py.example b/botconfig.py.example index 3517e79..77159dd 100644 --- a/botconfig.py.example +++ b/botconfig.py.example @@ -4,13 +4,17 @@ HOST = "irc.freenode.net" PORT = 6667 # SSL not supported yet USERNAME = "" # for authentication, can be left blank if same as NICK NICK = "mywolfbot" -OWNERS = ("unaffiliated/wolfbot_admin1",) # the comma is required at the end if there is one owner -ADMINS = ("unaffiliated/wolfbot_admin2", "unaffiliated/wolfbot_admin3") CMD_CHAR = "!" CHANGING_HOST_QUIT_MESSAGE = "Changing host" JOIN_AFTER_CLOAKED = True # Set to false if the bot does not have a cloak DISABLE_DEBUG_MODE = False # Entirely disable debug mode +OWNERS = ("unaffiliated/wolfbot_admin1",) # the comma is required at the end if there is one owner +ADMINS = ("unaffiliated/wolfbot_admin2", "unaffiliated/wolfbot_admin3") # glob syntax supported (wildcards) +ALLOW = {"cloakof/fwaiter": ("fwait",), + "cloakof/?omeone_else": ("fday","fnight")} +DENY = {} + # Argument --debug means start in debug mode import argparse parser = argparse.ArgumentParser() diff --git a/decorators.py b/decorators.py index 84c105e..5ef6635 100644 --- a/decorators.py +++ b/decorators.py @@ -9,6 +9,7 @@ from oyoyo.parse import parse_nick +import fnmatch import botconfig def generate(fdict, **kwargs): @@ -23,15 +24,29 @@ def generate(fdict, **kwargs): cloak = "" if not raw_nick and largs[1]: largs[1] = parse_nick(largs[1])[0] # username - #if largs[1].startswith("#"): + #if largs[1].startswith("#"): + if cloak: + for pattern in botconfig.DENY.keys(): + if fnmatch.fnmatch(cloak, pattern): + for cmdname in s: + if cmdname in botconfig.DENY[pattern]: + largs[0].notice(largs[1], "You do not have permission to use that command.") + return + for pattern in botconfig.ALLOW.keys(): + if fnmatch.fnmatch(cloak, pattern): + for cmdname in s: + if cmdname in botconfig.ALLOW[pattern]: + return f(*largs) # no questions if owner_only: - if cloak and cloak in botconfig.OWNERS: + if cloak and [ptn for ptn in botconfig.OWNERS + if fnmatch.fnmatch(cloak, ptn)]: return f(*largs) elif cloak: largs[0].notice(largs[1], "You are not the owner.") return if admin_only: - if cloak and (cloak in botconfig.ADMINS or cloak in botconfig.OWNERS): + if cloak and [ptn for ptn in botconfig.OWNERS + if fnmatch.fnmatch(cloak, ptn)]: return f(*largs) elif cloak: largs[0].notice(largs[1], "You are not an admin.") diff --git a/wolfgame.py b/wolfgame.py index 22b0141..6acc450 100644 --- a/wolfgame.py +++ b/wolfgame.py @@ -839,7 +839,7 @@ def reaper(cli, gameid): x = [a for a in to_warn if a in pl] if x: cli.msg(chan, ("{0}: \u0002You have been idling for a while. "+ - "Please remember to say something soon or you "+ + "Please say something soon or you "+ "might be declared dead.\u0002").format(", ".join(x))) sleep(10) @@ -1295,6 +1295,9 @@ def shoot(cli, nick, chan, rest): cli.notice(nick,"\u0002{0}\u0002 is currently not playing.".format(victim)) return victim = pl[pll.index(victim)] + if victim == nick: + cli.notice(nick, "You are holding it the wrong way.") + return var.GUNNERS[nick] -= 1