Compare commits

..

No commits in common. 'translation' and 'master' have entirely different histories.

  1. 11
      .gitignore
  2. 3
      botconfig.py.example
  3. 5
      modules/common.py
  4. 18
      modules/sabotage.py
  5. 1164
      modules/wolfgame.py
  6. 102
      settings/wolfgame.py
  7. 8
      tools/decorators.py
  8. 2
      wolfbot.py

11
.gitignore vendored

@ -1,11 +0,0 @@
# Ignore the configfile
botconfig.py
# Ignore the errorlog
errors.log
# Ignore the database
data.sqlite3
# Ignore the python files
**/*.pyc

3
botconfig.py.example

@ -3,10 +3,7 @@ CHANNEL = "#mywolfgame"
HOST = "irc.freenode.net" HOST = "irc.freenode.net"
PORT = 6667 PORT = 6667
USERNAME = "" # for authentication, can be left blank if same as NICK USERNAME = "" # for authentication, can be left blank if same as NICK
OPERUSER = ""
OPERPASS = ""
NICK = "mywolfbot" NICK = "mywolfbot"
NICKPASS = "nickserv password"
CMD_CHAR = "!" CMD_CHAR = "!"
CHANGING_HOST_QUIT_MESSAGE = "Changing host" CHANGING_HOST_QUIT_MESSAGE = "Changing host"

5
modules/common.py

@ -97,11 +97,6 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
def connect_callback(cli): def connect_callback(cli):
def prepare_stuff(*args): def prepare_stuff(*args):
if botconfig.OPERUSER and botconfig.OPERPASS:
cli.send("OPER", botconfig.OPERUSER, botconfig.OPERPASS)
if botconfig.NICKPASS:
cli.ns_identify(botconfig.NICKPASS)
cli.join(botconfig.CHANNEL) cli.join(botconfig.CHANNEL)
cli.msg("ChanServ", "op "+botconfig.CHANNEL) cli.msg("ChanServ", "op "+botconfig.CHANNEL)

18
modules/sabotage.py

@ -23,7 +23,7 @@ pmcmd = decorators.generate(PM_COMMANDS)
hook = decorators.generate(HOOKS, raw_nick=True, permissions=False) hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
def connect_callback(cli): def connect_callback(cli):
var.PHASE = "geen" var.PHASE = "none"
var.PLAYERS = [] var.PLAYERS = []
var.LAST_STATS = None var.LAST_STATS = None
@ -33,7 +33,7 @@ def connect_callback(cli):
def join(cli, nick, chan, rest): def join(cli, nick, chan, rest):
"""Either starts a new game of Werewolf or joins an existing game that has not started yet.""" """Either starts a new game of Werewolf or joins an existing game that has not started yet."""
if var.PHASE == "geen": if var.PHASE == "none":
cli.mode(chan, "+v", nick, nick+"!*@*") cli.mode(chan, "+v", nick, nick+"!*@*")
var.PLAYERS.append(nick) var.PLAYERS.append(nick)
@ -41,19 +41,19 @@ def join(cli, nick, chan, rest):
var.WAITED = 0 var.WAITED = 0
var.GAME_ID = time.time() var.GAME_ID = time.time()
var.CAN_START_TIME = datetime.now() + timedelta(seconds=var.MINIMUM_WAIT) var.CAN_START_TIME = datetime.now() + timedelta(seconds=var.MINIMUM_WAIT)
cli.msg(chan, ('\u0002{0}\u0002 Heeft een spel gestart. '+ cli.msg(chan, ('\u0002{0}\u0002 has started a game of Sabotage. '+
'Tik "{1}join" om mee te spelen. Tik "{1}start" om het spel te starten. '+ 'Type "{1}join" to join. Type "{1}start" to start the game. '+
'Tik "{1}wait" om nog even te wachten met het staten van het spel.').format(nick, botconfig.CMD_CHAR)) 'Type "{1}wait" to increase join wait time.').format(nick, botconfig.CMD_CHAR))
elif nick in var.PLAYERS: elif nick in var.PLAYERS:
cli.notice(nick, "Je speelt al mee!") cli.notice(nick, "You're already playing!")
elif len(pl) >= var.MAX_PLAYERS: elif len(pl) >= var.MAX_PLAYERS:
cli.notice(nick, "Het spel zit al vol. Probeer het later nog eens.") cli.notice(nick, "Too many players! Try again next time.")
elif var.PHASE != "join": elif var.PHASE != "join":
cli.notice(nick, "Sorry het spel is al bezig. Probeer het later nog eens.") cli.notice(nick, "Sorry but the game is already running. Try again next time.")
else: else:
cli.mode(chan, "+v", nick, nick+"!*@*") cli.mode(chan, "+v", nick, nick+"!*@*")
var.PLAYERS.append(nick) var.PLAYERS.append(nick)
cli.msg(chan, '\u0002{0}\u0002 doet mee met het spel.'.format(nick)) cli.msg(chan, '\u0002{0}\u0002 has joined the game.'.format(nick))
var.LAST_STATS = None # reset var.LAST_STATS = None # reset

1164
modules/wolfgame.py

File diff suppressed because it is too large Load Diff

102
settings/wolfgame.py

@ -9,18 +9,18 @@ ADMINS_RATE_LIMIT = 300
SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given
MAX_PLAYERS = 30 MAX_PLAYERS = 30
DRUNK_SHOTS_MULTIPLIER = 3 DRUNK_SHOTS_MULTIPLIER = 3
NIGHT_TIME_LIMIT = 100 NIGHT_TIME_LIMIT = 120
NIGHT_TIME_WARN = 20 # should be less than NIGHT_TIME_LIMIT NIGHT_TIME_WARN = 0 # should be less than NIGHT_TIME_LIMIT
DAY_TIME_LIMIT_WARN = 100 DAY_TIME_LIMIT_WARN = 780
DAY_TIME_LIMIT_CHANGE = 20 # seconds after DAY_TIME_LIMIT_WARN has passed DAY_TIME_LIMIT_CHANGE = 120 # seconds after DAY_TIME_LIMIT_WARN has passed
KILL_IDLE_TIME = 300 KILL_IDLE_TIME = 300
WARN_IDLE_TIME = 180 WARN_IDLE_TIME = 180
PART_GRACE_TIME = 7 PART_GRACE_TIME = 7
QUIT_GRACE_TIME = 30 QUIT_GRACE_TIME = 30
MAX_PRIVMSG_TARGETS = 1 MAX_PRIVMSG_TARGETS = 1
LOG_FILENAME = "wolfbot.log" LOG_FILENAME = ""
BARE_LOG_FILENAME = "wolfbot_bare.log" BARE_LOG_FILENAME = ""
# HIT MISS SUICIDE # HIT MISS SUICIDE
GUN_CHANCES = ( 5/7 , 1/7 , 1/7 ) GUN_CHANCES = ( 5/7 , 1/7 , 1/7 )
@ -29,19 +29,19 @@ MANSLAUGHTER_CHANCE = 1/5 # ACCIDENTAL HEADSHOT (FATAL)
GUNNER_KILLS_WOLF_AT_NIGHT_CHANCE = 0 GUNNER_KILLS_WOLF_AT_NIGHT_CHANCE = 0
GUARDIAN_ANGEL_DIES_CHANCE = 1/2 GUARDIAN_ANGEL_DIES_CHANCE = 1/2
rechercheur_REVEALED_CHANCE = 2/5 DETECTIVE_REVEALED_CHANCE = 2/5
################################################################################################################# #################################################################################################################
# ROLE INDEX: PLAYERS SEER WOLF CURSED DRUNK HARLOT TRAITOR GUNNER CROW ANGEL rechercheur ## # ROLE INDEX: PLAYERS SEER WOLF CURSED DRUNK HARLOT TRAITOR GUNNER CROW ANGEL DETECTIVE ##
################################################################################################################# #################################################################################################################
ROLES_GUIDE = { 4 : ( 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), ## ROLES_GUIDE = { 4 : ( 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ), ##
6 : ( 1 , 1 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 ), ## 6 : ( 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ), ##
8 : ( 1 , 2 , 1 , 0 , 1 , 1 , 1 , 0 , 0 , 0 ), ## 8 : ( 1 , 2 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 ), ##
10 : ( 1 , 2 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 0 ), ## 10 : ( 1 , 2 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 ), ##
11 : ( 1 , 2 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 0 ), ## 11 : ( 1 , 2 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 0 ), ##
15 : ( 1 , 3 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 ), ## 15 : ( 1 , 3 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 1 ), ##
22 : ( 1 , 4 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 ), ## 22 : ( 1 , 4 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 1 ), ##
29 : ( 1 , 5 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 ), ## 29 : ( 1 , 5 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 1 ), ##
None : ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )} ## None : ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )} ##
################################################################################################################# #################################################################################################################
# Notes: ## # Notes: ##
@ -51,35 +51,35 @@ GAME_MODES = {}
AWAY = [] # cloaks of people who are away. AWAY = [] # cloaks of people who are away.
SIMPLE_NOTIFY = [] # cloaks of people who !simple, who want everything /notice'd SIMPLE_NOTIFY = [] # cloaks of people who !simple, who want everything /notice'd
ROLE_INDICES = {0 : "ziener", ROLE_INDICES = {0 : "seer",
1 : "wolf", 1 : "wolf",
2 : "vervloekte burger", 2 : "cursed villager",
3 : "dronken burger", 3 : "village drunk",
4 : "onschuldige meisje", 4 : "harlot",
5 : "verrader", 5 : "traitor",
6 : "kanonnier", 6 : "gunner",
7 : "weerkraai", 7 : "werecrow",
8 : "bescherm engel", 8 : "guardian angel",
9 : "rechercheur"} 9 : "detective"}
INDEX_OF_ROLE = dict((v,k) for k,v in ROLE_INDICES.items()) INDEX_OF_ROLE = dict((v,k) for k,v in ROLE_INDICES.items())
NO_VICTIMS_MESSAGES = ("Het lichaam van een jonge huisdier is gevonden.", NO_VICTIMS_MESSAGES = ("The body of a young penguin pet is found.",
"Een plas van bloed en wolfpoot afdrukken zijn gevonden.", "A pool of blood and wolf paw prints are found.",
"Een pluk van wolvenhaar is gevonden.") "Traces of wolf fur are found.")
LYNCH_MESSAGES = ("De burgers hebben, na lang overleg, besloten om \u0002{0}\u0002 te elimineren. Hij/zij was een... \u0002{1}\u0002.", LYNCH_MESSAGES = ("The villagers, after much debate, finally decide on lynching \u0002{0}\u0002, who turned out to be... a \u0002{1}\u0002.",
"Onder veel lawaai hebben de woedende burgers \u0002{0}\u0002 geelimineerd. Hij/zij was een... \u0002{1}\u0002.", "Under a lot of noise, the pitchfork-bearing villagers lynch \u0002{0}\u0002, who turned out to be... a \u0002{1}\u0002.",
"De menigte sleept een protesterende \u0002{0}\u0002 naar de galg. Hij/zij bezwijkt aan de wil van de groep, en wordt opgehangen. Hij/zij was een \u0002{1}\u0002.", "The mob drags a protesting \u0002{0}\u0002 to the hanging tree. S/He succumbs to the will of the horde, and is hanged. It is discovered (s)he was a \u0002{1}\u0002.",
"Verslagen door zijn/haar lot, is \u0002{0}\u0002 naar de galg geleid. Na de dood bleek hij/zij een \u0002{1}\u0002 te zijn.") "Resigned to his/her fate, \u0002{0}\u0002 is led to the gallows. After death, it is discovered (s)he was a \u0002{1}\u0002.")
import botconfig import botconfig
RULES = (botconfig.CHANNEL + " Kanaal regels: 1) Wees aardig voor elkaar. 2) Deel geen spel infomatie "+ RULES = (botconfig.CHANNEL + " channel rules: 1) Be nice to others. 2) Do not share information "+
"na je dood. 3) Bots zijn niet toegestaan. 4) Speel niet met clones van jezelf.\n"+ "after death. 3) No bots allowed. 4) Do not play with clones.\n"+
"5) Stop niet met spelen, tenzij het niet anders kan. 6) Niet vloeken en hou het leuk "+ "5) Do not quit unless you need to leave. 6) No swearing and keep it "+
"voor iedereen. 7) Sla geen Prive berichten over van het spel tijdens het spel. "+ "family-friendly. 7) Do not paste PM's from the bot during the game. "+
"8) Gebruik je gezonde verstand. 9) Wachten op timeouts is niet leuk.") "8) Use common sense. 9) Waiting for timeouts is discouraged.")
# Other settings: # Other settings:
START_WITH_DAY = False START_WITH_DAY = False
@ -91,8 +91,8 @@ PING_IN = [] # cloaks of users who have opted in for ping
is_role = lambda plyr, rol: rol in ROLES and plyr in ROLES[rol] is_role = lambda plyr, rol: rol in ROLES and plyr in ROLES[rol]
def plural(role): def plural(role):
if role == "wolf": return "wolven" if role == "wolf": return "wolves"
elif role == "persoon": return "personen" elif role == "person": return "people"
else: return role + "s" else: return role + "s"
def list_players(): def list_players():
@ -125,16 +125,16 @@ def game_mode(name):
return decor return decor
CHANGEABLE_ROLES = { "zieners" : INDEX_OF_ROLE["ziener"], CHANGEABLE_ROLES = { "seers" : INDEX_OF_ROLE["seer"],
"wolven" : INDEX_OF_ROLE["wolf"], "wolves" : INDEX_OF_ROLE["wolf"],
"vervloekten" : INDEX_OF_ROLE["vervloekte burger"], "cursed" : INDEX_OF_ROLE["cursed villager"],
"dronkaarts" : INDEX_OF_ROLE["dronken burger"], "drunks" : INDEX_OF_ROLE["village drunk"],
"onschuldige meisjes" : INDEX_OF_ROLE["onschuldige meisje"], "harlots" : INDEX_OF_ROLE["harlot"],
"verraders" : INDEX_OF_ROLE["verrader"], "traitors" : INDEX_OF_ROLE["traitor"],
"kanonniers" : INDEX_OF_ROLE["kanonnier"], "gunners" : INDEX_OF_ROLE["gunner"],
"weerkraaien" : INDEX_OF_ROLE["weerkraai"], "werecrows" : INDEX_OF_ROLE["werecrow"],
"engelen" : INDEX_OF_ROLE["bescherm engel"], "angels" : INDEX_OF_ROLE["guardian angel"],
"rechercheurs" : INDEX_OF_ROLE["rechercheur"]} "detectives" : INDEX_OF_ROLE["detective"]}
@ -161,8 +161,8 @@ class ChangedRolesMode(object):
try: try:
lx[CHANGEABLE_ROLES[role.lower()]] = num lx[CHANGEABLE_ROLES[role.lower()]] = num
except KeyError: except KeyError:
raise InvalidModeException(("De rol \u0002{0}\u0002 "+ raise InvalidModeException(("The role \u0002{0}\u0002 "+
"is niet geldig.").format(role)) "is not valid.").format(role))
except ValueError: except ValueError:
raise InvalidModeException("A bad value was used in mode roles.") raise InvalidModeException("A bad value was used in mode roles.")
for k in ROLES_GUIDE.keys(): for k in ROLES_GUIDE.keys():
@ -196,7 +196,7 @@ with conn:
c.execute('DROP TABLE IF EXISTS roles') c.execute('DROP TABLE IF EXISTS roles')
c.execute('CREATE TABLE roles (id INTEGER PRIMARY KEY AUTOINCREMENT, role TEXT)') c.execute('CREATE TABLE roles (id INTEGER PRIMARY KEY AUTOINCREMENT, role TEXT)')
for x in ["burger"]+list(ROLE_INDICES.values()): for x in ["villager"]+list(ROLE_INDICES.values()):
c.execute("INSERT OR REPLACE INTO roles (role) VALUES (?)", (x,)) c.execute("INSERT OR REPLACE INTO roles (role) VALUES (?)", (x,))

8
tools/decorators.py

@ -37,7 +37,7 @@ def generate(fdict, permissions=True, **kwargs):
if fnmatch.fnmatch(cloak.lower(), pattern.lower()): if fnmatch.fnmatch(cloak.lower(), pattern.lower()):
for cmdname in s: for cmdname in s:
if cmdname in botconfig.DENY[pattern]: if cmdname in botconfig.DENY[pattern]:
largs[0].notice(nick, "Je hebt geen rechten voor dat commando.") largs[0].notice(nick, "You do not have permission to use that command.")
return return
for pattern in botconfig.ALLOW.keys(): for pattern in botconfig.ALLOW.keys():
if fnmatch.fnmatch(cloak.lower(), pattern.lower()): if fnmatch.fnmatch(cloak.lower(), pattern.lower()):
@ -49,14 +49,14 @@ def generate(fdict, permissions=True, **kwargs):
if fnmatch.fnmatch(cloak.lower(), ptn.lower())]: if fnmatch.fnmatch(cloak.lower(), ptn.lower())]:
return f(*largs) return f(*largs)
elif cloak: elif cloak:
largs[0].notice(nick, "Je bent niet de eigenaar.") largs[0].notice(nick, "You are not the owner.")
return return
if admin_only: if admin_only:
if cloak and [ptn for ptn in botconfig.ADMINS+botconfig.OWNERS if cloak and [ptn for ptn in botconfig.ADMINS+botconfig.OWNERS
if fnmatch.fnmatch(cloak.lower(), ptn.lower())]: if fnmatch.fnmatch(cloak.lower(), ptn.lower())]:
return f(*largs) return f(*largs)
elif cloak: elif cloak:
largs[0].notice(nick, "Je bent geen administrator.") largs[0].notice(nick, "You are not an admin.")
return return
return f(*largs) return f(*largs)
alias = False alias = False
@ -68,7 +68,7 @@ def generate(fdict, permissions=True, **kwargs):
for fn in fdict[x]: for fn in fdict[x]:
if (fn.owner_only != owner_only or if (fn.owner_only != owner_only or
fn.admin_only != admin_only): fn.admin_only != admin_only):
raise Exception("Commando: "+x+" heeft geen passende beschermingsniveau!") raise Exception("Command: "+x+" has non-matching protection levels!")
fdict[x].append(innerf) fdict[x].append(innerf)
if alias: if alias:
innerf.aliases.append(x) innerf.aliases.append(x)

2
wolfbot.py

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3.2
# Copyright (c) 2011 Jimmy Cao # Copyright (c) 2011 Jimmy Cao
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy

Loading…
Cancel
Save