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

5
modules/common.py

@ -97,11 +97,6 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False) @@ -97,11 +97,6 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
def connect_callback(cli):
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.msg("ChanServ", "op "+botconfig.CHANNEL)

18
modules/sabotage.py

@ -23,7 +23,7 @@ pmcmd = decorators.generate(PM_COMMANDS) @@ -23,7 +23,7 @@ pmcmd = decorators.generate(PM_COMMANDS)
hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
def connect_callback(cli):
var.PHASE = "geen"
var.PHASE = "none"
var.PLAYERS = []
var.LAST_STATS = None
@ -33,7 +33,7 @@ def connect_callback(cli): @@ -33,7 +33,7 @@ def connect_callback(cli):
def join(cli, nick, chan, rest):
"""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+"!*@*")
var.PLAYERS.append(nick)
@ -41,19 +41,19 @@ def join(cli, nick, chan, rest): @@ -41,19 +41,19 @@ def join(cli, nick, chan, rest):
var.WAITED = 0
var.GAME_ID = time.time()
var.CAN_START_TIME = datetime.now() + timedelta(seconds=var.MINIMUM_WAIT)
cli.msg(chan, ('\u0002{0}\u0002 Heeft een spel gestart. '+
'Tik "{1}join" om mee te spelen. Tik "{1}start" om het spel te starten. '+
'Tik "{1}wait" om nog even te wachten met het staten van het spel.').format(nick, botconfig.CMD_CHAR))
cli.msg(chan, ('\u0002{0}\u0002 has started a game of Sabotage. '+
'Type "{1}join" to join. Type "{1}start" to start the game. '+
'Type "{1}wait" to increase join wait time.').format(nick, botconfig.CMD_CHAR))
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:
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":
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:
cli.mode(chan, "+v", nick, 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

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

8
tools/decorators.py

@ -37,7 +37,7 @@ def generate(fdict, permissions=True, **kwargs): @@ -37,7 +37,7 @@ def generate(fdict, permissions=True, **kwargs):
if fnmatch.fnmatch(cloak.lower(), pattern.lower()):
for cmdname in s:
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
for pattern in botconfig.ALLOW.keys():
if fnmatch.fnmatch(cloak.lower(), pattern.lower()):
@ -49,14 +49,14 @@ def generate(fdict, permissions=True, **kwargs): @@ -49,14 +49,14 @@ def generate(fdict, permissions=True, **kwargs):
if fnmatch.fnmatch(cloak.lower(), ptn.lower())]:
return f(*largs)
elif cloak:
largs[0].notice(nick, "Je bent niet de eigenaar.")
largs[0].notice(nick, "You are not the owner.")
return
if admin_only:
if cloak and [ptn for ptn in botconfig.ADMINS+botconfig.OWNERS
if fnmatch.fnmatch(cloak.lower(), ptn.lower())]:
return f(*largs)
elif cloak:
largs[0].notice(nick, "Je bent geen administrator.")
largs[0].notice(nick, "You are not an admin.")
return
return f(*largs)
alias = False
@ -68,7 +68,7 @@ def generate(fdict, permissions=True, **kwargs): @@ -68,7 +68,7 @@ def generate(fdict, permissions=True, **kwargs):
for fn in fdict[x]:
if (fn.owner_only != owner_only or
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)
if alias:
innerf.aliases.append(x)

2
wolfbot.py

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

Loading…
Cancel
Save