message = ""
arguments = parameters.split()
allowed_prefs = set()
+ base_prefs = []
user_config = actor.universe.contents.get("mudpy.user")
if user_config:
- allowed_prefs.update(user_config.get("pref_allow", []))
+ base_prefs = user_config.get("pref_allow", [])
+ allowed_prefs.update(base_prefs)
if actor.owner.account.get("administrator"):
allowed_prefs.update(user_config.get("pref_admin", []))
if not arguments:
message += "These are your current preferences:"
- for pref in allowed_prefs:
- message += ("$(eol) $(red)%s $(grn)%s$(nrm)"
- % (pref, actor.owner.account.get(pref)))
+
+ # color-code base and admin prefs
+ for pref in sorted(allowed_prefs):
+ if pref in base_prefs:
+ color = "grn"
+ else:
+ color = "red"
+ message += ("$(eol) $(%s)%s$(nrm) - %s" % (
+ color, pref, actor.owner.account.get(pref, "<not set>")))
+
elif arguments[0] not in allowed_prefs:
message += (
'Preference "%s" does not exist. Try the `preferences` command by '
"itself for a list of valid preferences." % arguments[0])
elif len(arguments) == 1:
- message += "%s" % actor.owner.account.get(arguments[0])
+ message += "%s" % actor.owner.account.get(arguments[0], "<not set>")
else:
pref = arguments[0]
value = " ".join(arguments[1:])
test_preferences = (
(0, "> ", "preferences"),
- (0, r"prompt \x1b\[32m.*> ", "preferences prompt $(foo)"),
+ (0, r"\[32mprompt\x1b\[0m - <not set>.*> ", "preferences prompt $(foo)"),
(0, r"\$\(foo\) ", "preferences prompt"),
(0, r"\$\(foo\).*\$\(foo\) ", "preferences prompt $(time)>"),
- (0, "[0-9]> ", "preferences prompt >"),
+ (0, "[0-9]> ", "preferences loglevel 0"),
+ (0, "does not exist.*> ", "preferences prompt >"),
(2, "> ", "preferences loglevel 0"),
(2, "> ", "preferences"),
- (2, r"loglevel \x1b\[32m0\x1b\[0m.*> ", "preferences loglevel zero"),
+ (2, r"\[31mloglevel\x1b\[0m - 0.*> ", "preferences loglevel zero"),
(2, r'''cannot be set to type "<class 'str'>"\..*> ''', ""),
)