+ for portal in sorted(
+ actor.universe.contents[actor.get("location")].portals()):
+ if portal.startswith(parameters):
+ actor.move_direction(portal)
+ return(portal)
+ actor.send("You cannot go that way.")
+
+
+def preferences(actor, parameters):
+ """List, view and change actor preferences."""
+
+ # Escape replacement macros in preferences
+ parameters = mudpy.misc.escape_macros(parameters)
+
+ message = ""
+ arguments = parameters.split()
+ allowed_prefs = set()
+ user_config = actor.universe.contents.get("mudpy.user")
+ if user_config:
+ allowed_prefs.update(user_config.get("pref_allow", []))
+ 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)))
+ 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])