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:
|
if not arg:
|
||||||
return
|
return
|
||||||
|
|
||||||
pairs = arg.split(",")
|
arg = arg.replace("=", ":").replace(";", ",")
|
||||||
for pair in pairs:
|
|
||||||
change = pair.lower().split(":")
|
pairs = [arg]
|
||||||
|
while pairs:
|
||||||
|
pair, *pairs = pairs[0].split(",", 1)
|
||||||
|
change = pair.lower().replace(":", " ").strip().rsplit(None, 1)
|
||||||
if len(change) != 2:
|
if len(change) != 2:
|
||||||
raise InvalidModeException("Invalid syntax for mode arguments. arg={0}".format(arg))
|
raise InvalidModeException("Invalid syntax for mode arguments. arg={0}".format(arg))
|
||||||
|
|
||||||
@ -521,14 +524,15 @@ class ChangedRolesMode(GameMode):
|
|||||||
self.MAX_PLAYERS = 35
|
self.MAX_PLAYERS = 35
|
||||||
self.ROLE_GUIDE = ROLE_GUIDE.copy()
|
self.ROLE_GUIDE = ROLE_GUIDE.copy()
|
||||||
self.ROLE_INDEX = (MIN_PLAYERS,)
|
self.ROLE_INDEX = (MIN_PLAYERS,)
|
||||||
pairs = arg.split(",")
|
arg = arg.replace("=", ":").replace(";", ",")
|
||||||
if not pairs:
|
|
||||||
raise InvalidModeException("Invalid syntax for mode roles. arg={0}".format(arg))
|
|
||||||
|
|
||||||
for role in self.ROLE_GUIDE.keys():
|
for role in self.ROLE_GUIDE.keys():
|
||||||
self.ROLE_GUIDE[role] = (0,)
|
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:
|
if len(change) != 2:
|
||||||
raise InvalidModeException("Invalid syntax for mode roles. arg={0}".format(arg))
|
raise InvalidModeException("Invalid syntax for mode roles. arg={0}".format(arg))
|
||||||
role, num = change
|
role, num = change
|
||||||
|
@ -8371,7 +8371,7 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
|
|||||||
|
|
||||||
if rest:
|
if rest:
|
||||||
gamemode = rest.strip().lower()
|
gamemode = rest.strip().lower()
|
||||||
parts = gamemode.split("=", 1)
|
parts = gamemode.replace("=", " ", 1).split(None, 1)
|
||||||
if len(parts) > 1:
|
if len(parts) > 1:
|
||||||
gamemode, modeargs = parts
|
gamemode, modeargs = parts
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user