configuration
===============
-.. Copyright (c) 2004-2018 mudpy authors. Permission to use, copy,
+.. Copyright (c) 2004-2019 mudpy authors. Permission to use, copy,
modify, and distribute this software is granted under terms
provided in the LICENSE file distributed with this software.
Example::
.mudpy.timing.status: 6000
+
+.mudpy.user
+-----------
+
+.mudpy.user.pref_admin
+~~~~~~~~~~~~~~~~~~~~~~
+
+list, optional
+
+This can be used to list facets an administrative user is allowed to
+set or override on their own ``account`` element, in addition to any
+in the `.mudpy.user.pref_allow`_ list. Note that this is merely a
+convenience, as an administrator is already able to call the ``set``
+command to set values for facets of any element.
+
+Example::
+
+ .mudpy.user.pref_admin:
+ - loglevel
+
+.mudpy.user.pref_allow
+~~~~~~~~~~~~~~~~~~~~~~
+
+list, optional
+
+This can be used to list facets any user is allowed to set or
+override on their own ``account`` element with the ``preference``
+command.
+
+Example::
+
+ .mudpy.user.pref_allow:
+ - prompt
data model
============
-.. Copyright (c) 2004-2018 mudpy authors. Permission to use, copy,
+.. Copyright (c) 2004-2019 mudpy authors. Permission to use, copy,
modify, and distribute this software is granted under terms
provided in the LICENSE file distributed with this software.
Timing-specific settings and scheduling for the main loop.
+.mudpy.user
+~~~~~~~~~~~
+
+User-focused settings such as access controls.
+
storage
-------
---
-_copy: Copyright (c) 2004-2017 mudpy authors. Permission to use, copy,
+_copy: Copyright (c) 2004-2019 mudpy authors. Permission to use, copy,
modify, and distribute this software is granted under terms
provided in the LICENSE file distributed with this software.
.mudpy.timing.increment: 0.1
.mudpy.timing.save: 600
.mudpy.timing.status: 6000
+
+.mudpy.user.pref_admin:
+ - loglevel
+.mudpy.user.pref_allow:
+ - prompt
actor.send("You cannot go that way.")
+def preferences(actor, parameters):
+ """List, view and change actor preferences."""
+ 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])
+ else:
+ pref = arguments[0]
+ value = " ".join(arguments[1:])
+ try:
+ actor.owner.account.set(pref, value)
+ message += 'Preference "%s" set to "%s".' % (pref, value)
+ except ValueError:
+ message = (
+ 'Preference "%s" cannot be set to type "%s".' % (
+ pref, type(value)))
+ actor.send(message)
+
+
def quit(actor):
"""Leave the world and go back to the main menu."""
if actor.owner:
"""Miscellaneous functions for the mudpy engine."""
-# Copyright (c) 2004-2018 mudpy authors. Permission to use, copy,
+# Copyright (c) 2004-2019 mudpy authors. Permission to use, copy,
# modify, and distribute this software is granted under terms
# provided in the LICENSE file distributed with this software.
if not just_prompt:
output += "$(eol)"
if add_prompt:
- output += "> "
+ output += self.account.get("prompt", ">") + " "
mode = self.avatar.get("mode")
if mode:
output += "(" + mode + ") "
---
-_copy: Copyright (c) 2004-2017 mudpy authors. Permission to use, copy,
+_copy: Copyright (c) 2004-2019 mudpy authors. Permission to use, copy,
modify, and distribute this software is granted under terms
provided in the LICENSE file distributed with this software.
.mudpy.timing.increment: 0.1
.mudpy.timing.save: 5
.mudpy.timing.status: 25
+
+.mudpy.user.pref_admin:
+ - loglevel
+.mudpy.user.pref_allow:
+ - prompt
-# Copyright (c) 2004-2018 mudpy authors. Permission to use, copy,
+# Copyright (c) 2004-2019 mudpy authors. Permission to use, copy,
# modify, and distribute this software is granted under terms
# provided in the LICENSE file distributed with this software.
(2, "Whom would you like to awaken?", ""),
)
+test_preferences = (
+ (0, "> ", "preferences"),
+ (0, r"prompt \x1b\[32m.*> ", "preferences prompt #"),
+ (0, r"# ", "preferences prompt"),
+ (0, r"#.*# ", "preferences prompt >"),
+ (2, "> ", "preferences loglevel 0"),
+ (2, "> ", "preferences"),
+ (2, r"loglevel \x1b\[32m0\x1b\[0m.*> ", "preferences loglevel zero"),
+ (2, r'''cannot be set to type "<class 'str'>"\..*> ''', ""),
+)
+
test_crlf_eol = (
# Send a CR+LF at the end of the line instead of the default CR+NUL,
# to make sure they're treated the same
(test_actor_disappears, "actor spontaneous disappearance"),
(test_account1_teardown, "second account teardown"),
(test_admin_setup, "admin account setup"),
+ (test_preferences, "set and show preferences"),
(test_crlf_eol, "send crlf from the client as eol"),
(test_telnet_iac, "escape stray telnet iac bytes"),
(test_telnet_unknown, "strip unknown telnet command"),
command.move.help: You move in a direction by entering:$(eol)$(eol) move
north
+command.preferences.action: mudpy.command.preferences(actor, parameters)
+command.preferences.description: View or change your preferences.
+command.preferences.help: If invoked with no parameters, all your current
+ preferences and their values are listed. If one parameter is supplied, the
+ value of the preference with that name is displayed. If more than one
+ parameter is supplied, the first must be the name of a preference and the
+ remainder is the value to which you wish to change it.
+ Examples:$(eol)$(eol) preferences$(eol) preferences
+ prompt$(eol) preferences prompt $
+
command.quit.action: mudpy.command.quit(actor)
command.quit.description: Leave the World.
command.quit.help: This will deactivate your avatar and return you to the main