Merge remote-tracking branch 'upstream/master'
Conflicts: modules/wolfgame.py
This commit is contained in:
commit
9e4d8d7017
37
README.md
37
README.md
@ -1,35 +1,16 @@
|
|||||||
Dependencies
|
This is the game bot for ##werewolf on freenode. It's a continutation of
|
||||||
------------
|
[lycanthrope][1], which has become inactive. We have an active community, and
|
||||||
|
we'd love for you to join us!
|
||||||
|
|
||||||
- Python 3.2 or higher
|
# Running the bot
|
||||||
|
|
||||||
Configuration
|
If you wish to run your own copy of the bot, all you need is Python 3.2 or a
|
||||||
-------------
|
newer version.
|
||||||
|
|
||||||
Copy `botconfig.py.example` to `botconfig.py` and modify the settings as needed.
|
Copy `botconfig.py.example` to `botconfig.py` and modify the settings as needed.
|
||||||
If desired, edit `settings/wolfgame.py` to modify game settings.
|
If desired, edit `settings/wolfgame.py` to modify game settings.
|
||||||
|
|
||||||
Starting the bot
|
To start the bot, run `./wolfbot.py`. You can optionally use `--debug` or
|
||||||
----------------
|
`--verbose`.
|
||||||
|
|
||||||
To start the bot, you can simply execute `wolfbot.py`:
|
[1]: https://github.com/LycanthropeTheGreat/lycanthrope
|
||||||
|
|
||||||
$ ./wolfbot.py
|
|
||||||
|
|
||||||
Debug mode can be enabled with the `--debug` argument:
|
|
||||||
|
|
||||||
$ ./wolfbot.py --debug
|
|
||||||
|
|
||||||
Verbose logging can be enabled with the `--verbose` argument:
|
|
||||||
|
|
||||||
$ ./wolfbot.py --verbose
|
|
||||||
|
|
||||||
Playing the game
|
|
||||||
----------------
|
|
||||||
|
|
||||||
You can find us in ``##werewolf`` on [freenode][1] <sup>[(webchat)][2]</sup>. The
|
|
||||||
bot is running there and we have an active community. We'd love for you to join
|
|
||||||
us!
|
|
||||||
|
|
||||||
[1]: https://freenode.net/
|
|
||||||
[2]: http://webchat.freenode.net?channels=%23%23werewolf
|
|
||||||
|
@ -113,9 +113,13 @@ def connect_callback(cli):
|
|||||||
prepare_stuff = hook("endofmotd", hookid=294)(prepare_stuff)
|
prepare_stuff = hook("endofmotd", hookid=294)(prepare_stuff)
|
||||||
|
|
||||||
def mustregain(cli, *blah):
|
def mustregain(cli, *blah):
|
||||||
|
if not botconfig.PASS:
|
||||||
|
return
|
||||||
cli.ns_regain()
|
cli.ns_regain()
|
||||||
|
|
||||||
def mustrelease(cli, *rest):
|
def mustrelease(cli, *rest):
|
||||||
|
if not botconfig.PASS:
|
||||||
|
return # prevents the bot from trying to release without a password
|
||||||
cli.ns_release()
|
cli.ns_release()
|
||||||
cli.nick(botconfig.NICK)
|
cli.nick(botconfig.NICK)
|
||||||
|
|
||||||
|
@ -949,41 +949,43 @@ def chk_decision(cli, force = ""):
|
|||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
@cmd('votes')
|
||||||
@cmd("votes")
|
|
||||||
def show_votes(cli, nick, chan, rest):
|
def show_votes(cli, nick, chan, rest):
|
||||||
"""Displays the voting statistics."""
|
"""Displays the voting statistics."""
|
||||||
|
|
||||||
if var.PHASE in ("none", "join"):
|
if var.PHASE in ("none", "join"):
|
||||||
cli.notice(nick, "No game is currently running.")
|
cli.notice(nick, "No game is currently running.")
|
||||||
return
|
return
|
||||||
if var.PHASE != "day":
|
|
||||||
|
if var.PHASE != 'day':
|
||||||
cli.notice(nick, "Voting is only during the day.")
|
cli.notice(nick, "Voting is only during the day.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if (var.LAST_VOTES and
|
if (chan != nick and var.LAST_VOTES and var.VOTES_RATE_LIMIT and
|
||||||
var.LAST_VOTES + timedelta(seconds=var.VOTES_RATE_LIMIT) > datetime.now()):
|
var.LAST_VOTES + timedelta(seconds=var.VOTES_RATE_LIMIT) >
|
||||||
cli.notice(nick, ("This command is rate-limited." +
|
datetime.now()):
|
||||||
"Please wait a while before using it again."))
|
cli.notice(nick, ('This command is rate-limited. Please wait a while '
|
||||||
|
'before using it again.'))
|
||||||
return
|
return
|
||||||
|
|
||||||
pl = var.list_players()
|
pl = var.list_players()
|
||||||
|
|
||||||
if nick in pl:
|
if chan != nick and nick in pl:
|
||||||
var.LAST_VOTES = datetime.now()
|
var.LAST_VOTES = datetime.now()
|
||||||
|
|
||||||
if not var.VOTES.values():
|
if not var.VOTES.values():
|
||||||
msg = nick+": No votes yet."
|
msg = nick+ ': No votes yet.'
|
||||||
if nick in pl:
|
|
||||||
var.LAST_VOTES = None # reset
|
|
||||||
else:
|
|
||||||
votelist = ["{0}: {1} ({2})".format(votee,
|
|
||||||
len(var.VOTES[votee]),
|
|
||||||
" ".join(var.VOTES[votee]))
|
|
||||||
for votee in var.VOTES.keys()]
|
|
||||||
msg = "{0}: {1}".format(nick, ", ".join(votelist))
|
|
||||||
|
|
||||||
if nick in pl:
|
if nick in pl:
|
||||||
|
var.LAST_VOTES = None # reset
|
||||||
|
else:
|
||||||
|
votelist = ['{}: {} ({})'.format(votee,
|
||||||
|
len(var.VOTES[votee]),
|
||||||
|
' '.join(var.VOTES[votee]))
|
||||||
|
for votee in var.VOTES.keys()]
|
||||||
|
msg = '{}: {}'.format(nick, ', '.join(votelist))
|
||||||
|
|
||||||
|
if chan == nick or nick in pl:
|
||||||
cli.msg(chan, msg)
|
cli.msg(chan, msg)
|
||||||
else:
|
else:
|
||||||
cli.notice(nick, msg)
|
cli.notice(nick, msg)
|
||||||
@ -991,15 +993,20 @@ def show_votes(cli, nick, chan, rest):
|
|||||||
pl = var.list_players()
|
pl = var.list_players()
|
||||||
avail = len(pl) - len(var.WOUNDED) - len(var.ASLEEP)
|
avail = len(pl) - len(var.WOUNDED) - len(var.ASLEEP)
|
||||||
votesneeded = avail // 2 + 1
|
votesneeded = avail // 2 + 1
|
||||||
the_message = ("{0}: \u0002{1}\u0002 players, \u0002{2}\u0002 votes "+
|
the_message = ('{}: \u0002{}\u0002 players, \u0002{}\u0002 votes '
|
||||||
"required to lynch, \u0002{3}\u0002 players available " +
|
'required to lynch, \u0002{}\u0002 players available to '
|
||||||
"to vote.").format(nick, len(pl), votesneeded, avail)
|
'vote.').format(nick, len(pl), votesneeded, avail)
|
||||||
if nick in pl:
|
|
||||||
|
if chan == nick or nick in pl:
|
||||||
cli.msg(chan, the_message)
|
cli.msg(chan, the_message)
|
||||||
else:
|
else:
|
||||||
cli.notice(nick, the_message)
|
cli.notice(nick, the_message)
|
||||||
|
|
||||||
|
|
||||||
|
@pmcmd('votes')
|
||||||
|
def show_votes_pm(cli, nick, rest):
|
||||||
|
show_votes(cli, nick, nick, rest)
|
||||||
|
|
||||||
|
|
||||||
def chk_traitor(cli):
|
def chk_traitor(cli):
|
||||||
wcl = copy.copy(var.ROLES["wolf cub"])
|
wcl = copy.copy(var.ROLES["wolf cub"])
|
||||||
@ -5432,18 +5439,23 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
|
|||||||
|
|
||||||
|
|
||||||
@cmd("fgame", admin_only=True)
|
@cmd("fgame", admin_only=True)
|
||||||
def game(cli, nick, chan, rest):
|
def fgame(cli, nick, chan, rest):
|
||||||
pl = var.list_players()
|
pl = var.list_players()
|
||||||
if var.PHASE == "none":
|
|
||||||
cli.notice(nick, "No game is currently running.")
|
if var.PHASE == 'none':
|
||||||
|
cli.notice(nick, 'No game is currently running.')
|
||||||
return
|
return
|
||||||
if var.PHASE != "join":
|
|
||||||
cli.notice(nick, "Werewolf is already in play.")
|
if var.PHASE != 'join':
|
||||||
|
cli.notice(nick, 'Werewolf is already in play.')
|
||||||
return
|
return
|
||||||
if nick not in pl:
|
|
||||||
cli.notice(nick, "You're currently not playing.")
|
if nick not in pl and nick not in botconfig.ADMINS + botconfig.OWNERS:
|
||||||
|
cli.notice(nick, 'You\'re currently not playing.')
|
||||||
return
|
return
|
||||||
|
|
||||||
rest = rest.strip().lower()
|
rest = rest.strip().lower()
|
||||||
|
|
||||||
if rest:
|
if rest:
|
||||||
if cgamemode(cli, rest):
|
if cgamemode(cli, rest):
|
||||||
cli.msg(chan, ("\u0002{0}\u0002 has changed the "+
|
cli.msg(chan, ("\u0002{0}\u0002 has changed the "+
|
||||||
@ -5451,14 +5463,16 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
|
|||||||
|
|
||||||
def fgame_help(args = ""):
|
def fgame_help(args = ""):
|
||||||
args = args.strip()
|
args = args.strip()
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
return "Available game mode setters: "+ ", ".join(var.GAME_MODES.keys())
|
return 'Available game mode setters: ' + ', '.join(var.GAME_MODES.keys())
|
||||||
elif args in var.GAME_MODES.keys():
|
elif args in var.GAME_MODES.keys():
|
||||||
return var.GAME_MODES[args].__doc__
|
return var.GAME_MODES[args].__doc__
|
||||||
else:
|
else:
|
||||||
return "Game mode setter {0} not found.".format(args)
|
return 'Game mode setter \u0002{}\u0002 not found.'.format(args)
|
||||||
|
|
||||||
game.__doc__ = fgame_help
|
|
||||||
|
fgame.__doc__ = fgame_help
|
||||||
|
|
||||||
|
|
||||||
# DO NOT MAKE THIS A PMCOMMAND ALSO
|
# DO NOT MAKE THIS A PMCOMMAND ALSO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user