Add is_ooc lockfunc, because why not

This commit is contained in:
Griatch 2022-02-22 23:01:53 +01:00
parent 98c20ffa21
commit 8ea578c75f
2 changed files with 19 additions and 0 deletions

View file

@ -158,6 +158,7 @@ Up requirements to Django 4.0+, Twisted 22+, Python 3.9 or 3.10
- Have `type/force` default to `update`-mode rather than `reset`mode and add more verbose
warning when using reset mode.
- Attribute storage support defaultdics (Hendher)
- Add `is_ooc` lockfunc (meant for limiting commands at the OOC level)
## Evennia 0.9.5

View file

@ -473,6 +473,24 @@ def tag(accessing_obj, accessed_obj, *args, **kwargs):
category = args[1] if len(args) > 1 else None
return bool(accessing_obj.tags.get(tagkey, category=category))
def is_ooc(accessing_obj, accessed_obj, *args, **kwargs):
"""
Usage:
is_ooc()
This is normally used to lock a Command, so it can be used
only when out of character.
"""
obj = accessed_obj.obj if hasattr(accessed_obj, "obj") else accessed_obj
session = obj.session if hasattr(obj, "session") else obj
try:
return not obj.get_puppet(session)
except AttributeError:
try:
return not obj.account.get_puppet(session)
except AttributeError:
pass
return False
def objtag(accessing_obj, accessed_obj, *args, **kwargs):
"""