From 3915be7aa9d7dc54c8d84c96b27a10f3d633b49f Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sat, 26 Jul 2014 23:57:02 +0200 Subject: [PATCH 1/5] Update README.md --- README.md | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 2e63c45..9b74303 100644 --- a/README.md +++ b/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. 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`: - - $ ./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] [(webchat)][2]. 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 +[1]: https://github.com/LycanthropeTheGreat/lycanthrope From d2b96752c7ecb25ea2651421d0e2facc4207f241 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Fri, 1 Aug 2014 11:53:56 +0200 Subject: [PATCH 2/5] Make !votes work in PM --- modules/wolfgame.py | 59 +++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index 30c3295..15d0e96 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -760,41 +760,43 @@ def chk_decision(cli): transition_night(cli) - -@cmd("votes") +@cmd('votes') def show_votes(cli, nick, chan, rest): """Displays the voting statistics.""" - - if var.PHASE in ("none", "join"): + + if var.PHASE in ('none', 'join'): cli.notice(nick, "No game is currently running.") return - if var.PHASE != "day": + + if var.PHASE != 'day': cli.notice(nick, "Voting is only during the day.") return - - if (var.LAST_VOTES and - var.LAST_VOTES + timedelta(seconds=var.VOTES_RATE_LIMIT) > datetime.now()): - cli.notice(nick, ("This command is rate-limited." + - "Please wait a while before using it again.")) - return + + if (chan != nick and var.LAST_VOTES and var.VOTES_RATE_LIMIT and + var.LAST_VOTES + timedelta(seconds=var.VOTES_RATE_LIMIT) > + datetime.now()): + cli.notice(nick, ('This command is rate-limited. Please wait a while ' + 'before using it again.')) + return pl = var.list_players() - + if nick in pl: - var.LAST_VOTES = datetime.now() - + var.LAST_VOTES = datetime.now() + if not var.VOTES.values(): - msg = nick+": No votes yet." + msg = nick+ ': No votes yet.' + if nick in pl: - var.LAST_VOTES = None # reset + var.LAST_VOTES = None # reset else: - votelist = ["{0}: {1} ({2})".format(votee, - len(var.VOTES[votee]), - " ".join(var.VOTES[votee])) + votelist = ['{}: {} ({})'.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: + msg = '{}: {}'.format(nick, ', '.join(votelist)) + + if chan == nick or nick in pl: cli.msg(chan, msg) else: cli.notice(nick, msg) @@ -802,15 +804,20 @@ def show_votes(cli, nick, chan, rest): pl = var.list_players() avail = len(pl) - len(var.WOUNDED) votesneeded = avail // 2 + 1 - the_message = ("{0}: \u0002{1}\u0002 players, \u0002{2}\u0002 votes "+ - "required to lynch, \u0002{3}\u0002 players available " + - "to vote.").format(nick, len(pl), votesneeded, avail) - if nick in pl: + the_message = ('{}: \u0002{}\u0002 players, \u0002{}\u0002 votes ' + 'required to lynch, \u0002{3}\u0002 players available to ' + 'vote.').format(nick, len(pl), votesneeded, avail) + + if chan == nick or nick in pl: cli.msg(chan, the_message) else: cli.notice(nick, the_message) +@pmcmd('votes') +def show_votes_pm(cli, nick, rest): + show_votes(cli, nick, nick, rest) + def chk_traitor(cli): for tt in var.ROLES["traitor"]: From 85a342f9c5eba9e8ee7cdd577884e0008275c61b Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Mon, 4 Aug 2014 10:45:17 +0200 Subject: [PATCH 3/5] Fix typo in !votes Closes #44. --- modules/wolfgame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index 15d0e96..740ce00 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -781,7 +781,7 @@ def show_votes(cli, nick, chan, rest): pl = var.list_players() - if nick in pl: + if chan != nick and nick in pl: var.LAST_VOTES = datetime.now() if not var.VOTES.values(): @@ -805,7 +805,7 @@ def show_votes(cli, nick, chan, rest): avail = len(pl) - len(var.WOUNDED) votesneeded = avail // 2 + 1 the_message = ('{}: \u0002{}\u0002 players, \u0002{}\u0002 votes ' - 'required to lynch, \u0002{3}\u0002 players available to ' + 'required to lynch, \u0002{}\u0002 players available to ' 'vote.').format(nick, len(pl), votesneeded, avail) if chan == nick or nick in pl: From 191a910098f675bf6d73346d184cf257bc20b54b Mon Sep 17 00:00:00 2001 From: "Vgr E.Barry" Date: Tue, 5 Aug 2014 02:40:52 -0400 Subject: [PATCH 4/5] Fix issue where bot would spam services This very simple fix probably seems redundant or even entirely pointless, but it actually solves a big design flaw. It does not show much for freenode, but for other networks (e.g. Esper), where I tweaked my bot to use ns_ghost instead, it keeps trying to kill off an (unregistered) nick, without having a password. This effectively causes spam to the services, and results in an automatic ban. --- modules/common.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/common.py b/modules/common.py index fdc825f..310900a 100644 --- a/modules/common.py +++ b/modules/common.py @@ -113,9 +113,13 @@ def connect_callback(cli): prepare_stuff = hook("endofmotd", hookid=294)(prepare_stuff) def mustregain(cli, *blah): + if not botconfig.PASS: + return cli.ns_regain() def mustrelease(cli, *rest): + if not botconfig.PASS: + return # prevents the bot from trying to release without a password cli.ns_release() cli.nick(botconfig.NICK) From 1a80bc10274d12066b9fb23bb52fa29867853ecb Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Tue, 5 Aug 2014 14:28:10 +0200 Subject: [PATCH 5/5] Allow admins to use !fgame without joining --- modules/wolfgame.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index 740ce00..03a67b0 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -3380,33 +3380,40 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS: @cmd("fgame", admin_only=True) - def game(cli, nick, chan, rest): + def fgame(cli, nick, chan, rest): 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 - 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 - 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 + rest = rest.strip().lower() + if rest: - if cgamemode(cli, *re.split(" +",rest)): - cli.msg(chan, ("\u0002{0}\u0002 has changed the "+ - "game settings successfully.").format(nick)) + if cgamemode(cli, *re.split(' +', rest)): + cli.msg(chan, ('\u0002{}\u0002 has changed the game settings ' + 'successfully.').format(nick)) - def fgame_help(args = ""): + def fgame_help(args=''): args = args.strip() + 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(): return var.GAME_MODES[args].__doc__ 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