Browse Source

glob syntax for the permissions/admins/owners list, more flexible permissions, no gunner suicide

master
jcao219 14 years ago
parent
commit
96bf601dca
  1. 8
      botconfig.py.example
  2. 21
      decorators.py
  3. 5
      wolfgame.py

8
botconfig.py.example

@ -4,13 +4,17 @@ HOST = "irc.freenode.net" @@ -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()

21
decorators.py

@ -9,6 +9,7 @@ @@ -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): @@ -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.")

5
wolfgame.py

@ -839,7 +839,7 @@ def reaper(cli, gameid): @@ -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): @@ -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

Loading…
Cancel
Save