Improve !fgame to allow an arbitrary number of spaces
This also allows to be a bit more liberal with the punctuation
This commit is contained in:
parent
d827eae2d8
commit
bd93e96445
@ -473,9 +473,12 @@ class GameMode:
|
||||
if not arg:
|
||||
return
|
||||
|
||||
pairs = arg.split(",")
|
||||
for pair in pairs:
|
||||
change = pair.lower().split(":")
|
||||
arg = arg.replace("=", ":").replace(";", ",")
|
||||
|
||||
pairs = [arg]
|
||||
while pairs:
|
||||
pair, *pairs = pairs[0].split(",", 1)
|
||||
change = pair.lower().replace(":", " ").strip().rsplit(None, 1)
|
||||
if len(change) != 2:
|
||||
raise InvalidModeException("Invalid syntax for mode arguments. arg={0}".format(arg))
|
||||
|
||||
@ -521,14 +524,15 @@ class ChangedRolesMode(GameMode):
|
||||
self.MAX_PLAYERS = 35
|
||||
self.ROLE_GUIDE = ROLE_GUIDE.copy()
|
||||
self.ROLE_INDEX = (MIN_PLAYERS,)
|
||||
pairs = arg.split(",")
|
||||
if not pairs:
|
||||
raise InvalidModeException("Invalid syntax for mode roles. arg={0}".format(arg))
|
||||
arg = arg.replace("=", ":").replace(";", ",")
|
||||
|
||||
for role in self.ROLE_GUIDE.keys():
|
||||
self.ROLE_GUIDE[role] = (0,)
|
||||
for pair in pairs:
|
||||
change = pair.split(":")
|
||||
|
||||
pairs = [arg]
|
||||
while pairs:
|
||||
pair, *pairs = pairs[0].split(",", 1)
|
||||
change = pair.replace(":", " ").strip().rsplit(None, 1)
|
||||
if len(change) != 2:
|
||||
raise InvalidModeException("Invalid syntax for mode roles. arg={0}".format(arg))
|
||||
role, num = change
|
||||
|
@ -8371,7 +8371,7 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
|
||||
|
||||
if rest:
|
||||
gamemode = rest.strip().lower()
|
||||
parts = gamemode.split("=", 1)
|
||||
parts = gamemode.replace("=", " ", 1).split(None, 1)
|
||||
if len(parts) > 1:
|
||||
gamemode, modeargs = parts
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user