Change settings.COMMAND_ARG_REGEX default to require a space or '/' between cmdname and argument. This better matches common expectations. Resolves #1541.
This commit is contained in:
parent
36e985557f
commit
c2a3c789d3
6 changed files with 35 additions and 12 deletions
|
|
@ -103,6 +103,8 @@ Up requirements to Django 3.2+, Twisted 21+
|
||||||
`SERVER_HOSTNAME` setting for use in the server:port stanza.
|
`SERVER_HOSTNAME` setting for use in the server:port stanza.
|
||||||
- Changed all `at_before/after_*` hooks to `at_pre/post_*` for consistency
|
- Changed all `at_before/after_*` hooks to `at_pre/post_*` for consistency
|
||||||
across Evennia (the old names still work but are deprecated)
|
across Evennia (the old names still work but are deprecated)
|
||||||
|
- Change `settings.COMMAND_DEFAULT_ARG_REGEX` default from `None` to a regex meaning that
|
||||||
|
a space or `/` must separate the cmdname and args. This better fits common expectations.
|
||||||
|
|
||||||
|
|
||||||
### Evennia 0.9.5 (2019-2020)
|
### Evennia 0.9.5 (2019-2020)
|
||||||
|
|
|
||||||
|
|
@ -216,13 +216,18 @@ class CmdBan(COMMAND_DEFAULT_CLASS):
|
||||||
ipregex = ipregex.replace("*", "[0-9]{1,3}")
|
ipregex = ipregex.replace("*", "[0-9]{1,3}")
|
||||||
ipregex = re.compile(r"%s" % ipregex)
|
ipregex = re.compile(r"%s" % ipregex)
|
||||||
bantup = ("", ban, ipregex, now, reason)
|
bantup = ("", ban, ipregex, now, reason)
|
||||||
|
|
||||||
|
ret = yield(f"Are you sure you want to {typ}-ban '|w{ban}|n' [Y]/N?")
|
||||||
|
if str(ret).lower() in ("no", "n"):
|
||||||
|
self.caller.msg("Aborted.")
|
||||||
|
return
|
||||||
|
|
||||||
# save updated banlist
|
# save updated banlist
|
||||||
banlist.append(bantup)
|
banlist.append(bantup)
|
||||||
ServerConfig.objects.conf("server_bans", banlist)
|
ServerConfig.objects.conf("server_bans", banlist)
|
||||||
self.caller.msg("%s-Ban |w%s|n was added." % (typ, ban))
|
self.caller.msg(f"{typ}-ban '|w{ban}|n' was added. Use |wunban|n to reinstate.")
|
||||||
logger.log_sec(
|
logger.log_sec(
|
||||||
"Banned %s: %s (Caller: %s, IP: %s)."
|
"Banned {typ}: {ban.strip()} (Caller: {self.caller}, IP: {self.session.address})."
|
||||||
% (typ, ban.strip(), self.caller, self.session.address)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -264,15 +269,20 @@ class CmdUnban(COMMAND_DEFAULT_CLASS):
|
||||||
elif not (0 < num < len(banlist) + 1):
|
elif not (0 < num < len(banlist) + 1):
|
||||||
self.caller.msg("Ban id |w%s|x was not found." % self.args)
|
self.caller.msg("Ban id |w%s|x was not found." % self.args)
|
||||||
else:
|
else:
|
||||||
# all is ok, clear ban
|
# all is ok, ask, then clear ban
|
||||||
ban = banlist[num - 1]
|
ban = banlist[num - 1]
|
||||||
|
value = " ".join([s for s in ban[:2]])
|
||||||
|
|
||||||
|
ret = yield(f"Are you sure you want to unban {num}: '{value}' [Y]/N?")
|
||||||
|
if str(ret).lower() in ("n", "no"):
|
||||||
|
self.caller.msg("Aborted.")
|
||||||
|
return
|
||||||
|
|
||||||
del banlist[num - 1]
|
del banlist[num - 1]
|
||||||
ServerConfig.objects.conf("server_bans", banlist)
|
ServerConfig.objects.conf("server_bans", banlist)
|
||||||
value = " ".join([s for s in ban[:2]])
|
self.caller.msg(f"Cleared ban {num}: '{value}'" % (num, value))
|
||||||
self.caller.msg("Cleared ban %s: %s" % (num, value))
|
|
||||||
logger.log_sec(
|
logger.log_sec(
|
||||||
"Unbanned: %s (Caller: %s, IP: %s)."
|
"Unbanned: {value.strip()} (Caller: {self.caller}, IP: {self.session.address})."
|
||||||
% (value.strip(), self.caller, self.session.address)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -586,6 +586,9 @@ class CmdSay(COMMAND_DEFAULT_CLASS):
|
||||||
aliases = ['"', "'"]
|
aliases = ['"', "'"]
|
||||||
locks = "cmd:all()"
|
locks = "cmd:all()"
|
||||||
|
|
||||||
|
# don't require a space after `say/'/"`
|
||||||
|
arg_regex = None
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"""Run the say command"""
|
"""Run the say command"""
|
||||||
|
|
||||||
|
|
@ -671,6 +674,10 @@ class CmdPose(COMMAND_DEFAULT_CLASS):
|
||||||
aliases = [":", "emote"]
|
aliases = [":", "emote"]
|
||||||
locks = "cmd:all()"
|
locks = "cmd:all()"
|
||||||
|
|
||||||
|
# we want to be able to pose without whitespace between
|
||||||
|
# the command/alias and the pose (e.g. :pose)
|
||||||
|
arg_regex = None
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
"""
|
"""
|
||||||
Custom parse the cases where the emote
|
Custom parse the cases where the emote
|
||||||
|
|
|
||||||
|
|
@ -761,7 +761,7 @@ class TestAdmin(CommandTest):
|
||||||
self.call(admin.CmdWall(), "Test", "Announcing to all connected sessions ...")
|
self.call(admin.CmdWall(), "Test", "Announcing to all connected sessions ...")
|
||||||
|
|
||||||
def test_ban(self):
|
def test_ban(self):
|
||||||
self.call(admin.CmdBan(), "Char", "Name-Ban char was added.")
|
self.call(admin.CmdBan(), "Char", "Name-ban 'char' was added. Use unban to reinstate.")
|
||||||
|
|
||||||
def test_force(self):
|
def test_force(self):
|
||||||
cid = self.char2.id
|
cid = self.char2.id
|
||||||
|
|
|
||||||
|
|
@ -1092,18 +1092,22 @@ class AccessableCommand(Command):
|
||||||
|
|
||||||
class _CmdTest1(AccessableCommand):
|
class _CmdTest1(AccessableCommand):
|
||||||
key = "test1"
|
key = "test1"
|
||||||
|
arg_regex = None
|
||||||
|
|
||||||
|
|
||||||
class _CmdTest2(AccessableCommand):
|
class _CmdTest2(AccessableCommand):
|
||||||
key = "another command"
|
key = "another command"
|
||||||
|
arg_regex = None
|
||||||
|
|
||||||
|
|
||||||
class _CmdTest3(AccessableCommand):
|
class _CmdTest3(AccessableCommand):
|
||||||
key = "&the third command"
|
key = "&the third command"
|
||||||
|
arg_regex = None
|
||||||
|
|
||||||
|
|
||||||
class _CmdTest4(AccessableCommand):
|
class _CmdTest4(AccessableCommand):
|
||||||
key = "test2"
|
key = "test2"
|
||||||
|
arg_regex = None
|
||||||
|
|
||||||
|
|
||||||
class _CmdSetTest(CmdSet):
|
class _CmdSetTest(CmdSet):
|
||||||
|
|
|
||||||
|
|
@ -476,9 +476,9 @@ CMDSET_FALLBACKS = {
|
||||||
COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand"
|
COMMAND_DEFAULT_CLASS = "evennia.commands.default.muxcommand.MuxCommand"
|
||||||
# Command.arg_regex is a regular expression desribing how the arguments
|
# Command.arg_regex is a regular expression desribing how the arguments
|
||||||
# to the command must be structured for the command to match a given user
|
# to the command must be structured for the command to match a given user
|
||||||
# input. By default there is no restriction as long as the input string
|
# input. By default the command-name should end with a space or / (since the
|
||||||
# starts with the command name.
|
# default commands uses MuxCommand and /switches).
|
||||||
COMMAND_DEFAULT_ARG_REGEX = None
|
COMMAND_DEFAULT_ARG_REGEX = r'^[ /]+.*$|$'
|
||||||
# By default, Command.msg will only send data to the Session calling
|
# By default, Command.msg will only send data to the Session calling
|
||||||
# the Command in the first place. If set, Command.msg will instead return
|
# the Command in the first place. If set, Command.msg will instead return
|
||||||
# data to all Sessions connected to the Account/Character associated with
|
# data to all Sessions connected to the Account/Character associated with
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue