From 8a9d4412d39605cd9e27f799bf268a7a99db7636 Mon Sep 17 00:00:00 2001 From: Fudster Date: Mon, 6 Feb 2017 22:36:33 -0500 Subject: [PATCH] Tweak fjoin (#285) Change the behaviour of fjoin in both normal and debug modes: - Only joins fake nicks in debug mode; - Only joins one person in normal mode, multiple in debug mode; - Autocomplete nicks in both normal and debug modes. --- src/wolfgame.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/wolfgame.py b/src/wolfgame.py index 629b643..dd6c213 100644 --- a/src/wolfgame.py +++ b/src/wolfgame.py @@ -979,6 +979,7 @@ def fjoin(var, wrapper, message): "join_deadchat": join_deadchat, "vote_gamemode": vote_gamemode }) + if not evt.dispatch(var, wrapper, message, forced=True): return noticed = False @@ -986,9 +987,21 @@ def fjoin(var, wrapper, message): if not message.strip(): evt.data["join_player"](var, wrapper, forced=True) - for tojoin in re.split(" +", message): + parts = re.split(" +", message) + possible_users = {u.lower().nick for u in wrapper.target.users} + if not botconfig.DEBUG_MODE: + match = complete_one_match(users.lower(parts[0]), possible_users) + if match: + to_join = [match] + else: + to_join = [] + for i, s in enumerate(parts): + match = complete_one_match(users.lower(s), possible_users) + if match: + to_join.append(match) + for tojoin in to_join: tojoin = tojoin.strip() - if "-" in tojoin: + if "-" in tojoin and botconfig.DEBUG_MODE: first, hyphen, last = tojoin.partition("-") if first.isdigit() and last.isdigit(): if int(last)+1 - int(first) > var.MAX_PLAYERS - len(list_players()):