Allow scripts command to operate on range dbrefs. Resolve #2397.

This commit is contained in:
Griatch 2022-01-09 00:49:57 +01:00
parent e70337b6d2
commit 7b014f0fa0
2 changed files with 26 additions and 1 deletions

View file

@ -3129,6 +3129,7 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
script/stop myobj = scriptname - stop script on object
script/pause foo.Bar.Script - pause global script
script/delete myobj - delete ALL scripts on object
script/delete #dbref[-#dbref] - delete script or range by dbref
When given with an `<obj>` as left-hand-side, this creates and
assigns a new script to that object. Without an `<obj>`, this
@ -3170,6 +3171,13 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
scripts = ScriptDB.objects.filter(db_typeclass_path__iendswith=args)
if scripts:
return scripts
if "-" in args:
# may be a dbref-range
val1, val2 = (dbref(part.strip()) for part in args.split('-', 1))
if val1 and val2:
scripts = ScriptDB.objects.filter(id__in=(range(val1, val2 + 1)))
if scripts:
return scripts
def func(self):
"""implement method"""