Make scripts/objects lists use EvMore. Change EvMore to not justify by default.
This commit is contained in:
parent
b5aee2c41e
commit
69d85bd184
221 changed files with 2190 additions and 6810 deletions
|
|
@ -72,9 +72,9 @@ class MuxAccountLookCommand(COMMAND_DEFAULT_CLASS):
|
|||
self.account.db._playable_characters = playable
|
||||
# store playable property
|
||||
if self.args:
|
||||
self.playable = dict(
|
||||
(utils.to_str(char.key.lower()), char) for char in playable
|
||||
).get(self.args.lower(), None)
|
||||
self.playable = dict((utils.to_str(char.key.lower()), char) for char in playable).get(
|
||||
self.args.lower(), None
|
||||
)
|
||||
else:
|
||||
self.playable = playable
|
||||
|
||||
|
|
@ -113,9 +113,7 @@ class CmdOOCLook(MuxAccountLookCommand):
|
|||
|
||||
if _MULTISESSION_MODE < 2:
|
||||
# only one character allowed
|
||||
self.msg(
|
||||
"You are out-of-character (OOC).\nUse |wic|n to get back into the game."
|
||||
)
|
||||
self.msg("You are out-of-character (OOC).\nUse |wic|n to get back into the game.")
|
||||
return
|
||||
|
||||
# call on-account look helper method
|
||||
|
|
@ -154,8 +152,7 @@ class CmdCharCreate(COMMAND_DEFAULT_CLASS):
|
|||
charmax = _MAX_NR_CHARACTERS
|
||||
|
||||
if not account.is_superuser and (
|
||||
account.db._playable_characters
|
||||
and len(account.db._playable_characters) >= charmax
|
||||
account.db._playable_characters and len(account.db._playable_characters) >= charmax
|
||||
):
|
||||
self.msg("You may only create a maximum of %i characters." % charmax)
|
||||
return
|
||||
|
|
@ -175,11 +172,7 @@ class CmdCharCreate(COMMAND_DEFAULT_CLASS):
|
|||
default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME)
|
||||
permissions = settings.PERMISSION_ACCOUNT_DEFAULT
|
||||
new_character = create.create_object(
|
||||
typeclass,
|
||||
key=key,
|
||||
location=start_location,
|
||||
home=default_home,
|
||||
permissions=permissions,
|
||||
typeclass, key=key, location=start_location, home=default_home, permissions=permissions
|
||||
)
|
||||
# only allow creator (and developers) to puppet this char
|
||||
new_character.locks.add(
|
||||
|
|
@ -266,7 +259,9 @@ class CmdCharDelete(COMMAND_DEFAULT_CLASS):
|
|||
self.msg("You do not have permission to delete this character.")
|
||||
return
|
||||
|
||||
prompt = "|rThis will permanently destroy '%s'. This cannot be undone.|n Continue yes/[no]?"
|
||||
prompt = (
|
||||
"|rThis will permanently destroy '%s'. This cannot be undone.|n Continue yes/[no]?"
|
||||
)
|
||||
get_input(account, prompt % match.key, _callback)
|
||||
|
||||
|
||||
|
|
@ -313,9 +308,7 @@ class CmdIC(COMMAND_DEFAULT_CLASS):
|
|||
if not new_character:
|
||||
# search for a matching character
|
||||
new_character = [
|
||||
char
|
||||
for char in search.object_search(self.args)
|
||||
if char.access(account, "puppet")
|
||||
char for char in search.object_search(self.args) if char.access(account, "puppet")
|
||||
]
|
||||
if not new_character:
|
||||
self.msg("That is not a valid character choice.")
|
||||
|
|
@ -386,9 +379,7 @@ class CmdOOC(MuxAccountLookCommand):
|
|||
|
||||
if _MULTISESSION_MODE < 2:
|
||||
# only one character allowed
|
||||
self.msg(
|
||||
"You are out-of-character (OOC).\nUse |wic|n to get back into the game."
|
||||
)
|
||||
self.msg("You are out-of-character (OOC).\nUse |wic|n to get back into the game.")
|
||||
return
|
||||
|
||||
self.msg(account.at_look(target=self.playable, session=session))
|
||||
|
|
@ -466,9 +457,9 @@ class CmdWho(COMMAND_DEFAULT_CLASS):
|
|||
if self.cmdstring == "doing":
|
||||
show_session_data = False
|
||||
else:
|
||||
show_session_data = account.check_permstring(
|
||||
"Developer"
|
||||
) or account.check_permstring("Admins")
|
||||
show_session_data = account.check_permstring("Developer") or account.check_permstring(
|
||||
"Admins"
|
||||
)
|
||||
|
||||
naccounts = SESSIONS.account_count()
|
||||
if show_session_data:
|
||||
|
|
@ -495,15 +486,11 @@ class CmdWho(COMMAND_DEFAULT_CLASS):
|
|||
utils.crop(account.get_display_name(account), width=25),
|
||||
utils.time_format(delta_conn, 0),
|
||||
utils.time_format(delta_cmd, 1),
|
||||
utils.crop(
|
||||
puppet.get_display_name(account) if puppet else "None", width=25
|
||||
),
|
||||
utils.crop(puppet.get_display_name(account) if puppet else "None", width=25),
|
||||
utils.crop(location, width=25),
|
||||
session.cmd_total,
|
||||
session.protocol_key,
|
||||
isinstance(session.address, tuple)
|
||||
and session.address[0]
|
||||
or session.address,
|
||||
isinstance(session.address, tuple) and session.address[0] or session.address,
|
||||
)
|
||||
else:
|
||||
# unprivileged
|
||||
|
|
@ -575,9 +562,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
|||
self.msg("|gCleared all saved options.")
|
||||
|
||||
options = dict(flags) # make a copy of the flag dict
|
||||
saved_options = dict(
|
||||
self.caller.attributes.get("_saved_protocol_flags", default={})
|
||||
)
|
||||
saved_options = dict(self.caller.attributes.get("_saved_protocol_flags", default={}))
|
||||
|
||||
if "SCREENWIDTH" in options:
|
||||
if len(options["SCREENWIDTH"]) == 1:
|
||||
|
|
@ -604,15 +589,11 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
|||
if saved_options:
|
||||
saved = " |YYes|n" if key in saved_options else ""
|
||||
changed = (
|
||||
"|y*|n"
|
||||
if key in saved_options and flags[key] != saved_options[key]
|
||||
else ""
|
||||
"|y*|n" if key in saved_options and flags[key] != saved_options[key] else ""
|
||||
)
|
||||
row.append("%s%s" % (saved, changed))
|
||||
table.add_row(*row)
|
||||
self.msg(
|
||||
"|wClient settings (%s):|n\n%s|n" % (self.session.protocol_key, table)
|
||||
)
|
||||
self.msg("|wClient settings (%s):|n\n%s|n" % (self.session.protocol_key, table))
|
||||
|
||||
return
|
||||
|
||||
|
|
@ -642,9 +623,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
|||
old_val = flags.get(new_name, False)
|
||||
new_val = validator(new_val)
|
||||
if old_val == new_val:
|
||||
self.msg(
|
||||
"Option |w%s|n was kept as '|w%s|n'." % (new_name, old_val)
|
||||
)
|
||||
self.msg("Option |w%s|n was kept as '|w%s|n'." % (new_name, old_val))
|
||||
else:
|
||||
flags[new_name] = new_val
|
||||
self.msg(
|
||||
|
|
@ -688,9 +667,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
|||
# a valid setting
|
||||
if "save" in self.switches:
|
||||
# save this option only
|
||||
saved_options = self.account.attributes.get(
|
||||
"_saved_protocol_flags", default={}
|
||||
)
|
||||
saved_options = self.account.attributes.get("_saved_protocol_flags", default={})
|
||||
saved_options.update(optiondict)
|
||||
self.account.attributes.add("_saved_protocol_flags", saved_options)
|
||||
for key in optiondict:
|
||||
|
|
@ -698,9 +675,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS):
|
|||
if "clear" in self.switches:
|
||||
# clear this save
|
||||
for key in optiondict:
|
||||
self.account.attributes.get("_saved_protocol_flags", {}).pop(
|
||||
key, None
|
||||
)
|
||||
self.account.attributes.get("_saved_protocol_flags", {}).pop(key, None)
|
||||
self.msg("|gCleared saved %s." % key)
|
||||
self.session.update_flags(**optiondict)
|
||||
|
||||
|
|
@ -777,8 +752,7 @@ class CmdQuit(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
if "all" in self.switches:
|
||||
account.msg(
|
||||
"|RQuitting|n all sessions. Hope to see you soon again.",
|
||||
session=self.session,
|
||||
"|RQuitting|n all sessions. Hope to see you soon again.", session=self.session
|
||||
)
|
||||
reason = "quit/all"
|
||||
for session in account.sessions.all():
|
||||
|
|
@ -787,10 +761,7 @@ class CmdQuit(COMMAND_DEFAULT_CLASS):
|
|||
nsess = len(account.sessions.all())
|
||||
reason = "quit"
|
||||
if nsess == 2:
|
||||
account.msg(
|
||||
"|RQuitting|n. One session is still connected.",
|
||||
session=self.session,
|
||||
)
|
||||
account.msg("|RQuitting|n. One session is still connected.", session=self.session)
|
||||
elif nsess > 2:
|
||||
account.msg(
|
||||
"|RQuitting|n. %i sessions are still connected." % (nsess - 1),
|
||||
|
|
@ -798,9 +769,7 @@ class CmdQuit(COMMAND_DEFAULT_CLASS):
|
|||
)
|
||||
else:
|
||||
# we are quitting the last available session
|
||||
account.msg(
|
||||
"|RQuitting|n. Hope to see you again, soon.", session=self.session
|
||||
)
|
||||
account.msg("|RQuitting|n. Hope to see you again, soon.", session=self.session)
|
||||
account.disconnect_session_from_account(self.session, reason)
|
||||
|
||||
|
||||
|
|
@ -872,13 +841,11 @@ class CmdColorTest(COMMAND_DEFAULT_CLASS):
|
|||
for code, _ in ap.ansi_map[self.slice_dark_fg]
|
||||
]
|
||||
dark_bg = [
|
||||
"%s%s|n"
|
||||
% (code.replace("\\", ""), code.replace("|", "||").replace("\\", ""))
|
||||
"%s%s|n" % (code.replace("\\", ""), code.replace("|", "||").replace("\\", ""))
|
||||
for code, _ in ap.ansi_map[self.slice_dark_bg]
|
||||
]
|
||||
bright_bg = [
|
||||
"%s%s|n"
|
||||
% (code.replace("\\", ""), code.replace("|", "||").replace("\\", ""))
|
||||
"%s%s|n" % (code.replace("\\", ""), code.replace("|", "||").replace("\\", ""))
|
||||
for code, _ in ap.ansi_xterm256_bright_bg_map[self.slice_bright_bg]
|
||||
]
|
||||
dark_fg.extend(["" for _ in range(len(bright_fg) - len(dark_fg))])
|
||||
|
|
@ -900,21 +867,11 @@ class CmdColorTest(COMMAND_DEFAULT_CLASS):
|
|||
for ig in range(6):
|
||||
for ib in range(6):
|
||||
# foreground table
|
||||
table[ir].append(
|
||||
"|%i%i%i%s|n" % (ir, ig, ib, "||%i%i%i" % (ir, ig, ib))
|
||||
)
|
||||
table[ir].append("|%i%i%i%s|n" % (ir, ig, ib, "||%i%i%i" % (ir, ig, ib)))
|
||||
# background table
|
||||
table[6 + ir].append(
|
||||
"|%i%i%i|[%i%i%i%s|n"
|
||||
% (
|
||||
5 - ir,
|
||||
5 - ig,
|
||||
5 - ib,
|
||||
ir,
|
||||
ig,
|
||||
ib,
|
||||
"||[%i%i%i" % (ir, ig, ib),
|
||||
)
|
||||
% (5 - ir, 5 - ig, 5 - ib, ir, ig, ib, "||[%i%i%i" % (ir, ig, ib))
|
||||
)
|
||||
table = self.table_format(table)
|
||||
string = "Xterm256 colors (if not all hues show, your client might not report that it can handle xterm256):"
|
||||
|
|
@ -925,9 +882,7 @@ class CmdColorTest(COMMAND_DEFAULT_CLASS):
|
|||
letter = chr(97 + (ibatch * 6 + igray))
|
||||
inverse = chr(122 - (ibatch * 6 + igray))
|
||||
table[0 + igray].append("|=%s%s |n" % (letter, "||=%s" % letter))
|
||||
table[6 + igray].append(
|
||||
"|=%s|[=%s%s |n" % (inverse, letter, "||[=%s" % letter)
|
||||
)
|
||||
table[6 + igray].append("|=%s|[=%s%s |n" % (inverse, letter, "||[=%s" % letter))
|
||||
for igray in range(6):
|
||||
# the last row (y, z) has empty columns
|
||||
if igray < 2:
|
||||
|
|
@ -1013,10 +968,7 @@ class CmdQuell(COMMAND_DEFAULT_CLASS):
|
|||
cpermstr += "\nUse unquell to return to normal permission usage."
|
||||
self.msg(cpermstr)
|
||||
else:
|
||||
self.msg(
|
||||
"Quelling Account permissions%s. Use unquell to get them back."
|
||||
% permstr
|
||||
)
|
||||
self.msg("Quelling Account permissions%s. Use unquell to get them back." % permstr)
|
||||
self._recache_locks(account)
|
||||
|
||||
|
||||
|
|
@ -1047,10 +999,7 @@ class CmdStyle(COMMAND_DEFAULT_CLASS):
|
|||
for op_key in self.account.options.options_dict.keys():
|
||||
op_found = self.account.options.get(op_key, return_obj=True)
|
||||
table.add_row(
|
||||
op_key,
|
||||
op_found.description,
|
||||
op_found.__class__.__name__,
|
||||
op_found.display(),
|
||||
op_key, op_found.description, op_found.__class__.__name__, op_found.display()
|
||||
)
|
||||
self.msg(str(table))
|
||||
|
||||
|
|
|
|||
|
|
@ -89,9 +89,7 @@ class CmdBoot(COMMAND_DEFAULT_CLASS):
|
|||
boot_list.append(match)
|
||||
|
||||
if not boot_list:
|
||||
caller.msg(
|
||||
"No matching sessions found. The Account does not seem to be online."
|
||||
)
|
||||
caller.msg("No matching sessions found. The Account does not seem to be online.")
|
||||
return
|
||||
|
||||
# Carry out the booting of the sessions in the boot list.
|
||||
|
|
@ -192,8 +190,7 @@ class CmdBan(COMMAND_DEFAULT_CLASS):
|
|||
banlist = []
|
||||
|
||||
if not self.args or (
|
||||
self.switches
|
||||
and not any(switch in ("ip", "name") for switch in self.switches)
|
||||
self.switches and not any(switch in ("ip", "name") for switch in self.switches)
|
||||
):
|
||||
self.caller.msg(list_bans(self, banlist))
|
||||
return
|
||||
|
|
@ -402,12 +399,9 @@ class CmdNewPassword(COMMAND_DEFAULT_CLASS):
|
|||
account.save()
|
||||
self.msg("%s - new password set to '%s'." % (account.name, newpass))
|
||||
if account.character != caller:
|
||||
account.msg(
|
||||
"%s has changed your password to '%s'." % (caller.name, newpass)
|
||||
)
|
||||
account.msg("%s has changed your password to '%s'." % (caller.name, newpass))
|
||||
logger.log_sec(
|
||||
"Password Changed: %s (Caller: %s, IP: %s)."
|
||||
% (account, caller, self.session.address)
|
||||
"Password Changed: %s (Caller: %s, IP: %s)." % (account, caller, self.session.address)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -492,17 +486,14 @@ class CmdPerm(COMMAND_DEFAULT_CLASS):
|
|||
obj.permissions.remove(perm)
|
||||
if obj.permissions.get(perm):
|
||||
caller_result.append(
|
||||
"\nPermissions %s could not be removed from %s."
|
||||
% (perm, obj.name)
|
||||
"\nPermissions %s could not be removed from %s." % (perm, obj.name)
|
||||
)
|
||||
else:
|
||||
caller_result.append(
|
||||
"\nPermission %s removed from %s (if they existed)."
|
||||
% (perm, obj.name)
|
||||
"\nPermission %s removed from %s (if they existed)." % (perm, obj.name)
|
||||
)
|
||||
target_result.append(
|
||||
"\n%s revokes the permission(s) %s from you."
|
||||
% (caller.name, perm)
|
||||
"\n%s revokes the permission(s) %s from you." % (caller.name, perm)
|
||||
)
|
||||
logger.log_sec(
|
||||
"Permissions Deleted: %s, %s (Caller: %s, IP: %s)."
|
||||
|
|
@ -532,8 +523,7 @@ class CmdPerm(COMMAND_DEFAULT_CLASS):
|
|||
obj.permissions.add(perm)
|
||||
plystring = "the Account" if accountmode else "the Object/Character"
|
||||
caller_result.append(
|
||||
"\nPermission '%s' given to %s (%s)."
|
||||
% (perm, obj.name, plystring)
|
||||
"\nPermission '%s' given to %s (%s)." % (perm, obj.name, plystring)
|
||||
)
|
||||
target_result.append(
|
||||
"\n%s gives you (%s, %s) the permission '%s'."
|
||||
|
|
@ -593,17 +583,13 @@ class CmdForce(COMMAND_DEFAULT_CLASS):
|
|||
def func(self):
|
||||
"""Implements the force command"""
|
||||
if not self.lhs or not self.rhs:
|
||||
self.caller.msg(
|
||||
"You must provide a target and a command string to execute."
|
||||
)
|
||||
self.caller.msg("You must provide a target and a command string to execute.")
|
||||
return
|
||||
targ = self.caller.search(self.lhs)
|
||||
if not targ:
|
||||
return
|
||||
if not targ.access(self.caller, self.perm_used):
|
||||
self.caller.msg(
|
||||
"You don't have permission to force them to execute commands."
|
||||
)
|
||||
self.caller.msg("You don't have permission to force them to execute commands.")
|
||||
return
|
||||
targ.execute_cmd(self.rhs)
|
||||
self.caller.msg("You have forced %s to: %s" % (targ, self.rhs))
|
||||
|
|
|
|||
|
|
@ -269,9 +269,7 @@ class CmdBatchCommands(_COMMAND_DEFAULT_CLASS):
|
|||
"%s'%s' could not load. You have to supply python paths "
|
||||
"from one of the defined batch-file directories\n (%s)."
|
||||
)
|
||||
caller.msg(
|
||||
string % (err, python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS))
|
||||
)
|
||||
caller.msg(string % (err, python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS)))
|
||||
return
|
||||
if not commands:
|
||||
caller.msg("File %s seems empty of valid commands." % python_path)
|
||||
|
|
@ -294,9 +292,7 @@ class CmdBatchCommands(_COMMAND_DEFAULT_CLASS):
|
|||
# Set interactive state directly
|
||||
caller.cmdset.add(BatchInteractiveCmdSet)
|
||||
|
||||
caller.msg(
|
||||
"\nBatch-command processor - Interactive mode for %s ..." % python_path
|
||||
)
|
||||
caller.msg("\nBatch-command processor - Interactive mode for %s ..." % python_path)
|
||||
show_curr(caller)
|
||||
else:
|
||||
caller.msg(
|
||||
|
|
@ -395,9 +391,7 @@ class CmdBatchCode(_COMMAND_DEFAULT_CLASS):
|
|||
"%s'%s' could not load. You have to supply python paths "
|
||||
"from one of the defined batch-file directories\n (%s)."
|
||||
)
|
||||
caller.msg(
|
||||
string % (err, python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS))
|
||||
)
|
||||
caller.msg(string % (err, python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS)))
|
||||
return
|
||||
if not codes:
|
||||
caller.msg("File %s seems empty of functional code." % python_path)
|
||||
|
|
@ -421,14 +415,10 @@ class CmdBatchCode(_COMMAND_DEFAULT_CLASS):
|
|||
# Set interactive state directly
|
||||
caller.cmdset.add(BatchInteractiveCmdSet)
|
||||
|
||||
caller.msg(
|
||||
"\nBatch-code processor - Interactive mode for %s ..." % python_path
|
||||
)
|
||||
caller.msg("\nBatch-code processor - Interactive mode for %s ..." % python_path)
|
||||
show_curr(caller)
|
||||
else:
|
||||
caller.msg(
|
||||
"Running Batch-code processor - Automatic mode for %s ..." % python_path
|
||||
)
|
||||
caller.msg("Running Batch-code processor - Automatic mode for %s ..." % python_path)
|
||||
|
||||
procpool = False
|
||||
if "PythonProcPool" in utils.server_services():
|
||||
|
|
@ -489,9 +479,7 @@ class CmdStateAbort(_COMMAND_DEFAULT_CLASS):
|
|||
def func(self):
|
||||
"""Exit back to default."""
|
||||
purge_processor(self.caller)
|
||||
self.caller.msg(
|
||||
"Exited processor and reset out active cmdset back to the default one."
|
||||
)
|
||||
self.caller.msg("Exited processor and reset out active cmdset back to the default one.")
|
||||
|
||||
|
||||
class CmdStateLL(_COMMAND_DEFAULT_CLASS):
|
||||
|
|
|
|||
|
|
@ -108,20 +108,12 @@ class ObjManipCommand(COMMAND_DEFAULT_CLASS):
|
|||
objdef, option = [part.strip() for part in objdef.rsplit(":", 1)]
|
||||
if ";" in objdef:
|
||||
objdef, aliases = [part.strip() for part in objdef.split(";", 1)]
|
||||
aliases = [
|
||||
alias.strip() for alias in aliases.split(";") if alias.strip()
|
||||
]
|
||||
aliases = [alias.strip() for alias in aliases.split(";") if alias.strip()]
|
||||
if "/" in objdef:
|
||||
objdef, attrs = [part.strip() for part in objdef.split("/", 1)]
|
||||
attrs = [
|
||||
part.strip().lower()
|
||||
for part in attrs.split("/")
|
||||
if part.strip()
|
||||
]
|
||||
attrs = [part.strip().lower() for part in attrs.split("/") if part.strip()]
|
||||
# store data
|
||||
obj_defs[iside].append(
|
||||
{"name": objdef, "option": option, "aliases": aliases}
|
||||
)
|
||||
obj_defs[iside].append({"name": objdef, "option": option, "aliases": aliases})
|
||||
obj_attrs[iside].append({"name": objdef, "attrs": attrs})
|
||||
|
||||
# store for future access
|
||||
|
|
@ -185,12 +177,7 @@ class CmdSetObjAlias(COMMAND_DEFAULT_CLASS):
|
|||
obj.get_display_name(caller),
|
||||
", ".join(
|
||||
"'%s'%s"
|
||||
% (
|
||||
alias,
|
||||
""
|
||||
if category is None
|
||||
else "[category:'%s']" % category,
|
||||
)
|
||||
% (alias, "" if category is None else "[category:'%s']" % category)
|
||||
for (alias, category) in aliases
|
||||
),
|
||||
)
|
||||
|
|
@ -231,9 +218,7 @@ class CmdSetObjAlias(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
# merge the old and new aliases (if any)
|
||||
old_aliases = obj.aliases.get(category=category, return_list=True)
|
||||
new_aliases = [
|
||||
alias.strip().lower() for alias in rhs.split(",") if alias.strip()
|
||||
]
|
||||
new_aliases = [alias.strip().lower() for alias in rhs.split(",") if alias.strip()]
|
||||
|
||||
# make the aliases only appear once
|
||||
old_aliases.extend(new_aliases)
|
||||
|
|
@ -339,10 +324,7 @@ class CmdCopy(ObjManipCommand):
|
|||
to_obj_aliases,
|
||||
)
|
||||
else:
|
||||
string = "There was an error copying %s to '%s'." % (
|
||||
from_obj_name,
|
||||
to_obj_name,
|
||||
)
|
||||
string = "There was an error copying %s to '%s'." % (from_obj_name, to_obj_name)
|
||||
# we are done, echo to user
|
||||
caller.msg(string)
|
||||
|
||||
|
|
@ -565,9 +547,7 @@ class CmdCreate(ObjManipCommand):
|
|||
|
||||
# lockstring of newly created objects, for easy overloading.
|
||||
# Will be formatted with the {id} of the creating object.
|
||||
new_obj_lockstring = (
|
||||
"control:id({id}) or perm(Admin);delete:id({id}) or perm(Admin)"
|
||||
)
|
||||
new_obj_lockstring = "control:id({id}) or perm(Admin);delete:id({id}) or perm(Admin)"
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
|
|
@ -660,9 +640,7 @@ class CmdDesc(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
def edit_handler(self):
|
||||
if self.rhs:
|
||||
self.msg(
|
||||
"|rYou may specify a value, or use the edit switch, " "but not both.|n"
|
||||
)
|
||||
self.msg("|rYou may specify a value, or use the edit switch, " "but not both.|n")
|
||||
return
|
||||
if self.args:
|
||||
obj = self.caller.search(self.args)
|
||||
|
|
@ -672,9 +650,7 @@ class CmdDesc(COMMAND_DEFAULT_CLASS):
|
|||
return
|
||||
|
||||
if not (obj.access(self.caller, "control") or obj.access(self.caller, "edit")):
|
||||
self.caller.msg(
|
||||
"You don't have permission to edit the description of %s." % obj.key
|
||||
)
|
||||
self.caller.msg("You don't have permission to edit the description of %s." % obj.key)
|
||||
|
||||
self.caller.db.evmenu_target = obj
|
||||
# launch the editor
|
||||
|
|
@ -715,9 +691,7 @@ class CmdDesc(COMMAND_DEFAULT_CLASS):
|
|||
obj.db.desc = desc
|
||||
caller.msg("The description was set on %s." % obj.get_display_name(caller))
|
||||
else:
|
||||
caller.msg(
|
||||
"You don't have permission to edit the description of %s." % obj.key
|
||||
)
|
||||
caller.msg("You don't have permission to edit the description of %s." % obj.key)
|
||||
|
||||
|
||||
class CmdDestroy(COMMAND_DEFAULT_CLASS):
|
||||
|
|
@ -798,13 +772,9 @@ class CmdDestroy(COMMAND_DEFAULT_CLASS):
|
|||
else:
|
||||
string += "\n%s was destroyed." % objname
|
||||
if had_exits:
|
||||
string += (
|
||||
" Exits to and from %s were destroyed as well." % objname
|
||||
)
|
||||
string += " Exits to and from %s were destroyed as well." % objname
|
||||
if had_objs:
|
||||
string += (
|
||||
" Objects inside %s were moved to their homes." % objname
|
||||
)
|
||||
string += " Objects inside %s were moved to their homes." % objname
|
||||
return string
|
||||
|
||||
objs = []
|
||||
|
|
@ -814,9 +784,7 @@ class CmdDestroy(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
if "-" in objname:
|
||||
# might be a range of dbrefs
|
||||
dmin, dmax = [
|
||||
utils.dbref(part, reqhash=False) for part in objname.split("-", 1)
|
||||
]
|
||||
dmin, dmax = [utils.dbref(part, reqhash=False) for part in objname.split("-", 1)]
|
||||
if dmin and dmax:
|
||||
for dbref in range(int(dmin), int(dmax + 1)):
|
||||
obj = caller.search("#" + str(dbref))
|
||||
|
|
@ -909,10 +877,7 @@ class CmdDig(ObjManipCommand):
|
|||
caller = self.caller
|
||||
|
||||
if not self.lhs:
|
||||
string = (
|
||||
"Usage: dig[/teleport] <roomname>[;alias;alias...]"
|
||||
"[:parent] [= <exit_there>"
|
||||
)
|
||||
string = "Usage: dig[/teleport] <roomname>[;alias;alias...]" "[:parent] [= <exit_there>"
|
||||
string += "[;alias;alias..][:parent]] "
|
||||
string += "[, <exit_back_here>[;alias;alias..][:parent]]"
|
||||
caller.msg(string)
|
||||
|
|
@ -992,9 +957,7 @@ class CmdDig(ObjManipCommand):
|
|||
if not back_exit["name"]:
|
||||
exit_back_string = "\nNo back exit created."
|
||||
elif not location:
|
||||
exit_back_string = (
|
||||
"\nYou cannot create an exit back to a None-location."
|
||||
)
|
||||
exit_back_string = "\nYou cannot create an exit back to a None-location."
|
||||
else:
|
||||
typeclass = back_exit["option"]
|
||||
if not typeclass:
|
||||
|
|
@ -1088,9 +1051,8 @@ class CmdTunnel(COMMAND_DEFAULT_CLASS):
|
|||
exitshort = self.lhs.split(":")[0]
|
||||
|
||||
if exitshort not in self.directions:
|
||||
string = (
|
||||
"tunnel can only understand the following directions: %s."
|
||||
% ",".join(sorted(self.directions.keys()))
|
||||
string = "tunnel can only understand the following directions: %s." % ",".join(
|
||||
sorted(self.directions.keys())
|
||||
)
|
||||
string += "\n(use dig for more freedom)"
|
||||
self.caller.msg(string)
|
||||
|
|
@ -1121,13 +1083,7 @@ class CmdTunnel(COMMAND_DEFAULT_CLASS):
|
|||
backstring = ", %s;%s" % (backname, backshort)
|
||||
|
||||
# build the string we will use to call dig
|
||||
digstring = "dig%s %s = %s;%s%s" % (
|
||||
telswitch,
|
||||
roomname,
|
||||
exitname,
|
||||
exitshort,
|
||||
backstring,
|
||||
)
|
||||
digstring = "dig%s %s = %s;%s%s" % (telswitch, roomname, exitname, exitshort, backstring)
|
||||
self.execute_cmd(digstring)
|
||||
|
||||
|
||||
|
|
@ -1168,12 +1124,8 @@ class CmdLink(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
# try to search locally first
|
||||
results = caller.search(object_name, quiet=True)
|
||||
if (
|
||||
len(results) > 1
|
||||
): # local results was a multimatch. Inform them to be more specific
|
||||
_AT_SEARCH_RESULT = variable_from_module(
|
||||
*settings.SEARCH_AT_RESULT.rsplit(".", 1)
|
||||
)
|
||||
if len(results) > 1: # local results was a multimatch. Inform them to be more specific
|
||||
_AT_SEARCH_RESULT = variable_from_module(*settings.SEARCH_AT_RESULT.rsplit(".", 1))
|
||||
return _AT_SEARCH_RESULT(results, caller, query=object_name)
|
||||
elif len(results) == 1: # A unique local match
|
||||
obj = results[0]
|
||||
|
|
@ -1198,9 +1150,9 @@ class CmdLink(COMMAND_DEFAULT_CLASS):
|
|||
string = note % (obj.name, obj.dbref)
|
||||
if "twoway" in self.switches:
|
||||
if not (target.location and obj.location):
|
||||
string = (
|
||||
"To create a two-way link, %s and %s must both have a location"
|
||||
% (obj, target)
|
||||
string = "To create a two-way link, %s and %s must both have a location" % (
|
||||
obj,
|
||||
target,
|
||||
)
|
||||
string += " (i.e. they cannot be rooms, but should be exits)."
|
||||
self.caller.msg(string)
|
||||
|
|
@ -1227,10 +1179,7 @@ class CmdLink(COMMAND_DEFAULT_CLASS):
|
|||
if dest:
|
||||
string = "%s is an exit to %s." % (obj.name, dest.name)
|
||||
else:
|
||||
string = "%s is not an exit. Its home location is %s." % (
|
||||
obj.name,
|
||||
obj.home,
|
||||
)
|
||||
string = "%s is not an exit. Its home location is %s." % (obj.name, obj.home)
|
||||
|
||||
else:
|
||||
# We gave the command link 'obj = ' which means we want to
|
||||
|
|
@ -1333,11 +1282,7 @@ class CmdSetHome(CmdLink):
|
|||
new_home.dbref,
|
||||
)
|
||||
else:
|
||||
string = "Home location of %s was set to %s(%s)." % (
|
||||
obj,
|
||||
new_home,
|
||||
new_home.dbref,
|
||||
)
|
||||
string = "Home location of %s was set to %s(%s)." % (obj, new_home, new_home.dbref)
|
||||
self.caller.msg(string)
|
||||
|
||||
|
||||
|
|
@ -1410,12 +1355,8 @@ class CmdName(ObjManipCommand):
|
|||
if not newname:
|
||||
caller.msg("No name defined!")
|
||||
return
|
||||
if not (
|
||||
obj.access(caller, "control") or obj.access(caller, "edit")
|
||||
):
|
||||
caller.msg(
|
||||
"You don't have right to edit this account %s." % obj
|
||||
)
|
||||
if not (obj.access(caller, "control") or obj.access(caller, "edit")):
|
||||
caller.msg("You don't have right to edit this account %s." % obj)
|
||||
return
|
||||
obj.username = newname
|
||||
obj.save()
|
||||
|
|
@ -1470,9 +1411,7 @@ class CmdOpen(ObjManipCommand):
|
|||
help_category = "Building"
|
||||
|
||||
# a custom member method to chug out exits and do checks
|
||||
def create_exit(
|
||||
self, exit_name, location, destination, exit_aliases=None, typeclass=None
|
||||
):
|
||||
def create_exit(self, exit_name, location, destination, exit_aliases=None, typeclass=None):
|
||||
"""
|
||||
Helper function to avoid code duplication.
|
||||
At this point we know destination is a valid location
|
||||
|
|
@ -1493,7 +1432,9 @@ class CmdOpen(ObjManipCommand):
|
|||
if not exit_obj.destination:
|
||||
# we are trying to link a non-exit
|
||||
string = "'%s' already exists and is not an exit!\nIf you want to convert it "
|
||||
string += "to an exit, you must assign an object to the 'destination' property first."
|
||||
string += (
|
||||
"to an exit, you must assign an object to the 'destination' property first."
|
||||
)
|
||||
caller.msg(string % exit_name)
|
||||
return None
|
||||
# we are re-linking an old exit.
|
||||
|
|
@ -1505,9 +1446,9 @@ class CmdOpen(ObjManipCommand):
|
|||
exit_obj.destination = destination
|
||||
if exit_aliases:
|
||||
[exit_obj.aliases.add(alias) for alias in exit_aliases]
|
||||
string += (
|
||||
" Rerouted its old destination '%s' to '%s' and changed aliases."
|
||||
% (old_destination.name, destination.name)
|
||||
string += " Rerouted its old destination '%s' to '%s' and changed aliases." % (
|
||||
old_destination.name,
|
||||
destination.name,
|
||||
)
|
||||
else:
|
||||
string += " It already points to the correct place."
|
||||
|
|
@ -1517,11 +1458,7 @@ class CmdOpen(ObjManipCommand):
|
|||
if not typeclass:
|
||||
typeclass = settings.BASE_EXIT_TYPECLASS
|
||||
exit_obj = create.create_object(
|
||||
typeclass,
|
||||
key=exit_name,
|
||||
location=location,
|
||||
aliases=exit_aliases,
|
||||
report_to=caller,
|
||||
typeclass, key=exit_name, location=location, aliases=exit_aliases, report_to=caller
|
||||
)
|
||||
if exit_obj:
|
||||
# storing a destination is what makes it an exit!
|
||||
|
|
@ -1576,9 +1513,7 @@ class CmdOpen(ObjManipCommand):
|
|||
return
|
||||
|
||||
# Create exit
|
||||
ok = self.create_exit(
|
||||
exit_name, location, destination, exit_aliases, exit_typeclass
|
||||
)
|
||||
ok = self.create_exit(exit_name, location, destination, exit_aliases, exit_typeclass)
|
||||
if not ok:
|
||||
# an error; the exit was not created, so we quit.
|
||||
return
|
||||
|
|
@ -1588,11 +1523,7 @@ class CmdOpen(ObjManipCommand):
|
|||
back_exit_aliases = self.lhs_objs[1]["aliases"]
|
||||
back_exit_typeclass = self.lhs_objs[1]["option"]
|
||||
self.create_exit(
|
||||
back_exit_name,
|
||||
destination,
|
||||
location,
|
||||
back_exit_aliases,
|
||||
back_exit_typeclass,
|
||||
back_exit_name, destination, location, back_exit_aliases, back_exit_typeclass
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -1787,18 +1718,11 @@ class CmdSetAttribute(ObjManipCommand):
|
|||
del deep[del_key]
|
||||
except (IndexError, KeyError, TypeError):
|
||||
continue
|
||||
return "\nDeleted attribute '%s' (= nested) from %s." % (
|
||||
attr,
|
||||
obj.name,
|
||||
)
|
||||
return "\nDeleted attribute '%s' (= nested) from %s." % (attr, obj.name)
|
||||
else:
|
||||
exists = obj.attributes.has(key)
|
||||
obj.attributes.remove(attr)
|
||||
return "\nDeleted attribute '%s' (= %s) from %s." % (
|
||||
attr,
|
||||
exists,
|
||||
obj.name,
|
||||
)
|
||||
return "\nDeleted attribute '%s' (= %s) from %s." % (attr, exists, obj.name)
|
||||
error = "\n%s has no attribute '%s'." % (obj.name, attr)
|
||||
if nested:
|
||||
error += " (Nested lookups attempted)"
|
||||
|
|
@ -1892,9 +1816,7 @@ class CmdSetAttribute(ObjManipCommand):
|
|||
"""
|
||||
from evennia.utils.utils import variable_from_module
|
||||
|
||||
_AT_SEARCH_RESULT = variable_from_module(
|
||||
*settings.SEARCH_AT_RESULT.rsplit(".", 1)
|
||||
)
|
||||
_AT_SEARCH_RESULT = variable_from_module(*settings.SEARCH_AT_RESULT.rsplit(".", 1))
|
||||
caller = self.caller
|
||||
if objname.startswith("*") or "account" in self.switches:
|
||||
found_obj = caller.search_account(objname.lstrip("*"))
|
||||
|
|
@ -1913,9 +1835,7 @@ class CmdSetAttribute(ObjManipCommand):
|
|||
else:
|
||||
global_search = False
|
||||
typeclass = None
|
||||
found_obj = caller.search(
|
||||
objname, global_search=global_search, typeclass=typeclass
|
||||
)
|
||||
found_obj = caller.search(objname, global_search=global_search, typeclass=typeclass)
|
||||
return found_obj
|
||||
|
||||
def func(self):
|
||||
|
|
@ -1941,16 +1861,12 @@ class CmdSetAttribute(ObjManipCommand):
|
|||
result = []
|
||||
if "edit" in self.switches:
|
||||
# edit in the line editor
|
||||
if not (
|
||||
obj.access(self.caller, "control") or obj.access(self.caller, "edit")
|
||||
):
|
||||
if not (obj.access(self.caller, "control") or obj.access(self.caller, "edit")):
|
||||
caller.msg("You don't have permission to edit %s." % obj.key)
|
||||
return
|
||||
|
||||
if len(attrs) > 1:
|
||||
caller.msg(
|
||||
"The Line editor can only be applied " "to one attribute at a time."
|
||||
)
|
||||
caller.msg("The Line editor can only be applied " "to one attribute at a time.")
|
||||
return
|
||||
self.edit_handler(obj, attrs[0])
|
||||
return
|
||||
|
|
@ -1968,10 +1884,7 @@ class CmdSetAttribute(ObjManipCommand):
|
|||
return
|
||||
else:
|
||||
# deleting the attribute(s)
|
||||
if not (
|
||||
obj.access(self.caller, "control")
|
||||
or obj.access(self.caller, "edit")
|
||||
):
|
||||
if not (obj.access(self.caller, "control") or obj.access(self.caller, "edit")):
|
||||
caller.msg("You don't have permission to edit %s." % obj.key)
|
||||
return
|
||||
for attr in attrs:
|
||||
|
|
@ -1980,9 +1893,7 @@ class CmdSetAttribute(ObjManipCommand):
|
|||
result.append(self.rm_attr(obj, attr))
|
||||
else:
|
||||
# setting attribute(s). Make sure to convert to real Python type before saving.
|
||||
if not (
|
||||
obj.access(self.caller, "control") or obj.access(self.caller, "edit")
|
||||
):
|
||||
if not (obj.access(self.caller, "control") or obj.access(self.caller, "edit")):
|
||||
caller.msg("You don't have permission to edit %s." % obj.key)
|
||||
return
|
||||
for attr in attrs:
|
||||
|
|
@ -2053,17 +1964,15 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
if "list" in self.switches:
|
||||
tclasses = get_all_typeclasses()
|
||||
contribs = [
|
||||
key for key in sorted(tclasses) if key.startswith("evennia.contrib")
|
||||
] or ["<None loaded>"]
|
||||
contribs = [key for key in sorted(tclasses) if key.startswith("evennia.contrib")] or [
|
||||
"<None loaded>"
|
||||
]
|
||||
core = [
|
||||
key
|
||||
for key in sorted(tclasses)
|
||||
if key.startswith("evennia") and key not in contribs
|
||||
] or ["<None loaded>"]
|
||||
game = [
|
||||
key for key in sorted(tclasses) if not key.startswith("evennia")
|
||||
key for key in sorted(tclasses) if key.startswith("evennia") and key not in contribs
|
||||
] or ["<None loaded>"]
|
||||
game = [key for key in sorted(tclasses) if not key.startswith("evennia")] or [
|
||||
"<None loaded>"
|
||||
]
|
||||
string = (
|
||||
"|wCore typeclasses|n\n"
|
||||
" {core}\n"
|
||||
|
|
@ -2072,9 +1981,7 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
|
|||
"|wGame-dir typeclasses|n\n"
|
||||
" {game}"
|
||||
).format(
|
||||
core="\n ".join(core),
|
||||
contrib="\n ".join(contribs),
|
||||
game="\n ".join(game),
|
||||
core="\n ".join(core), contrib="\n ".join(contribs), game="\n ".join(game)
|
||||
)
|
||||
EvMore(caller, string, exit_on_lastpage=True)
|
||||
return
|
||||
|
|
@ -2090,9 +1997,7 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
|
|||
# no object found to examine, see if it's a typeclass-path instead
|
||||
tclasses = get_all_typeclasses()
|
||||
matches = [
|
||||
(key, tclass)
|
||||
for key, tclass in tclasses.items()
|
||||
if key.endswith(oquery)
|
||||
(key, tclass) for key, tclass in tclasses.items() if key.endswith(oquery)
|
||||
]
|
||||
nmatches = len(matches)
|
||||
if nmatches > 1:
|
||||
|
|
@ -2102,15 +2007,11 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
|
|||
)
|
||||
)
|
||||
elif not matches:
|
||||
caller.msg(
|
||||
"No object or typeclass path found to match '{}'".format(oquery)
|
||||
)
|
||||
caller.msg("No object or typeclass path found to match '{}'".format(oquery))
|
||||
else:
|
||||
# one match found
|
||||
caller.msg(
|
||||
"Docstring for typeclass '{}':\n{}".format(
|
||||
oquery, matches[0][1].__doc__
|
||||
)
|
||||
"Docstring for typeclass '{}':\n{}".format(oquery, matches[0][1].__doc__)
|
||||
)
|
||||
else:
|
||||
# do the search again to get the error handling in case of multi-match
|
||||
|
|
@ -2170,17 +2071,11 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
# we let this raise exception if needed
|
||||
obj.swap_typeclass(
|
||||
new_typeclass,
|
||||
clean_attributes=reset,
|
||||
clean_cmdsets=reset,
|
||||
run_start_hooks=hooks,
|
||||
new_typeclass, clean_attributes=reset, clean_cmdsets=reset, run_start_hooks=hooks
|
||||
)
|
||||
|
||||
if is_same:
|
||||
string = "%s updated its existing typeclass (%s).\n" % (
|
||||
obj.name,
|
||||
obj.path,
|
||||
)
|
||||
string = "%s updated its existing typeclass (%s).\n" % (obj.name, obj.path)
|
||||
else:
|
||||
string = "%s changed typeclass from %s to %s.\n" % (
|
||||
obj.name,
|
||||
|
|
@ -2294,8 +2189,7 @@ class CmdLock(ObjManipCommand):
|
|||
caller = self.caller
|
||||
if not self.args:
|
||||
string = (
|
||||
"Usage: lock <object>[ = <lockstring>] or lock[/switch] "
|
||||
"<object>/<access_type>"
|
||||
"Usage: lock <object>[ = <lockstring>] or lock[/switch] " "<object>/<access_type>"
|
||||
)
|
||||
caller.msg(string)
|
||||
return
|
||||
|
|
@ -2441,10 +2335,7 @@ class CmdExamine(ObjManipCommand):
|
|||
except Exception:
|
||||
ndb_attr = None
|
||||
else:
|
||||
db_attr = [
|
||||
(attr.key, attr.value, attr.category)
|
||||
for attr in obj.db_attributes.all()
|
||||
]
|
||||
db_attr = [(attr.key, attr.value, attr.category) for attr in obj.db_attributes.all()]
|
||||
try:
|
||||
ndb_attr = obj.nattributes.all(return_tuples=True)
|
||||
except Exception:
|
||||
|
|
@ -2468,9 +2359,7 @@ class CmdExamine(ObjManipCommand):
|
|||
"""
|
||||
string = "\n|wName/key|n: |c%s|n (%s)" % (obj.name, obj.dbref)
|
||||
if hasattr(obj, "aliases") and obj.aliases.all():
|
||||
string += "\n|wAliases|n: %s" % (
|
||||
", ".join(utils.make_iter(str(obj.aliases)))
|
||||
)
|
||||
string += "\n|wAliases|n: %s" % (", ".join(utils.make_iter(str(obj.aliases))))
|
||||
if hasattr(obj, "sessions") and obj.sessions.all():
|
||||
string += "\n|wSession id(s)|n: %s" % (
|
||||
", ".join("#%i" % sess.sessid for sess in obj.sessions.all())
|
||||
|
|
@ -2512,20 +2401,14 @@ class CmdExamine(ObjManipCommand):
|
|||
|
||||
locks = str(obj.locks)
|
||||
if locks:
|
||||
locks_string = utils.fill(
|
||||
"; ".join([lock for lock in locks.split(";")]), indent=6
|
||||
)
|
||||
locks_string = utils.fill("; ".join([lock for lock in locks.split(";")]), indent=6)
|
||||
else:
|
||||
locks_string = " Default"
|
||||
string += "\n|wLocks|n:%s" % locks_string
|
||||
|
||||
if not (
|
||||
len(obj.cmdset.all()) == 1 and obj.cmdset.current.key == "_EMPTY_CMDSET"
|
||||
):
|
||||
if not (len(obj.cmdset.all()) == 1 and obj.cmdset.current.key == "_EMPTY_CMDSET"):
|
||||
# all() returns a 'stack', so make a copy to sort.
|
||||
stored_cmdsets = sorted(
|
||||
obj.cmdset.all(), key=lambda x: x.priority, reverse=True
|
||||
)
|
||||
stored_cmdsets = sorted(obj.cmdset.all(), key=lambda x: x.priority, reverse=True)
|
||||
string += "\n|wStored Cmdset(s)|n:\n %s" % (
|
||||
"\n ".join(
|
||||
"%s [%s] (%s, prio %s)"
|
||||
|
|
@ -2540,9 +2423,7 @@ class CmdExamine(ObjManipCommand):
|
|||
# we always at least try to add account- and session sets since these are ignored
|
||||
# if we merge on the object level.
|
||||
if hasattr(obj, "account") and obj.account:
|
||||
all_cmdsets.extend(
|
||||
[(cmdset.key, cmdset) for cmdset in obj.account.cmdset.all()]
|
||||
)
|
||||
all_cmdsets.extend([(cmdset.key, cmdset) for cmdset in obj.account.cmdset.all()])
|
||||
if obj.sessions.count():
|
||||
# if there are more sessions than one on objects it's because of multisession mode 3.
|
||||
# we only show the first session's cmdset here (it is -in principle- possible that
|
||||
|
|
@ -2560,9 +2441,7 @@ class CmdExamine(ObjManipCommand):
|
|||
all_cmdsets.extend(
|
||||
[
|
||||
(cmdset.key, cmdset)
|
||||
for cmdset in obj.get_session(
|
||||
obj.sessions.get()
|
||||
).cmdset.all()
|
||||
for cmdset in obj.get_session(obj.sessions.get()).cmdset.all()
|
||||
]
|
||||
)
|
||||
except (TypeError, AttributeError):
|
||||
|
|
@ -2579,21 +2458,15 @@ class CmdExamine(ObjManipCommand):
|
|||
)
|
||||
|
||||
# list the commands available to this object
|
||||
avail_cmdset = sorted(
|
||||
[cmd.key for cmd in avail_cmdset if cmd.access(obj, "cmd")]
|
||||
)
|
||||
avail_cmdset = sorted([cmd.key for cmd in avail_cmdset if cmd.access(obj, "cmd")])
|
||||
|
||||
cmdsetstr = utils.fill(", ".join(avail_cmdset), indent=2)
|
||||
string += (
|
||||
"\n|wCommands available to %s (result of Merged CmdSets)|n:\n %s"
|
||||
% (obj.key, cmdsetstr)
|
||||
string += "\n|wCommands available to %s (result of Merged CmdSets)|n:\n %s" % (
|
||||
obj.key,
|
||||
cmdsetstr,
|
||||
)
|
||||
|
||||
if (
|
||||
hasattr(obj, "scripts")
|
||||
and hasattr(obj.scripts, "all")
|
||||
and obj.scripts.all()
|
||||
):
|
||||
if hasattr(obj, "scripts") and hasattr(obj.scripts, "all") and obj.scripts.all():
|
||||
string += "\n|wScripts|n:\n %s" % obj.scripts
|
||||
# add the attributes
|
||||
string += self.format_attributes(obj)
|
||||
|
|
@ -2772,9 +2645,7 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
|||
caller.msg("Usage: find <string> [= low [-high]]")
|
||||
return
|
||||
|
||||
if (
|
||||
"locate" in self.cmdstring
|
||||
): # Use option /loc as a default for locate command alias
|
||||
if "locate" in self.cmdstring: # Use option /loc as a default for locate command alias
|
||||
switches.append("loc")
|
||||
|
||||
searchstring = self.lhs
|
||||
|
|
@ -2822,16 +2693,10 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
|||
if not result:
|
||||
string += "\n |RNo match found.|n"
|
||||
elif not low <= int(result[0].id) <= high:
|
||||
string += (
|
||||
"\n |RNo match found for '%s' in #dbref interval.|n"
|
||||
% searchstring
|
||||
)
|
||||
string += "\n |RNo match found for '%s' in #dbref interval.|n" % searchstring
|
||||
else:
|
||||
result = result[0]
|
||||
string += "\n|g %s - %s|n" % (
|
||||
result.get_display_name(caller),
|
||||
result.path,
|
||||
)
|
||||
string += "\n|g %s - %s|n" % (result.get_display_name(caller), result.path)
|
||||
if "loc" in self.switches and not is_account and result.location:
|
||||
string += " (|wlocation|n: |g{}|n)".format(
|
||||
result.location.get_display_name(caller)
|
||||
|
|
@ -2848,9 +2713,7 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
|||
id__lte=high,
|
||||
)
|
||||
elif "startswith" in switches:
|
||||
keyquery = Q(
|
||||
db_key__istartswith=searchstring, id__gte=low, id__lte=high
|
||||
)
|
||||
keyquery = Q(db_key__istartswith=searchstring, id__gte=low, id__lte=high)
|
||||
aliasquery = Q(
|
||||
db_tags__db_key__istartswith=searchstring,
|
||||
db_tags__db_tagtype__iexact="alias",
|
||||
|
|
@ -2873,33 +2736,19 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
|||
# convert result to typeclasses.
|
||||
results = [result for result in results]
|
||||
if "room" in switches:
|
||||
results = [
|
||||
obj for obj in results if inherits_from(obj, ROOM_TYPECLASS)
|
||||
]
|
||||
results = [obj for obj in results if inherits_from(obj, ROOM_TYPECLASS)]
|
||||
if "exit" in switches:
|
||||
results = [
|
||||
obj for obj in results if inherits_from(obj, EXIT_TYPECLASS)
|
||||
]
|
||||
results = [obj for obj in results if inherits_from(obj, EXIT_TYPECLASS)]
|
||||
if "char" in switches:
|
||||
results = [
|
||||
obj for obj in results if inherits_from(obj, CHAR_TYPECLASS)
|
||||
]
|
||||
results = [obj for obj in results if inherits_from(obj, CHAR_TYPECLASS)]
|
||||
nresults = len(results)
|
||||
|
||||
# still results after type filtering?
|
||||
if nresults:
|
||||
if nresults > 1:
|
||||
string = "|w%i Matches|n(#%i-#%i%s):" % (
|
||||
nresults,
|
||||
low,
|
||||
high,
|
||||
restrictions,
|
||||
)
|
||||
string = "|w%i Matches|n(#%i-#%i%s):" % (nresults, low, high, restrictions)
|
||||
for res in results:
|
||||
string += "\n |g%s - %s|n" % (
|
||||
res.get_display_name(caller),
|
||||
res.path,
|
||||
)
|
||||
string += "\n |g%s - %s|n" % (res.get_display_name(caller), res.path)
|
||||
else:
|
||||
string = "|wOne Match|n(#%i-#%i%s):" % (low, high, restrictions)
|
||||
string += "\n |g%s - %s|n" % (
|
||||
|
|
@ -2985,8 +2834,7 @@ class CmdTeleport(COMMAND_DEFAULT_CLASS):
|
|||
caller.msg("Teleported %s -> None-location." % obj_to_teleport)
|
||||
if obj_to_teleport.location and not tel_quietly:
|
||||
obj_to_teleport.location.msg_contents(
|
||||
"%s teleported %s into nothingness." % (caller, obj_to_teleport),
|
||||
exclude=caller,
|
||||
"%s teleported %s into nothingness." % (caller, obj_to_teleport), exclude=caller
|
||||
)
|
||||
obj_to_teleport.location = None
|
||||
return
|
||||
|
|
@ -3029,10 +2877,7 @@ class CmdTeleport(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
# try the teleport
|
||||
if obj_to_teleport.move_to(
|
||||
destination,
|
||||
quiet=tel_quietly,
|
||||
emit_to_obj=caller,
|
||||
use_destination=use_destination,
|
||||
destination, quiet=tel_quietly, emit_to_obj=caller, use_destination=use_destination
|
||||
):
|
||||
if obj_to_teleport == caller:
|
||||
caller.msg("Teleported to %s." % destination)
|
||||
|
|
@ -3077,9 +2922,7 @@ class CmdScript(COMMAND_DEFAULT_CLASS):
|
|||
return
|
||||
|
||||
if not self.lhs:
|
||||
caller.msg(
|
||||
"To create a global script you need |wscripts/add <typeclass>|n."
|
||||
)
|
||||
caller.msg("To create a global script you need |wscripts/add <typeclass>|n.")
|
||||
return
|
||||
|
||||
obj = caller.search(self.lhs)
|
||||
|
|
@ -3091,9 +2934,7 @@ class CmdScript(COMMAND_DEFAULT_CLASS):
|
|||
# no rhs means we want to operate on all scripts
|
||||
scripts = obj.scripts.all()
|
||||
if not scripts:
|
||||
result.append(
|
||||
"No scripts defined on %s." % obj.get_display_name(caller)
|
||||
)
|
||||
result.append("No scripts defined on %s." % obj.get_display_name(caller))
|
||||
elif not self.switches:
|
||||
# view all scripts
|
||||
from evennia.commands.default.system import format_script_list
|
||||
|
|
@ -3101,17 +2942,12 @@ class CmdScript(COMMAND_DEFAULT_CLASS):
|
|||
result.append(format_script_list(scripts))
|
||||
elif "start" in self.switches:
|
||||
num = sum([obj.scripts.start(script.key) for script in scripts])
|
||||
result.append(
|
||||
"%s scripts started on %s." % (num, obj.get_display_name(caller))
|
||||
)
|
||||
result.append("%s scripts started on %s." % (num, obj.get_display_name(caller)))
|
||||
elif "stop" in self.switches:
|
||||
for script in scripts:
|
||||
result.append(
|
||||
"Stopping script %s on %s."
|
||||
% (
|
||||
script.get_display_name(caller),
|
||||
obj.get_display_name(caller),
|
||||
)
|
||||
% (script.get_display_name(caller), obj.get_display_name(caller))
|
||||
)
|
||||
script.stop()
|
||||
obj.scripts.validate()
|
||||
|
|
@ -3139,10 +2975,7 @@ class CmdScript(COMMAND_DEFAULT_CLASS):
|
|||
for path in paths:
|
||||
ok = obj.scripts.stop(path)
|
||||
if not ok:
|
||||
result.append(
|
||||
"\nScript %s could not be stopped. Does it exist?"
|
||||
% path
|
||||
)
|
||||
result.append("\nScript %s could not be stopped. Does it exist?" % path)
|
||||
else:
|
||||
result = ["Script stopped and removed from object."]
|
||||
break
|
||||
|
|
@ -3151,13 +2984,12 @@ class CmdScript(COMMAND_DEFAULT_CLASS):
|
|||
for path in paths:
|
||||
ok = obj.scripts.start(path)
|
||||
if not ok:
|
||||
result.append(
|
||||
"\nScript %s could not be (re)started." % path
|
||||
)
|
||||
result.append("\nScript %s could not be (re)started." % path)
|
||||
else:
|
||||
result = ["Script started successfully."]
|
||||
break
|
||||
caller.msg("".join(result).strip())
|
||||
|
||||
EvMore(caller, "".join(result).strip())
|
||||
|
||||
|
||||
class CmdTag(COMMAND_DEFAULT_CLASS):
|
||||
|
|
@ -3257,10 +3089,7 @@ class CmdTag(COMMAND_DEFAULT_CLASS):
|
|||
]
|
||||
if old_tags:
|
||||
obj.tags.clear()
|
||||
string = "Cleared all tags from %s: %s" % (
|
||||
obj,
|
||||
", ".join(sorted(old_tags)),
|
||||
)
|
||||
string = "Cleared all tags from %s: %s" % (obj, ", ".join(sorted(old_tags)))
|
||||
else:
|
||||
string = "No Tags to clear on %s." % obj
|
||||
self.caller.msg(string)
|
||||
|
|
@ -3291,18 +3120,12 @@ class CmdTag(COMMAND_DEFAULT_CLASS):
|
|||
tagtuples = obj.tags.all(return_key_and_category=True)
|
||||
ntags = len(tagtuples)
|
||||
tags = [tup[0] for tup in tagtuples]
|
||||
categories = [
|
||||
" (category: %s)" % tup[1] if tup[1] else "" for tup in tagtuples
|
||||
]
|
||||
categories = [" (category: %s)" % tup[1] if tup[1] else "" for tup in tagtuples]
|
||||
if ntags:
|
||||
string = "Tag%s on %s: %s" % (
|
||||
"s" if ntags > 1 else "",
|
||||
obj,
|
||||
", ".join(
|
||||
sorted(
|
||||
"'%s'%s" % (tags[i], categories[i]) for i in range(ntags)
|
||||
)
|
||||
),
|
||||
", ".join(sorted("'%s'%s" % (tags[i], categories[i]) for i in range(ntags))),
|
||||
)
|
||||
else:
|
||||
string = "No tags attached to %s." % obj
|
||||
|
|
@ -3417,12 +3240,9 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
return None
|
||||
if expect == dict:
|
||||
# an actual prototype. We need to make sure it's safe. Don't allow exec
|
||||
if "exec" in prototype and not self.caller.check_permstring(
|
||||
"Developer"
|
||||
):
|
||||
if "exec" in prototype and not self.caller.check_permstring("Developer"):
|
||||
self.caller.msg(
|
||||
"Spawn aborted: You are not allowed to "
|
||||
"use the 'exec' prototype key."
|
||||
"Spawn aborted: You are not allowed to " "use the 'exec' prototype key."
|
||||
)
|
||||
return None
|
||||
try:
|
||||
|
|
@ -3458,10 +3278,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
if len(prototype) > 1:
|
||||
caller.msg(
|
||||
"More than one match for {}:\n{}".format(
|
||||
key,
|
||||
"\n".join(
|
||||
proto.get("prototype_key", "") for proto in prototype
|
||||
),
|
||||
key, "\n".join(proto.get("prototype_key", "") for proto in prototype)
|
||||
)
|
||||
)
|
||||
return
|
||||
|
|
@ -3482,9 +3299,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
else:
|
||||
key, tags = self.args.strip(), None
|
||||
if ";" in self.args:
|
||||
key, tags = (
|
||||
part.strip().lower() for part in self.args.split(";", 1)
|
||||
)
|
||||
key, tags = (part.strip().lower() for part in self.args.split(";", 1))
|
||||
tags = [tag.strip() for tag in tags.split(",")] if tags else None
|
||||
EvMore(
|
||||
caller,
|
||||
|
|
@ -3537,18 +3352,14 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
prototype_key = prototype.get("prototype_key")
|
||||
if not prototype_key:
|
||||
caller.msg(
|
||||
"\n|yTo save a prototype it must have the 'prototype_key' set."
|
||||
)
|
||||
caller.msg("\n|yTo save a prototype it must have the 'prototype_key' set.")
|
||||
return
|
||||
|
||||
# check for existing prototype,
|
||||
old_matchstring = _search_show_prototype(prototype_key)
|
||||
|
||||
if old_matchstring:
|
||||
string += "\n|yExisting saved prototype found:|n\n{}".format(
|
||||
old_matchstring
|
||||
)
|
||||
string += "\n|yExisting saved prototype found:|n\n{}".format(old_matchstring)
|
||||
question = "\n|yDo you want to replace the existing prototype?|n [Y]/N"
|
||||
|
||||
answer = yield (string + question)
|
||||
|
|
@ -3586,9 +3397,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
"Use spawn/update <key> to apply later as needed.|n"
|
||||
)
|
||||
return
|
||||
n_updated = spawner.batch_update_objects_with_prototype(
|
||||
existing_objects, key
|
||||
)
|
||||
n_updated = spawner.batch_update_objects_with_prototype(existing_objects, key)
|
||||
caller.msg("{} objects were updated.".format(n_updated))
|
||||
return
|
||||
|
||||
|
|
@ -3616,9 +3425,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
caller.msg("|rError deleting:|R {}|n".format(err))
|
||||
caller.msg(
|
||||
"Deletion {}.".format(
|
||||
"successful"
|
||||
if success
|
||||
else "failed (does the prototype exist?)"
|
||||
"successful" if success else "failed (does the prototype exist?)"
|
||||
)
|
||||
)
|
||||
return
|
||||
|
|
@ -3642,9 +3449,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
if answer.lower() in ["n", "no"]:
|
||||
caller.msg("|rUpdate cancelled.")
|
||||
return
|
||||
n_updated = spawner.batch_update_objects_with_prototype(
|
||||
existing_objects, key
|
||||
)
|
||||
n_updated = spawner.batch_update_objects_with_prototype(existing_objects, key)
|
||||
caller.msg("{} objects were updated.".format(n_updated))
|
||||
|
||||
# A direct creation of an object from a given prototype
|
||||
|
|
@ -3670,19 +3475,14 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS):
|
|||
"Found {} prototypes matching '{}':\n {}".format(
|
||||
nprots,
|
||||
prototype,
|
||||
", ".join(
|
||||
proto.get("prototype_key", "") for proto in prototypes
|
||||
),
|
||||
", ".join(proto.get("prototype_key", "") for proto in prototypes),
|
||||
)
|
||||
)
|
||||
return
|
||||
# we have a prototype, check access
|
||||
prototype = prototypes[0]
|
||||
if not caller.locks.check_lockstring(
|
||||
caller,
|
||||
prototype.get("prototype_locks", ""),
|
||||
access_type="spawn",
|
||||
default=True,
|
||||
caller, prototype.get("prototype_locks", ""), access_type="spawn", default=True
|
||||
):
|
||||
caller.msg("You don't have access to use this prototype.")
|
||||
return
|
||||
|
|
|
|||
|
|
@ -188,18 +188,14 @@ class CmdDelCom(COMMAND_DEFAULT_CLASS):
|
|||
if delnicks:
|
||||
for nick in [
|
||||
nick
|
||||
for nick in make_iter(
|
||||
caller.nicks.get(category="channel", return_obj=True)
|
||||
)
|
||||
for nick in make_iter(caller.nicks.get(category="channel", return_obj=True))
|
||||
if nick and nick.pk and nick.value[3].lower() == chkey
|
||||
]:
|
||||
nick.delete()
|
||||
disconnect = channel.disconnect(account)
|
||||
if disconnect:
|
||||
wipednicks = " Eventual aliases were removed." if delnicks else ""
|
||||
self.msg(
|
||||
"You stop listening to channel '%s'.%s" % (channel.key, wipednicks)
|
||||
)
|
||||
self.msg("You stop listening to channel '%s'.%s" % (channel.key, wipednicks))
|
||||
return
|
||||
else:
|
||||
# we are removing a channel nick
|
||||
|
|
@ -210,10 +206,7 @@ class CmdDelCom(COMMAND_DEFAULT_CLASS):
|
|||
else:
|
||||
if caller.nicks.get(ostring, category="channel"):
|
||||
caller.nicks.remove(ostring, category="channel")
|
||||
self.msg(
|
||||
"Your alias '%s' for channel %s was cleared."
|
||||
% (ostring, channel.key)
|
||||
)
|
||||
self.msg("Your alias '%s' for channel %s was cleared." % (ostring, channel.key))
|
||||
else:
|
||||
self.msg("You had no such alias defined for this channel.")
|
||||
|
||||
|
|
@ -347,9 +340,7 @@ class CmdChannels(COMMAND_DEFAULT_CLASS):
|
|||
"%s%s"
|
||||
% (
|
||||
chan.key,
|
||||
chan.aliases.all()
|
||||
and "(%s)" % ",".join(chan.aliases.all())
|
||||
or "",
|
||||
chan.aliases.all() and "(%s)" % ",".join(chan.aliases.all()) or "",
|
||||
),
|
||||
"%s"
|
||||
% ",".join(
|
||||
|
|
@ -390,9 +381,7 @@ class CmdChannels(COMMAND_DEFAULT_CLASS):
|
|||
"%s%s"
|
||||
% (
|
||||
chan.key,
|
||||
chan.aliases.all()
|
||||
and "(%s)" % ",".join(chan.aliases.all())
|
||||
or "",
|
||||
chan.aliases.all() and "(%s)" % ",".join(chan.aliases.all()) or "",
|
||||
),
|
||||
"%s"
|
||||
% ",".join(
|
||||
|
|
@ -444,9 +433,7 @@ class CmdCdestroy(COMMAND_DEFAULT_CLASS):
|
|||
self.msg("You are not allowed to do that.")
|
||||
return
|
||||
channel_key = channel.key
|
||||
message = (
|
||||
"%s is being destroyed. Make sure to change your aliases." % channel_key
|
||||
)
|
||||
message = "%s is being destroyed. Make sure to change your aliases." % channel_key
|
||||
msgobj = create.create_message(caller, message, channel)
|
||||
channel.msg(msgobj)
|
||||
channel.delete()
|
||||
|
|
@ -507,10 +494,7 @@ class CmdCBoot(COMMAND_DEFAULT_CLASS):
|
|||
self.msg(string)
|
||||
return
|
||||
if not channel.subscriptions.has(account):
|
||||
string = "Account %s is not connected to channel %s." % (
|
||||
account.key,
|
||||
channel.key,
|
||||
)
|
||||
string = "Account %s is not connected to channel %s." % (account.key, channel.key)
|
||||
self.msg(string)
|
||||
return
|
||||
if "quiet" not in self.switches:
|
||||
|
|
@ -661,9 +645,7 @@ class CmdChannelCreate(COMMAND_DEFAULT_CLASS):
|
|||
return
|
||||
# Create and set the channel up
|
||||
lockstring = "send:all();listen:all();control:id(%s)" % caller.id
|
||||
new_chan = create.create_channel(
|
||||
channame.strip(), aliases, description, locks=lockstring
|
||||
)
|
||||
new_chan = create.create_channel(channame.strip(), aliases, description, locks=lockstring)
|
||||
new_chan.connect(caller)
|
||||
CHANNELHANDLER.update()
|
||||
self.msg("Created channel %s and connected to it." % new_chan.key)
|
||||
|
|
@ -795,9 +777,7 @@ class CmdPage(COMMAND_DEFAULT_CLASS):
|
|||
caller = self.caller
|
||||
|
||||
# get the messages we've sent (not to channels)
|
||||
pages_we_sent = Msg.objects.get_messages_by_sender(
|
||||
caller, exclude_channel_messages=True
|
||||
)
|
||||
pages_we_sent = Msg.objects.get_messages_by_sender(caller, exclude_channel_messages=True)
|
||||
# get last messages we've got
|
||||
pages_we_got = Msg.objects.get_messages_by_receiver(caller)
|
||||
|
||||
|
|
@ -915,10 +895,7 @@ def _list_bots(cmd):
|
|||
|
||||
"""
|
||||
ircbots = [
|
||||
bot
|
||||
for bot in AccountDB.objects.filter(
|
||||
db_is_bot=True, username__startswith="ircbot-"
|
||||
)
|
||||
bot for bot in AccountDB.objects.filter(db_is_bot=True, username__startswith="ircbot-")
|
||||
]
|
||||
if ircbots:
|
||||
table = cmd.styled_table(
|
||||
|
|
@ -987,9 +964,7 @@ class CmdIRC2Chan(COMMAND_DEFAULT_CLASS):
|
|||
"""Setup the irc-channel mapping"""
|
||||
|
||||
if not settings.IRC_ENABLED:
|
||||
string = (
|
||||
"""IRC is not enabled. You need to activate it in game/settings.py."""
|
||||
)
|
||||
string = """IRC is not enabled. You need to activate it in game/settings.py."""
|
||||
self.msg(string)
|
||||
return
|
||||
|
||||
|
|
@ -998,11 +973,7 @@ class CmdIRC2Chan(COMMAND_DEFAULT_CLASS):
|
|||
self.msg(_list_bots(self))
|
||||
return
|
||||
|
||||
if (
|
||||
"disconnect" in self.switches
|
||||
or "remove" in self.switches
|
||||
or "delete" in self.switches
|
||||
):
|
||||
if "disconnect" in self.switches or "remove" in self.switches or "delete" in self.switches:
|
||||
botname = "ircbot-%s" % self.lhs
|
||||
matches = AccountDB.objects.filter(db_is_bot=True, username=botname)
|
||||
dbref = utils.dbref(self.lhs)
|
||||
|
|
@ -1132,9 +1103,7 @@ class CmdIRCStatus(COMMAND_DEFAULT_CLASS):
|
|||
elif option in ("users", "nicklist", "who"):
|
||||
# retrieve user list. The bot must handles the echo since it's
|
||||
# an asynchronous call.
|
||||
self.caller.msg(
|
||||
"Requesting nicklist from %s (%s:%s)." % (channel, network, port)
|
||||
)
|
||||
self.caller.msg("Requesting nicklist from %s (%s:%s)." % (channel, network, port))
|
||||
ircbot.get_nicklist(self.caller)
|
||||
elif self.caller.locks.check_lockstring(
|
||||
self.caller, "dummy:perm(ircstatus) or perm(Developer)"
|
||||
|
|
@ -1182,9 +1151,7 @@ class CmdRSS2Chan(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
# checking we have all we need
|
||||
if not settings.RSS_ENABLED:
|
||||
string = (
|
||||
"""RSS is not enabled. You need to activate it in game/settings.py."""
|
||||
)
|
||||
string = """RSS is not enabled. You need to activate it in game/settings.py."""
|
||||
self.msg(string)
|
||||
return
|
||||
try:
|
||||
|
|
@ -1203,9 +1170,7 @@ class CmdRSS2Chan(COMMAND_DEFAULT_CLASS):
|
|||
# show all connections
|
||||
rssbots = [
|
||||
bot
|
||||
for bot in AccountDB.objects.filter(
|
||||
db_is_bot=True, username__startswith="rssbot-"
|
||||
)
|
||||
for bot in AccountDB.objects.filter(db_is_bot=True, username__startswith="rssbot-")
|
||||
]
|
||||
if rssbots:
|
||||
table = self.styled_table(
|
||||
|
|
@ -1218,28 +1183,19 @@ class CmdRSS2Chan(COMMAND_DEFAULT_CLASS):
|
|||
)
|
||||
for rssbot in rssbots:
|
||||
table.add_row(
|
||||
rssbot.id,
|
||||
rssbot.db.rss_rate,
|
||||
rssbot.db.ev_channel,
|
||||
rssbot.db.rss_url,
|
||||
rssbot.id, rssbot.db.rss_rate, rssbot.db.ev_channel, rssbot.db.rss_url
|
||||
)
|
||||
self.msg(table)
|
||||
else:
|
||||
self.msg("No rss bots found.")
|
||||
return
|
||||
|
||||
if (
|
||||
"disconnect" in self.switches
|
||||
or "remove" in self.switches
|
||||
or "delete" in self.switches
|
||||
):
|
||||
if "disconnect" in self.switches or "remove" in self.switches or "delete" in self.switches:
|
||||
botname = "rssbot-%s" % self.lhs
|
||||
matches = AccountDB.objects.filter(db_is_bot=True, db_key=botname)
|
||||
if not matches:
|
||||
# try dbref match
|
||||
matches = AccountDB.objects.filter(
|
||||
db_is_bot=True, id=self.args.lstrip("#")
|
||||
)
|
||||
matches = AccountDB.objects.filter(db_is_bot=True, id=self.args.lstrip("#"))
|
||||
if matches:
|
||||
matches[0].delete()
|
||||
self.msg("RSS connection destroyed.")
|
||||
|
|
@ -1321,34 +1277,24 @@ class CmdGrapevine2Chan(COMMAND_DEFAULT_CLASS):
|
|||
maxwidth=_DEFAULT_WIDTH,
|
||||
)
|
||||
for gwbot in gwbots:
|
||||
table.add_row(
|
||||
gwbot.id, gwbot.db.ev_channel, gwbot.db.grapevine_channel
|
||||
)
|
||||
table.add_row(gwbot.id, gwbot.db.ev_channel, gwbot.db.grapevine_channel)
|
||||
self.msg(table)
|
||||
else:
|
||||
self.msg("No grapevine bots found.")
|
||||
return
|
||||
|
||||
if (
|
||||
"disconnect" in self.switches
|
||||
or "remove" in self.switches
|
||||
or "delete" in self.switches
|
||||
):
|
||||
if "disconnect" in self.switches or "remove" in self.switches or "delete" in self.switches:
|
||||
botname = "grapevinebot-%s" % self.lhs
|
||||
matches = AccountDB.objects.filter(db_is_bot=True, db_key=botname)
|
||||
|
||||
if not matches:
|
||||
# try dbref match
|
||||
matches = AccountDB.objects.filter(
|
||||
db_is_bot=True, id=self.args.lstrip("#")
|
||||
)
|
||||
matches = AccountDB.objects.filter(db_is_bot=True, id=self.args.lstrip("#"))
|
||||
if matches:
|
||||
matches[0].delete()
|
||||
self.msg("Grapevine connection destroyed.")
|
||||
else:
|
||||
self.msg(
|
||||
"Grapevine connection/bot could not be removed, does it exist?"
|
||||
)
|
||||
self.msg("Grapevine connection/bot could not be removed, does it exist?")
|
||||
return
|
||||
|
||||
if not self.args or not self.rhs:
|
||||
|
|
@ -1371,9 +1317,7 @@ class CmdGrapevine2Chan(COMMAND_DEFAULT_CLASS):
|
|||
self.msg("Reusing bot '%s' (%s)" % (botname, bot.dbref))
|
||||
else:
|
||||
# create a new bot
|
||||
bot = create.create_account(
|
||||
botname, None, None, typeclass=bots.GrapevineBot
|
||||
)
|
||||
bot = create.create_account(botname, None, None, typeclass=bots.GrapevineBot)
|
||||
|
||||
bot.start(ev_channel=channel, grapevine_channel=grapevine_channel)
|
||||
self.msg(f"Grapevine connection created {channel} <-> {grapevine_channel}.")
|
||||
|
|
|
|||
|
|
@ -157,24 +157,14 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
caller = self.caller
|
||||
switches = self.switches
|
||||
nicktypes = [
|
||||
switch
|
||||
for switch in switches
|
||||
if switch in ("object", "account", "inputline")
|
||||
]
|
||||
nicktypes = [switch for switch in switches if switch in ("object", "account", "inputline")]
|
||||
specified_nicktype = bool(nicktypes)
|
||||
nicktypes = nicktypes if specified_nicktype else ["inputline"]
|
||||
|
||||
nicklist = (
|
||||
utils.make_iter(
|
||||
caller.nicks.get(category="inputline", return_obj=True) or []
|
||||
)
|
||||
+ utils.make_iter(
|
||||
caller.nicks.get(category="object", return_obj=True) or []
|
||||
)
|
||||
+ utils.make_iter(
|
||||
caller.nicks.get(category="account", return_obj=True) or []
|
||||
)
|
||||
utils.make_iter(caller.nicks.get(category="inputline", return_obj=True) or [])
|
||||
+ utils.make_iter(caller.nicks.get(category="object", return_obj=True) or [])
|
||||
+ utils.make_iter(caller.nicks.get(category="account", return_obj=True) or [])
|
||||
)
|
||||
|
||||
if "list" in switches or self.cmdstring in ("nicks",):
|
||||
|
|
@ -186,10 +176,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
|||
for inum, nickobj in enumerate(nicklist):
|
||||
_, _, nickvalue, replacement = nickobj.value
|
||||
table.add_row(
|
||||
str(inum + 1),
|
||||
nickobj.db_category,
|
||||
_cy(nickvalue),
|
||||
_cy(replacement),
|
||||
str(inum + 1), nickobj.db_category, _cy(nickvalue), _cy(replacement)
|
||||
)
|
||||
string = "|wDefined Nicks:|n\n%s" % table
|
||||
caller.msg(string)
|
||||
|
|
@ -220,9 +207,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
|||
if not specified_nicktype:
|
||||
nicktypes = ("object", "account", "inputline")
|
||||
for nicktype in nicktypes:
|
||||
oldnicks.append(
|
||||
caller.nicks.get(arg, category=nicktype, return_obj=True)
|
||||
)
|
||||
oldnicks.append(caller.nicks.get(arg, category=nicktype, return_obj=True))
|
||||
|
||||
oldnicks = [oldnick for oldnick in oldnicks if oldnick]
|
||||
if oldnicks:
|
||||
|
|
@ -256,9 +241,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
|||
_, _, nick, repl = nick.value
|
||||
if nick.startswith(self.lhs):
|
||||
strings.append(
|
||||
"{}-nick: '{}' -> '{}'".format(
|
||||
nicktype.capitalize(), nick, repl
|
||||
)
|
||||
"{}-nick: '{}' -> '{}'".format(nicktype.capitalize(), nick, repl)
|
||||
)
|
||||
if strings:
|
||||
caller.msg("\n".join(strings))
|
||||
|
|
@ -276,16 +259,12 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
|||
obj = account
|
||||
else:
|
||||
obj = caller
|
||||
nicks = utils.make_iter(
|
||||
obj.nicks.get(category=nicktype, return_obj=True)
|
||||
)
|
||||
nicks = utils.make_iter(obj.nicks.get(category=nicktype, return_obj=True))
|
||||
for nick in nicks:
|
||||
_, _, nick, repl = nick.value
|
||||
if nick.startswith(self.lhs):
|
||||
strings.append(
|
||||
"{}-nick: '{}' -> '{}'".format(
|
||||
nicktype.capitalize(), nick, repl
|
||||
)
|
||||
"{}-nick: '{}' -> '{}'".format(nicktype.capitalize(), nick, repl)
|
||||
)
|
||||
if strings:
|
||||
caller.msg("\n".join(strings))
|
||||
|
|
@ -303,16 +282,12 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
|||
obj = account
|
||||
else:
|
||||
obj = caller
|
||||
nicks = utils.make_iter(
|
||||
obj.nicks.get(category=nicktype, return_obj=True)
|
||||
)
|
||||
nicks = utils.make_iter(obj.nicks.get(category=nicktype, return_obj=True))
|
||||
for nick in nicks:
|
||||
_, _, nick, repl = nick.value
|
||||
if nick.startswith(self.lhs):
|
||||
strings.append(
|
||||
"{}-nick: '{}' -> '{}'".format(
|
||||
nicktype.capitalize(), nick, repl
|
||||
)
|
||||
"{}-nick: '{}' -> '{}'".format(nicktype.capitalize(), nick, repl)
|
||||
)
|
||||
if strings:
|
||||
caller.msg("\n".join(strings))
|
||||
|
|
@ -341,9 +316,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
|||
old_nickstring = None
|
||||
old_replstring = None
|
||||
|
||||
oldnick = caller.nicks.get(
|
||||
key=nickstring, category=nicktype, return_obj=True
|
||||
)
|
||||
oldnick = caller.nicks.get(key=nickstring, category=nicktype, return_obj=True)
|
||||
if oldnick:
|
||||
_, _, old_nickstring, old_replstring = oldnick.value
|
||||
if replstring:
|
||||
|
|
@ -455,9 +428,7 @@ class CmdGet(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
obj.move_to(caller, quiet=True)
|
||||
caller.msg("You pick up %s." % obj.name)
|
||||
caller.location.msg_contents(
|
||||
"%s picks up %s." % (caller.name, obj.name), exclude=caller
|
||||
)
|
||||
caller.location.msg_contents("%s picks up %s." % (caller.name, obj.name), exclude=caller)
|
||||
# calling at_get hook method
|
||||
obj.at_get(caller)
|
||||
|
||||
|
|
@ -502,9 +473,7 @@ class CmdDrop(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
obj.move_to(caller.location, quiet=True)
|
||||
caller.msg("You drop %s." % (obj.name,))
|
||||
caller.location.msg_contents(
|
||||
"%s drops %s." % (caller.name, obj.name), exclude=caller
|
||||
)
|
||||
caller.location.msg_contents("%s drops %s." % (caller.name, obj.name), exclude=caller)
|
||||
# Call the object script's at_drop() method.
|
||||
obj.at_drop(caller)
|
||||
|
||||
|
|
@ -706,9 +675,7 @@ class CmdPose(COMMAND_DEFAULT_CLASS):
|
|||
self.caller.msg(msg)
|
||||
else:
|
||||
msg = "%s%s" % (self.caller.name, self.args)
|
||||
self.caller.location.msg_contents(
|
||||
text=(msg, {"type": "pose"}), from_obj=self.caller
|
||||
)
|
||||
self.caller.location.msg_contents(text=(msg, {"type": "pose"}), from_obj=self.caller)
|
||||
|
||||
|
||||
class CmdAccess(COMMAND_DEFAULT_CLASS):
|
||||
|
|
@ -732,9 +699,7 @@ class CmdAccess(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
caller = self.caller
|
||||
hierarchy_full = settings.PERMISSION_HIERARCHY
|
||||
string = "\n|wPermission Hierarchy|n (climbing):\n %s" % ", ".join(
|
||||
hierarchy_full
|
||||
)
|
||||
string = "\n|wPermission Hierarchy|n (climbing):\n %s" % ", ".join(hierarchy_full)
|
||||
|
||||
if self.caller.account.is_superuser:
|
||||
cperms = "<Superuser>"
|
||||
|
|
|
|||
|
|
@ -67,10 +67,7 @@ class CmdHelp(Command):
|
|||
if type(self).help_more:
|
||||
usemore = True
|
||||
|
||||
if self.session and self.session.protocol_key in (
|
||||
"websocket",
|
||||
"ajax/comet",
|
||||
):
|
||||
if self.session and self.session.protocol_key in ("websocket", "ajax/comet"):
|
||||
try:
|
||||
options = self.account.db._saved_webclient_options
|
||||
if options and options["helppopup"]:
|
||||
|
|
@ -104,9 +101,7 @@ class CmdHelp(Command):
|
|||
if title:
|
||||
string += "|CHelp for |w%s|n" % title
|
||||
if aliases:
|
||||
string += " |C(aliases: %s|C)|n" % (
|
||||
"|C,|n ".join("|w%s|n" % ali for ali in aliases)
|
||||
)
|
||||
string += " |C(aliases: %s|C)|n" % ("|C,|n ".join("|w%s|n" % ali for ali in aliases))
|
||||
if help_text:
|
||||
string += "\n%s" % dedent(help_text.rstrip())
|
||||
if suggested:
|
||||
|
|
@ -129,18 +124,14 @@ class CmdHelp(Command):
|
|||
string += "\n" + _SEP + "\n |CCommand help entries|n\n" + _SEP
|
||||
for category in sorted(hdict_cmds.keys()):
|
||||
string += "\n |w%s|n:\n" % (str(category).title())
|
||||
string += (
|
||||
"|G" + fill("|C, |G".join(sorted(hdict_cmds[category]))) + "|n"
|
||||
)
|
||||
string += "|G" + fill("|C, |G".join(sorted(hdict_cmds[category]))) + "|n"
|
||||
if hdict_db and any(hdict_db.values()):
|
||||
string += "\n\n" + _SEP + "\n\r |COther help entries|n\n" + _SEP
|
||||
for category in sorted(hdict_db.keys()):
|
||||
string += "\n\r |w%s|n:\n" % (str(category).title())
|
||||
string += (
|
||||
"|G"
|
||||
+ fill(
|
||||
", ".join(sorted([str(topic) for topic in hdict_db[category]]))
|
||||
)
|
||||
+ fill(", ".join(sorted([str(topic) for topic in hdict_db[category]])))
|
||||
+ "|n"
|
||||
)
|
||||
return string
|
||||
|
|
@ -213,9 +204,7 @@ class CmdHelp(Command):
|
|||
# retrieve all available commands and database topics
|
||||
all_cmds = [cmd for cmd in cmdset if self.check_show_help(cmd, caller)]
|
||||
all_topics = [
|
||||
topic
|
||||
for topic in HelpEntry.objects.all()
|
||||
if topic.access(caller, "view", default=True)
|
||||
topic for topic in HelpEntry.objects.all() if topic.access(caller, "view", default=True)
|
||||
]
|
||||
all_categories = list(
|
||||
set(
|
||||
|
|
@ -253,18 +242,13 @@ class CmdHelp(Command):
|
|||
suggestions = [
|
||||
sugg
|
||||
for sugg in string_suggestions(
|
||||
query,
|
||||
set(vocabulary),
|
||||
cutoff=suggestion_cutoff,
|
||||
maxnum=suggestion_maxnum,
|
||||
query, set(vocabulary), cutoff=suggestion_cutoff, maxnum=suggestion_maxnum
|
||||
)
|
||||
if sugg != query
|
||||
]
|
||||
if not suggestions:
|
||||
suggestions = [
|
||||
sugg
|
||||
for sugg in vocabulary
|
||||
if sugg != query and sugg.startswith(query)
|
||||
sugg for sugg in vocabulary if sugg != query and sugg.startswith(query)
|
||||
]
|
||||
|
||||
# try an exact command auto-help match
|
||||
|
|
@ -307,18 +291,8 @@ class CmdHelp(Command):
|
|||
if query in all_categories:
|
||||
self.msg_help(
|
||||
self.format_help_list(
|
||||
{
|
||||
query: [
|
||||
cmd.key for cmd in all_cmds if cmd.help_category == query
|
||||
]
|
||||
},
|
||||
{
|
||||
query: [
|
||||
topic.key
|
||||
for topic in all_topics
|
||||
if topic.help_category == query
|
||||
]
|
||||
},
|
||||
{query: [cmd.key for cmd in all_cmds if cmd.help_category == query]},
|
||||
{query: [topic.key for topic in all_topics if topic.help_category == query]},
|
||||
)
|
||||
)
|
||||
return
|
||||
|
|
@ -402,19 +376,14 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
|||
self.msg("You have to define a topic!")
|
||||
return
|
||||
topicstrlist = topicstr.split(";")
|
||||
topicstr, aliases = (
|
||||
topicstrlist[0],
|
||||
topicstrlist[1:] if len(topicstr) > 1 else [],
|
||||
)
|
||||
topicstr, aliases = (topicstrlist[0], topicstrlist[1:] if len(topicstr) > 1 else [])
|
||||
aliastxt = ("(aliases: %s)" % ", ".join(aliases)) if aliases else ""
|
||||
old_entry = None
|
||||
|
||||
# check if we have an old entry with the same name
|
||||
try:
|
||||
for querystr in topicstrlist:
|
||||
old_entry = HelpEntry.objects.find_topicmatch(
|
||||
querystr
|
||||
) # also search by alias
|
||||
old_entry = HelpEntry.objects.find_topicmatch(querystr) # also search by alias
|
||||
if old_entry:
|
||||
old_entry = list(old_entry)[0]
|
||||
break
|
||||
|
|
@ -436,11 +405,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
|||
helpentry = old_entry
|
||||
else:
|
||||
helpentry = create.create_help_entry(
|
||||
topicstr,
|
||||
self.rhs,
|
||||
category=category,
|
||||
locks=lockstring,
|
||||
aliases=aliases,
|
||||
topicstr, self.rhs, category=category, locks=lockstring, aliases=aliases
|
||||
)
|
||||
self.caller.db._editing_help = helpentry
|
||||
|
||||
|
|
@ -457,9 +422,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
|||
if "append" in switches or "merge" in switches or "extend" in switches:
|
||||
# merge/append operations
|
||||
if not old_entry:
|
||||
self.msg(
|
||||
"Could not find topic '%s'. You must give an exact name." % topicstr
|
||||
)
|
||||
self.msg("Could not find topic '%s'. You must give an exact name." % topicstr)
|
||||
return
|
||||
if not self.rhs:
|
||||
self.msg("You must supply text to append/merge.")
|
||||
|
|
@ -506,9 +469,7 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
|||
topicstr, self.rhs, category=category, locks=lockstring, aliases=aliases
|
||||
)
|
||||
if new_entry:
|
||||
self.msg(
|
||||
"Topic '%s'%s was successfully created." % (topicstr, aliastxt)
|
||||
)
|
||||
self.msg("Topic '%s'%s was successfully created." % (topicstr, aliastxt))
|
||||
if "edit" in switches:
|
||||
# open the line editor to edit the helptext
|
||||
self.caller.db._editing_help = new_entry
|
||||
|
|
@ -523,6 +484,5 @@ class CmdSetHelp(COMMAND_DEFAULT_CLASS):
|
|||
return
|
||||
else:
|
||||
self.msg(
|
||||
"Error when creating topic '%s'%s! Contact an admin."
|
||||
% (topicstr, aliastxt)
|
||||
"Error when creating topic '%s'%s! Contact an admin." % (topicstr, aliastxt)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -129,14 +129,10 @@ class MuxCommand(Command):
|
|||
if switches and self.switch_options:
|
||||
valid_switches, unused_switches, extra_switches = [], [], []
|
||||
for element in switches:
|
||||
option_check = [
|
||||
opt for opt in self.switch_options if opt == element
|
||||
]
|
||||
option_check = [opt for opt in self.switch_options if opt == element]
|
||||
if not option_check:
|
||||
option_check = [
|
||||
opt
|
||||
for opt in self.switch_options
|
||||
if opt.startswith(element)
|
||||
opt for opt in self.switch_options if opt.startswith(element)
|
||||
]
|
||||
match_count = len(option_check)
|
||||
if match_count > 1:
|
||||
|
|
@ -144,13 +140,9 @@ class MuxCommand(Command):
|
|||
option_check
|
||||
) # Either the option provided is ambiguous,
|
||||
elif match_count == 1:
|
||||
valid_switches.extend(
|
||||
option_check
|
||||
) # or it is a valid option abbreviation,
|
||||
valid_switches.extend(option_check) # or it is a valid option abbreviation,
|
||||
elif match_count == 0:
|
||||
unused_switches.append(
|
||||
element
|
||||
) # or an extraneous option to be ignored.
|
||||
unused_switches.append(element) # or an extraneous option to be ignored.
|
||||
if extra_switches: # User provided switches
|
||||
self.msg(
|
||||
"|g%s|n: |wAmbiguous switch supplied: Did you mean /|C%s|w?"
|
||||
|
|
@ -162,17 +154,13 @@ class MuxCommand(Command):
|
|||
'|g%s|n: |wExtra switch%s "/|C%s|w" ignored.'
|
||||
% (self.cmdstring, plural, "|n, /|C".join(unused_switches))
|
||||
)
|
||||
switches = (
|
||||
valid_switches
|
||||
) # Only include valid_switches in command function call
|
||||
switches = valid_switches # Only include valid_switches in command function call
|
||||
arglist = [arg.strip() for arg in args.split()]
|
||||
|
||||
# check for arg1, arg2, ... = argA, argB, ... constructs
|
||||
lhs, rhs = args.strip(), None
|
||||
if lhs:
|
||||
if delimiters and hasattr(
|
||||
delimiters, "__iter__"
|
||||
): # If delimiter is iterable,
|
||||
if delimiters and hasattr(delimiters, "__iter__"): # If delimiter is iterable,
|
||||
best_split = delimiters[0] # (default to first delimiter)
|
||||
for this_split in delimiters: # try each delimiter
|
||||
if this_split in lhs: # to find first successful split
|
||||
|
|
@ -204,15 +192,11 @@ class MuxCommand(Command):
|
|||
# a special property "character" for the puppeted object, if any. This
|
||||
# is convenient for commands defined on the Account only.
|
||||
if self.account_caller:
|
||||
if utils.inherits_from(
|
||||
self.caller, "evennia.objects.objects.DefaultObject"
|
||||
):
|
||||
if utils.inherits_from(self.caller, "evennia.objects.objects.DefaultObject"):
|
||||
# caller is an Object/Character
|
||||
self.character = self.caller
|
||||
self.caller = self.caller.account
|
||||
elif utils.inherits_from(
|
||||
self.caller, "evennia.accounts.accounts.DefaultAccount"
|
||||
):
|
||||
elif utils.inherits_from(self.caller, "evennia.accounts.accounts.DefaultAccount"):
|
||||
# caller was already an Account
|
||||
self.character = self.caller.get_puppet(self.session)
|
||||
else:
|
||||
|
|
@ -225,8 +209,7 @@ class MuxCommand(Command):
|
|||
to all the variables defined therein.
|
||||
"""
|
||||
variables = "\n".join(
|
||||
" |w{}|n ({}): {}".format(key, type(val), val)
|
||||
for key, val in self.__dict__.items()
|
||||
" |w{}|n ({}): {}".format(key, type(val), val) for key, val in self.__dict__.items()
|
||||
)
|
||||
string = f"""
|
||||
Command {self} has no defined `func()` - showing on-command variables: No child func() defined for {self} - available variables:
|
||||
|
|
@ -253,9 +236,7 @@ Command {self} has no defined `func()` - showing on-command variables: No child
|
|||
string += "cmd args (self.args): |w%s|n\n" % self.args
|
||||
string += "cmd switches (self.switches): |w%s|n\n" % self.switches
|
||||
string += "cmd options (self.switch_options): |w%s|n\n" % self.switch_options
|
||||
string += (
|
||||
"cmd parse left/right using (self.rhs_split): |w%s|n\n" % self.rhs_split
|
||||
)
|
||||
string += "cmd parse left/right using (self.rhs_split): |w%s|n\n" % self.rhs_split
|
||||
string += "space-separated arg list (self.arglist): |w%s|n\n" % self.arglist
|
||||
string += "lhs, left-hand side of '=' (self.lhs): |w%s|n\n" % self.lhs
|
||||
string += "lhs, comma separated (self.lhslist): |w%s|n\n" % self.lhslist
|
||||
|
|
@ -280,6 +261,4 @@ class MuxAccountCommand(MuxCommand):
|
|||
character is actually attached to this Account and Session.
|
||||
"""
|
||||
|
||||
account_caller = (
|
||||
True
|
||||
) # Using MuxAccountCommand explicitly defaults the caller to an account
|
||||
account_caller = True # Using MuxAccountCommand explicitly defaults the caller to an account
|
||||
|
|
|
|||
|
|
@ -103,9 +103,7 @@ class SystemMultimatch(COMMAND_DEFAULT_CLASS):
|
|||
# evennia.commands.cmdparse.create_match for more details.
|
||||
matches = self.matches
|
||||
# at_search_result will itself msg the multimatch options to the caller.
|
||||
at_search_result(
|
||||
[match[2] for match in matches], self.caller, query=matches[0][0]
|
||||
)
|
||||
at_search_result([match[2] for match in matches], self.caller, query=matches[0][0])
|
||||
|
||||
|
||||
# Command called when the command given at the command line
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ from evennia.accounts.models import AccountDB
|
|||
from evennia.utils import logger, utils, gametime, create, search
|
||||
from evennia.utils.eveditor import EvEditor
|
||||
from evennia.utils.evtable import EvTable
|
||||
from evennia.utils.evmore import EvMore
|
||||
from evennia.utils.utils import crop, class_from_module
|
||||
|
||||
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
||||
|
|
@ -150,12 +151,7 @@ def _py_code(caller, buf):
|
|||
string = "Executing code%s ..." % (" (measure timing)" if measure_time else "")
|
||||
caller.msg(string)
|
||||
_run_code_snippet(
|
||||
caller,
|
||||
buf,
|
||||
mode="exec",
|
||||
measure_time=measure_time,
|
||||
client_raw=client_raw,
|
||||
show_input=False,
|
||||
caller, buf, mode="exec", measure_time=measure_time, client_raw=client_raw, show_input=False
|
||||
)
|
||||
return True
|
||||
|
||||
|
|
@ -240,9 +236,7 @@ def _run_code_snippet(
|
|||
|
||||
for session in sessions:
|
||||
try:
|
||||
caller.msg(
|
||||
ret, session=session, options={"raw": True, "client_raw": client_raw}
|
||||
)
|
||||
caller.msg(ret, session=session, options={"raw": True, "client_raw": client_raw})
|
||||
except TypeError:
|
||||
caller.msg(ret, options={"raw": True, "client_raw": client_raw})
|
||||
|
||||
|
|
@ -416,7 +410,9 @@ def format_script_list(scripts):
|
|||
align="r",
|
||||
border="tablecols",
|
||||
)
|
||||
|
||||
for script in scripts:
|
||||
|
||||
nextrep = script.time_until_next_repeat()
|
||||
if nextrep is None:
|
||||
nextrep = "PAUS" if script.db._paused_time else "--"
|
||||
|
|
@ -440,6 +436,7 @@ def format_script_list(scripts):
|
|||
script.typeclass_path.rsplit(".", 1)[-1],
|
||||
crop(script.desc, width=20),
|
||||
)
|
||||
|
||||
return "%s" % table
|
||||
|
||||
|
||||
|
|
@ -484,9 +481,7 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
|||
if new_script:
|
||||
caller.msg("Global script %s was started successfully." % args)
|
||||
else:
|
||||
caller.msg(
|
||||
"Global script %s could not start correctly. See logs." % args
|
||||
)
|
||||
caller.msg("Global script %s could not start correctly. See logs." % args)
|
||||
return
|
||||
|
||||
# test first if this is a script match
|
||||
|
|
@ -507,10 +502,7 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
|||
return
|
||||
|
||||
if not scripts:
|
||||
string = "No scripts found with a key '%s', or on an object named '%s'." % (
|
||||
args,
|
||||
args,
|
||||
)
|
||||
string = "No scripts found with a key '%s', or on an object named '%s'." % (args, args)
|
||||
caller.msg(string)
|
||||
return
|
||||
|
||||
|
|
@ -539,7 +531,7 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
|||
else:
|
||||
# No stopping or validation. We just want to view things.
|
||||
string = format_script_list(scripts)
|
||||
caller.msg(string)
|
||||
EvMore(caller, string)
|
||||
|
||||
|
||||
class CmdObjects(COMMAND_DEFAULT_CLASS):
|
||||
|
|
@ -597,9 +589,7 @@ class CmdObjects(COMMAND_DEFAULT_CLASS):
|
|||
nexits,
|
||||
"%.2f" % ((float(nexits) / nobjs) * 100),
|
||||
)
|
||||
totaltable.add_row(
|
||||
"Other", "", nother, "%.2f" % ((float(nother) / nobjs) * 100)
|
||||
)
|
||||
totaltable.add_row("Other", "", nother, "%.2f" % ((float(nother) / nobjs) * 100))
|
||||
|
||||
# typeclass table
|
||||
typetable = self.styled_table(
|
||||
|
|
@ -611,16 +601,9 @@ class CmdObjects(COMMAND_DEFAULT_CLASS):
|
|||
typetable.add_row(path, count, "%.2f" % ((float(count) / nobjs) * 100))
|
||||
|
||||
# last N table
|
||||
objs = ObjectDB.objects.all().order_by("db_date_created")[
|
||||
max(0, nobjs - nlim) :
|
||||
]
|
||||
objs = ObjectDB.objects.all().order_by("db_date_created")[max(0, nobjs - nlim) :]
|
||||
latesttable = self.styled_table(
|
||||
"|wcreated|n",
|
||||
"|wdbref|n",
|
||||
"|wname|n",
|
||||
"|wtypeclass|n",
|
||||
align="l",
|
||||
border="table",
|
||||
"|wcreated|n", "|wdbref|n", "|wname|n", "|wtypeclass|n", align="l", border="table"
|
||||
)
|
||||
latesttable.align = "l"
|
||||
for obj in objs:
|
||||
|
|
@ -628,10 +611,7 @@ class CmdObjects(COMMAND_DEFAULT_CLASS):
|
|||
utils.datetime_format(obj.date_created), obj.dbref, obj.key, obj.path
|
||||
)
|
||||
|
||||
string = "\n|wObject subtype totals (out of %i Objects):|n\n%s" % (
|
||||
nobjs,
|
||||
totaltable,
|
||||
)
|
||||
string = "\n|wObject subtype totals (out of %i Objects):|n\n%s" % (nobjs, totaltable)
|
||||
string += "\n|wObject typeclass distribution:|n\n%s" % typetable
|
||||
string += "\n|wLast %s Objects created:|n\n%s" % (min(nobjs, nlim), latesttable)
|
||||
caller.msg(string)
|
||||
|
|
@ -684,9 +664,7 @@ class CmdAccounts(COMMAND_DEFAULT_CLASS):
|
|||
return
|
||||
if len(accounts) > 1:
|
||||
string = "There were multiple matches:\n"
|
||||
string += "\n".join(
|
||||
" %s %s" % (account.id, account.key) for account in accounts
|
||||
)
|
||||
string += "\n".join(" %s %s" % (account.id, account.key) for account in accounts)
|
||||
self.msg(string)
|
||||
return
|
||||
account = accounts.first()
|
||||
|
|
@ -735,16 +713,9 @@ class CmdAccounts(COMMAND_DEFAULT_CLASS):
|
|||
for path, count in dbtotals.items():
|
||||
typetable.add_row(path, count, "%.2f" % ((float(count) / naccounts) * 100))
|
||||
# last N table
|
||||
plyrs = AccountDB.objects.all().order_by("db_date_created")[
|
||||
max(0, naccounts - nlim) :
|
||||
]
|
||||
plyrs = AccountDB.objects.all().order_by("db_date_created")[max(0, naccounts - nlim) :]
|
||||
latesttable = self.styled_table(
|
||||
"|wcreated|n",
|
||||
"|wdbref|n",
|
||||
"|wname|n",
|
||||
"|wtypeclass|n",
|
||||
border="cells",
|
||||
align="l",
|
||||
"|wcreated|n", "|wdbref|n", "|wname|n", "|wtypeclass|n", border="cells", align="l"
|
||||
)
|
||||
for ply in plyrs:
|
||||
latesttable.add_row(
|
||||
|
|
@ -752,10 +723,7 @@ class CmdAccounts(COMMAND_DEFAULT_CLASS):
|
|||
)
|
||||
|
||||
string = "\n|wAccount typeclass distribution:|n\n%s" % typetable
|
||||
string += "\n|wLast %s Accounts created:|n\n%s" % (
|
||||
min(naccounts, nlim),
|
||||
latesttable,
|
||||
)
|
||||
string += "\n|wLast %s Accounts created:|n\n%s" % (min(naccounts, nlim), latesttable)
|
||||
caller.msg(string)
|
||||
|
||||
|
||||
|
|
@ -805,9 +773,7 @@ class CmdService(COMMAND_DEFAULT_CLASS):
|
|||
"|wService|n (use services/start|stop|delete)", "|wstatus", align="l"
|
||||
)
|
||||
for service in service_collection.services:
|
||||
table.add_row(
|
||||
service.name, service.running and "|gRunning" or "|rNot Running"
|
||||
)
|
||||
table.add_row(service.name, service.running and "|gRunning" or "|rNot Running")
|
||||
caller.msg(str(table))
|
||||
return
|
||||
|
||||
|
|
@ -817,9 +783,7 @@ class CmdService(COMMAND_DEFAULT_CLASS):
|
|||
service = service_collection.getServiceNamed(self.args)
|
||||
except Exception:
|
||||
string = "Invalid service name. This command is case-sensitive. "
|
||||
string += (
|
||||
"See service/list for valid service name (enter the full name exactly)."
|
||||
)
|
||||
string += "See service/list for valid service name (enter the full name exactly)."
|
||||
caller.msg(string)
|
||||
return
|
||||
|
||||
|
|
@ -833,9 +797,7 @@ class CmdService(COMMAND_DEFAULT_CLASS):
|
|||
return
|
||||
if service.name[:7] == "Evennia":
|
||||
if delmode:
|
||||
caller.msg(
|
||||
"You cannot remove a core Evennia service (named 'Evennia***')."
|
||||
)
|
||||
caller.msg("You cannot remove a core Evennia service (named 'Evennia***').")
|
||||
return
|
||||
string = "You seem to be shutting down a core Evennia service (named 'Evennia***'). Note that"
|
||||
string += "stopping some TCP port services will *not* disconnect users *already*"
|
||||
|
|
@ -927,9 +889,7 @@ class CmdTime(COMMAND_DEFAULT_CLASS):
|
|||
table1.add_row("Current uptime", utils.time_format(gametime.uptime(), 3))
|
||||
table1.add_row("Portal uptime", utils.time_format(gametime.portal_uptime(), 3))
|
||||
table1.add_row("Total runtime", utils.time_format(gametime.runtime(), 2))
|
||||
table1.add_row(
|
||||
"First start", datetime.datetime.fromtimestamp(gametime.server_epoch())
|
||||
)
|
||||
table1.add_row("First start", datetime.datetime.fromtimestamp(gametime.server_epoch()))
|
||||
table1.add_row("Current time", datetime.datetime.now())
|
||||
table1.reformat_column(0, width=30)
|
||||
table2 = self.styled_table(
|
||||
|
|
@ -939,14 +899,11 @@ class CmdTime(COMMAND_DEFAULT_CLASS):
|
|||
width=77,
|
||||
border_top=0,
|
||||
)
|
||||
epochtxt = "Epoch (%s)" % (
|
||||
"from settings" if settings.TIME_GAME_EPOCH else "server start"
|
||||
)
|
||||
epochtxt = "Epoch (%s)" % ("from settings" if settings.TIME_GAME_EPOCH else "server start")
|
||||
table2.add_row(epochtxt, datetime.datetime.fromtimestamp(gametime.game_epoch()))
|
||||
table2.add_row("Total time passed:", utils.time_format(gametime.gametime(), 2))
|
||||
table2.add_row(
|
||||
"Current time ",
|
||||
datetime.datetime.fromtimestamp(gametime.gametime(absolute=True)),
|
||||
"Current time ", datetime.datetime.fromtimestamp(gametime.gametime(absolute=True))
|
||||
)
|
||||
table2.reformat_column(0, width=30)
|
||||
self.caller.msg(str(table1) + "\n" + str(table2))
|
||||
|
|
@ -1043,9 +1000,7 @@ class CmdServerLoad(COMMAND_DEFAULT_CLASS):
|
|||
# Display table
|
||||
loadtable = self.styled_table("property", "statistic", align="l")
|
||||
loadtable.add_row("Total CPU load", "%g %%" % loadavg)
|
||||
loadtable.add_row(
|
||||
"Total computer memory usage", "%g MB (%g%%)" % (rmem, pmem)
|
||||
)
|
||||
loadtable.add_row("Total computer memory usage", "%g MB (%g%%)" % (rmem, pmem))
|
||||
loadtable.add_row("Process ID", "%g" % pid),
|
||||
else:
|
||||
loadtable = (
|
||||
|
|
@ -1062,12 +1017,10 @@ class CmdServerLoad(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
loadavg = os.getloadavg()[0]
|
||||
rmem = (
|
||||
float(os.popen("ps -p %d -o %s | tail -1" % (pid, "rss")).read())
|
||||
/ 1000.0
|
||||
float(os.popen("ps -p %d -o %s | tail -1" % (pid, "rss")).read()) / 1000.0
|
||||
) # resident memory
|
||||
vmem = (
|
||||
float(os.popen("ps -p %d -o %s | tail -1" % (pid, "vsz")).read())
|
||||
/ 1000.0
|
||||
float(os.popen("ps -p %d -o %s | tail -1" % (pid, "vsz")).read()) / 1000.0
|
||||
) # virtual memory
|
||||
pmem = float(
|
||||
os.popen("ps -p %d -o %s | tail -1" % (pid, "%mem")).read()
|
||||
|
|
@ -1099,12 +1052,9 @@ class CmdServerLoad(COMMAND_DEFAULT_CLASS):
|
|||
% (rusage.ru_majflt, rusage.ru_minflt, rusage.ru_nswap),
|
||||
)
|
||||
loadtable.add_row(
|
||||
"Disk I/O",
|
||||
"%g reads, %g writes" % (rusage.ru_inblock, rusage.ru_oublock),
|
||||
)
|
||||
loadtable.add_row(
|
||||
"Network I/O", "%g in, %g out" % (rusage.ru_msgrcv, rusage.ru_msgsnd)
|
||||
"Disk I/O", "%g reads, %g writes" % (rusage.ru_inblock, rusage.ru_oublock)
|
||||
)
|
||||
loadtable.add_row("Network I/O", "%g in, %g out" % (rusage.ru_msgrcv, rusage.ru_msgsnd))
|
||||
loadtable.add_row(
|
||||
"Context switching",
|
||||
"%g vol, %g forced, %g signals"
|
||||
|
|
@ -1124,9 +1074,7 @@ class CmdServerLoad(COMMAND_DEFAULT_CLASS):
|
|||
)
|
||||
memtable = self.styled_table("entity name", "number", "idmapper %", align="l")
|
||||
for tup in sorted_cache:
|
||||
memtable.add_row(
|
||||
tup[0], "%i" % tup[1], "%.2f" % (float(tup[1]) / total_num * 100)
|
||||
)
|
||||
memtable.add_row(tup[0], "%i" % tup[1], "%.2f" % (float(tup[1]) / total_num * 100))
|
||||
|
||||
string += "\n|w Entity idmapper cache:|n %i items\n%s" % (total_num, memtable)
|
||||
|
||||
|
|
@ -1158,18 +1106,14 @@ class CmdTickers(COMMAND_DEFAULT_CLASS):
|
|||
if not all_subs:
|
||||
self.caller.msg("No tickers are currently active.")
|
||||
return
|
||||
table = self.styled_table(
|
||||
"interval (s)", "object", "path/methodname", "idstring", "db"
|
||||
)
|
||||
table = self.styled_table("interval (s)", "object", "path/methodname", "idstring", "db")
|
||||
for sub in all_subs:
|
||||
table.add_row(
|
||||
sub[3],
|
||||
"%s%s"
|
||||
% (
|
||||
sub[0] or "[None]",
|
||||
sub[0]
|
||||
and " (#%s)" % (sub[0].id if hasattr(sub[0], "id") else "")
|
||||
or "",
|
||||
sub[0] and " (#%s)" % (sub[0].id if hasattr(sub[0], "id") else "") or "",
|
||||
),
|
||||
sub[1] if sub[1] else sub[2],
|
||||
sub[4] or "[Unset]",
|
||||
|
|
|
|||
|
|
@ -99,9 +99,7 @@ class CommandTest(EvenniaTest):
|
|||
cmdobj.cmdset = cmdset
|
||||
cmdobj.session = SESSIONS.session_from_sessid(1)
|
||||
cmdobj.account = self.account
|
||||
cmdobj.raw_string = (
|
||||
raw_string if raw_string is not None else cmdobj.key + " " + args
|
||||
)
|
||||
cmdobj.raw_string = raw_string if raw_string is not None else cmdobj.key + " " + args
|
||||
cmdobj.obj = obj or (caller if caller else self.char1)
|
||||
# test
|
||||
old_msg = receiver.msg
|
||||
|
|
@ -142,18 +140,14 @@ class CommandTest(EvenniaTest):
|
|||
for name, args, kwargs in receiver.msg.mock_calls
|
||||
]
|
||||
# Get the first element of a tuple if msg received a tuple instead of a string
|
||||
stored_msg = [
|
||||
str(smsg[0]) if isinstance(smsg, tuple) else str(smsg)
|
||||
for smsg in stored_msg
|
||||
]
|
||||
stored_msg = [str(smsg[0]) if isinstance(smsg, tuple) else str(smsg) for smsg in stored_msg]
|
||||
if msg is not None:
|
||||
msg = str(msg) # to be safe, e.g. `py` command may return ints
|
||||
# set our separator for returned messages based on parsing ansi or not
|
||||
msg_sep = "|" if noansi else "||"
|
||||
# Have to strip ansi for each returned message for the regex to handle it correctly
|
||||
returned_msg = msg_sep.join(
|
||||
_RE.sub("", ansi.parse_ansi(mess, strip_ansi=noansi))
|
||||
for mess in stored_msg
|
||||
_RE.sub("", ansi.parse_ansi(mess, strip_ansi=noansi)) for mess in stored_msg
|
||||
).strip()
|
||||
if msg == "" and returned_msg or not returned_msg.startswith(msg.strip()):
|
||||
sep1 = "\n" + "=" * 30 + "Wanted message" + "=" * 34 + "\n"
|
||||
|
|
@ -208,12 +202,8 @@ class TestGeneral(CommandTest):
|
|||
self.assertEqual(
|
||||
"testaliasedstring2", self.char1.nicks.get("testalias", category="account")
|
||||
)
|
||||
self.assertEqual(
|
||||
None, self.char1.account.nicks.get("testalias", category="account")
|
||||
)
|
||||
self.assertEqual(
|
||||
"testaliasedstring3", self.char1.nicks.get("testalias", category="object")
|
||||
)
|
||||
self.assertEqual(None, self.char1.account.nicks.get("testalias", category="account"))
|
||||
self.assertEqual("testaliasedstring3", self.char1.nicks.get("testalias", category="object"))
|
||||
|
||||
def test_get_and_drop(self):
|
||||
self.call(general.CmdGet(), "Obj", "You pick up Obj.")
|
||||
|
|
@ -240,13 +230,9 @@ class TestGeneral(CommandTest):
|
|||
"Switches matched: ['test', 'testswitch', 'testswitch2']",
|
||||
)
|
||||
self.call(CmdTest(), "/test", "Switches matched: ['test']")
|
||||
self.call(CmdTest(), "/test/testswitch", "Switches matched: ['test', 'testswitch']")
|
||||
self.call(
|
||||
CmdTest(), "/test/testswitch", "Switches matched: ['test', 'testswitch']"
|
||||
)
|
||||
self.call(
|
||||
CmdTest(),
|
||||
"/testswitch/testswitch2",
|
||||
"Switches matched: ['testswitch', 'testswitch2']",
|
||||
CmdTest(), "/testswitch/testswitch2", "Switches matched: ['testswitch', 'testswitch2']"
|
||||
)
|
||||
self.call(CmdTest(), "/testswitch", "Switches matched: ['testswitch']")
|
||||
self.call(CmdTest(), "/testswitch2", "Switches matched: ['testswitch2']")
|
||||
|
|
@ -288,9 +274,7 @@ class TestHelp(CommandTest):
|
|||
"testhelp, General = This is a test",
|
||||
"Topic 'testhelp' was successfully created.",
|
||||
)
|
||||
self.call(
|
||||
help.CmdHelp(), "testhelp", "Help for testhelp", cmdset=CharacterCmdSet()
|
||||
)
|
||||
self.call(help.CmdHelp(), "testhelp", "Help for testhelp", cmdset=CharacterCmdSet())
|
||||
|
||||
|
||||
class TestSystem(CommandTest):
|
||||
|
|
@ -348,10 +332,7 @@ class TestAccount(CommandTest):
|
|||
def test_ooc_look(self):
|
||||
if settings.MULTISESSION_MODE < 2:
|
||||
self.call(
|
||||
account.CmdOOCLook(),
|
||||
"",
|
||||
"You are out-of-character (OOC).",
|
||||
caller=self.account,
|
||||
account.CmdOOCLook(), "", "You are out-of-character (OOC).", caller=self.account
|
||||
)
|
||||
if settings.MULTISESSION_MODE == 2:
|
||||
self.call(
|
||||
|
|
@ -367,11 +348,7 @@ class TestAccount(CommandTest):
|
|||
def test_ic(self):
|
||||
self.account.unpuppet_object(self.session)
|
||||
self.call(
|
||||
account.CmdIC(),
|
||||
"Char",
|
||||
"You become Char.",
|
||||
caller=self.account,
|
||||
receiver=self.char1,
|
||||
account.CmdIC(), "Char", "You become Char.", caller=self.account, receiver=self.char1
|
||||
)
|
||||
|
||||
def test_password(self):
|
||||
|
|
@ -390,16 +367,11 @@ class TestAccount(CommandTest):
|
|||
|
||||
def test_quit(self):
|
||||
self.call(
|
||||
account.CmdQuit(),
|
||||
"",
|
||||
"Quitting. Hope to see you again, soon.",
|
||||
caller=self.account,
|
||||
account.CmdQuit(), "", "Quitting. Hope to see you again, soon.", caller=self.account
|
||||
)
|
||||
|
||||
def test_sessions(self):
|
||||
self.call(
|
||||
account.CmdSessions(), "", "Your current session(s):", caller=self.account
|
||||
)
|
||||
self.call(account.CmdSessions(), "", "Your current session(s):", caller=self.account)
|
||||
|
||||
def test_color_test(self):
|
||||
self.call(account.CmdColorTest(), "ansi", "ANSI colors:", caller=self.account)
|
||||
|
|
@ -484,11 +456,7 @@ class TestBuilding(CommandTest):
|
|||
self.call(building.CmdExamine(), "*TestAccount", "Name/key: TestAccount")
|
||||
|
||||
self.char1.db.test = "testval"
|
||||
self.call(
|
||||
building.CmdExamine(),
|
||||
"self/test",
|
||||
"Persistent attributes:\n test = testval",
|
||||
)
|
||||
self.call(building.CmdExamine(), "self/test", "Persistent attributes:\n test = testval")
|
||||
self.call(building.CmdExamine(), "NotFound", "Could not find 'NotFound'.")
|
||||
self.call(building.CmdExamine(), "out", "Name/key: out")
|
||||
|
||||
|
|
@ -508,11 +476,7 @@ class TestBuilding(CommandTest):
|
|||
self.call(building.CmdSetObjAlias(), "", "Usage: ")
|
||||
self.call(building.CmdSetObjAlias(), "NotFound =", "Could not find 'NotFound'.")
|
||||
|
||||
self.call(
|
||||
building.CmdSetObjAlias(),
|
||||
"Obj",
|
||||
"Aliases for Obj(#{}): 'testobj1b'".format(oid),
|
||||
)
|
||||
self.call(building.CmdSetObjAlias(), "Obj", "Aliases for Obj(#{}): 'testobj1b'".format(oid))
|
||||
self.call(building.CmdSetObjAlias(), "Obj2 =", "Cleared aliases from Obj2")
|
||||
self.call(building.CmdSetObjAlias(), "Obj2 =", "No aliases to clear.")
|
||||
|
||||
|
|
@ -523,11 +487,7 @@ class TestBuilding(CommandTest):
|
|||
"Copied Obj to 'TestObj3' (aliases: ['TestObj3b']",
|
||||
)
|
||||
self.call(building.CmdCopy(), "", "Usage: ")
|
||||
self.call(
|
||||
building.CmdCopy(),
|
||||
"Obj",
|
||||
"Identical copy of Obj, named 'Obj_copy' was created.",
|
||||
)
|
||||
self.call(building.CmdCopy(), "Obj", "Identical copy of Obj, named 'Obj_copy' was created.")
|
||||
self.call(building.CmdCopy(), "NotFound = Foo", "Could not find 'NotFound'.")
|
||||
|
||||
def test_attribute_commands(self):
|
||||
|
|
@ -542,14 +502,8 @@ class TestBuilding(CommandTest):
|
|||
'Obj2/test2="value2"',
|
||||
"Created attribute Obj2/test2 = 'value2'",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj2/test2", "Attribute Obj2/test2 = value2"
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj2/NotFound",
|
||||
"Obj2 has no attribute 'notfound'.",
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj2/test2", "Attribute Obj2/test2 = value2")
|
||||
self.call(building.CmdSetAttribute(), "Obj2/NotFound", "Obj2 has no attribute 'notfound'.")
|
||||
|
||||
with mock.patch("evennia.commands.default.building.EvEditor") as mock_ed:
|
||||
self.call(building.CmdSetAttribute(), "/edit Obj2/test3")
|
||||
|
|
@ -573,59 +527,35 @@ class TestBuilding(CommandTest):
|
|||
"(value: 'value2')",
|
||||
)
|
||||
self.call(building.CmdMvAttr(), "", "Usage: ")
|
||||
self.call(
|
||||
building.CmdMvAttr(),
|
||||
"Obj2/test2 = Obj/test3",
|
||||
"Moved Obj2.test2 -> Obj.test3",
|
||||
)
|
||||
self.call(building.CmdMvAttr(), "Obj2/test2 = Obj/test3", "Moved Obj2.test2 -> Obj.test3")
|
||||
self.call(building.CmdCpAttr(), "", "Usage: ")
|
||||
self.call(
|
||||
building.CmdCpAttr(),
|
||||
"Obj/test1 = Obj2/test3",
|
||||
"Copied Obj.test1 -> Obj2.test3",
|
||||
)
|
||||
self.call(building.CmdCpAttr(), "Obj/test1 = Obj2/test3", "Copied Obj.test1 -> Obj2.test3")
|
||||
|
||||
self.call(building.CmdWipe(), "", "Usage: ")
|
||||
self.call(
|
||||
building.CmdWipe(),
|
||||
"Obj2/test2/test3",
|
||||
"Wiped attributes test2,test3 on Obj2.",
|
||||
)
|
||||
self.call(building.CmdWipe(), "Obj2/test2/test3", "Wiped attributes test2,test3 on Obj2.")
|
||||
self.call(building.CmdWipe(), "Obj2", "Wiped all attributes on Obj2.")
|
||||
|
||||
def test_nested_attribute_commands(self):
|
||||
# list - adding white space proves real parsing
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test1=[1,2]",
|
||||
"Created attribute Obj/test1 = [1, 2]",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj/test1", "Attribute Obj/test1 = [1, 2]"
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj/test1[0]", "Attribute Obj/test1[0] = 1"
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj/test1[1]", "Attribute Obj/test1[1] = 2"
|
||||
building.CmdSetAttribute(), "Obj/test1=[1,2]", "Created attribute Obj/test1 = [1, 2]"
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test1", "Attribute Obj/test1 = [1, 2]")
|
||||
self.call(building.CmdSetAttribute(), "Obj/test1[0]", "Attribute Obj/test1[0] = 1")
|
||||
self.call(building.CmdSetAttribute(), "Obj/test1[1]", "Attribute Obj/test1[1] = 2")
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test1[0] = 99",
|
||||
"Modified attribute Obj/test1 = [99, 2]",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj/test1[0]", "Attribute Obj/test1[0] = 99"
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test1[0]", "Attribute Obj/test1[0] = 99")
|
||||
# list delete
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test1[0] =",
|
||||
"Deleted attribute 'test1[0]' (= nested) from Obj.",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj/test1[0]", "Attribute Obj/test1[0] = 2"
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test1[0]", "Attribute Obj/test1[0] = 2")
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test1[1]",
|
||||
|
|
@ -656,35 +586,17 @@ class TestBuilding(CommandTest):
|
|||
"Created attribute Obj/test2 = {'one': 1, 'two': 2}",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2",
|
||||
"Attribute Obj/test2 = {'one': 1, 'two': 2}",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2['one']",
|
||||
"Attribute Obj/test2['one'] = 1",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2['one]",
|
||||
"Attribute Obj/test2['one] = 1",
|
||||
building.CmdSetAttribute(), "Obj/test2", "Attribute Obj/test2 = {'one': 1, 'two': 2}"
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test2['one']", "Attribute Obj/test2['one'] = 1")
|
||||
self.call(building.CmdSetAttribute(), "Obj/test2['one]", "Attribute Obj/test2['one] = 1")
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2['one']=99",
|
||||
"Modified attribute Obj/test2 = {'one': 99, 'two': 2}",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2['one']",
|
||||
"Attribute Obj/test2['one'] = 99",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2['two']",
|
||||
"Attribute Obj/test2['two'] = 2",
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test2['one']", "Attribute Obj/test2['one'] = 99")
|
||||
self.call(building.CmdSetAttribute(), "Obj/test2['two']", "Attribute Obj/test2['two'] = 2")
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2[+'three']",
|
||||
|
|
@ -717,9 +629,7 @@ class TestBuilding(CommandTest):
|
|||
"Obj has no attribute 'test2['two']'. (Nested lookups attempted)",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2",
|
||||
"Attribute Obj/test2 = {'one': 99, 'three': 3}",
|
||||
building.CmdSetAttribute(), "Obj/test2", "Attribute Obj/test2 = {'one': 99, 'three': 3}"
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
|
|
@ -744,9 +654,7 @@ class TestBuilding(CommandTest):
|
|||
|
||||
# tuple
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/tup = (1,2)",
|
||||
"Created attribute Obj/tup = (1, 2)",
|
||||
building.CmdSetAttribute(), "Obj/tup = (1,2)", "Created attribute Obj/tup = (1, 2)"
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
|
|
@ -777,23 +685,15 @@ class TestBuilding(CommandTest):
|
|||
"Created attribute Obj/test3 = [{'one': 1}]",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test3[0]['one']",
|
||||
"Attribute Obj/test3[0]['one'] = 1",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test3[0]",
|
||||
"Attribute Obj/test3[0] = {'one': 1}",
|
||||
building.CmdSetAttribute(), "Obj/test3[0]['one']", "Attribute Obj/test3[0]['one'] = 1"
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test3[0]", "Attribute Obj/test3[0] = {'one': 1}")
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test3[0]['one'] =",
|
||||
"Deleted attribute 'test3[0]['one']' (= nested) from Obj.",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj/test3[0]", "Attribute Obj/test3[0] = {}"
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test3[0]", "Attribute Obj/test3[0] = {}")
|
||||
self.call(building.CmdSetAttribute(), "Obj/test3", "Attribute Obj/test3 = [{}]")
|
||||
|
||||
# Naughty keys
|
||||
|
|
@ -802,35 +702,23 @@ class TestBuilding(CommandTest):
|
|||
"Obj/test4[0]='foo'",
|
||||
"Created attribute Obj/test4[0] = 'foo'",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj/test4[0]", "Attribute Obj/test4[0] = foo"
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test4[0]", "Attribute Obj/test4[0] = foo")
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test4=[{'one': 1}]",
|
||||
"Created attribute Obj/test4 = [{'one': 1}]",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test4[0]['one']",
|
||||
"Attribute Obj/test4[0]['one'] = 1",
|
||||
building.CmdSetAttribute(), "Obj/test4[0]['one']", "Attribute Obj/test4[0]['one'] = 1"
|
||||
)
|
||||
# Prefer nested items
|
||||
self.call(building.CmdSetAttribute(), "Obj/test4[0]", "Attribute Obj/test4[0] = {'one': 1}")
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test4[0]",
|
||||
"Attribute Obj/test4[0] = {'one': 1}",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test4[0]['one']",
|
||||
"Attribute Obj/test4[0]['one'] = 1",
|
||||
building.CmdSetAttribute(), "Obj/test4[0]['one']", "Attribute Obj/test4[0]['one'] = 1"
|
||||
)
|
||||
# Restored access
|
||||
self.call(building.CmdWipe(), "Obj/test4", "Wiped attributes test4 on Obj.")
|
||||
self.call(
|
||||
building.CmdSetAttribute(), "Obj/test4[0]", "Attribute Obj/test4[0] = foo"
|
||||
)
|
||||
self.call(building.CmdSetAttribute(), "Obj/test4[0]", "Attribute Obj/test4[0] = foo")
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test4[0]['one']",
|
||||
|
|
@ -848,11 +736,7 @@ class TestBuilding(CommandTest):
|
|||
# duplicate keys don't cause issues
|
||||
"test5[0][0]": [("test5", [0, 0]), ("test5[0]", [0]), ("test5[0][0]", [])],
|
||||
# String ints preserved
|
||||
'test6["0"][0]': [
|
||||
("test6", ["0", 0]),
|
||||
('test6["0"]', [0]),
|
||||
('test6["0"][0]', []),
|
||||
],
|
||||
'test6["0"][0]': [("test6", ["0", 0]), ('test6["0"]', [0]), ('test6["0"][0]', [])],
|
||||
# Unmatched []
|
||||
"test7[dict": [("test7[dict", [])],
|
||||
}
|
||||
|
|
@ -892,24 +776,16 @@ class TestBuilding(CommandTest):
|
|||
"*TestAccount=TestAccountRenamed",
|
||||
"Account's name changed to 'TestAccountRenamed'.",
|
||||
)
|
||||
self.call(building.CmdName(), "*NotFound=TestAccountRenamed", "Could not find '*NotFound'")
|
||||
self.call(
|
||||
building.CmdName(),
|
||||
"*NotFound=TestAccountRenamed",
|
||||
"Could not find '*NotFound'",
|
||||
)
|
||||
self.call(
|
||||
building.CmdName(),
|
||||
"Obj3=Obj4;foo;bar",
|
||||
"Object's name changed to 'Obj4' (foo, bar).",
|
||||
building.CmdName(), "Obj3=Obj4;foo;bar", "Object's name changed to 'Obj4' (foo, bar)."
|
||||
)
|
||||
self.call(building.CmdName(), "Obj4=", "No names or aliases defined!")
|
||||
|
||||
def test_desc(self):
|
||||
oid = self.obj2.id
|
||||
self.call(
|
||||
building.CmdDesc(),
|
||||
"Obj2=TestDesc",
|
||||
"The description was set on Obj2(#{}).".format(oid),
|
||||
building.CmdDesc(), "Obj2=TestDesc", "The description was set on Obj2(#{}).".format(oid)
|
||||
)
|
||||
self.call(building.CmdDesc(), "", "Usage: ")
|
||||
|
||||
|
|
@ -931,11 +807,7 @@ class TestBuilding(CommandTest):
|
|||
oid = self.obj2.id
|
||||
o2d = self.obj2.db.desc
|
||||
r1d = self.room1.db.desc
|
||||
self.call(
|
||||
building.CmdDesc(),
|
||||
"Obj2=",
|
||||
"The description was set on Obj2(#{}).".format(oid),
|
||||
)
|
||||
self.call(building.CmdDesc(), "Obj2=", "The description was set on Obj2(#{}).".format(oid))
|
||||
assert self.obj2.db.desc == "" and self.obj2.db.desc != o2d
|
||||
assert self.room1.db.desc == r1d
|
||||
|
||||
|
|
@ -944,11 +816,7 @@ class TestBuilding(CommandTest):
|
|||
rid = self.room1.id
|
||||
o2d = self.obj2.db.desc
|
||||
r1d = self.room1.db.desc
|
||||
self.call(
|
||||
building.CmdDesc(),
|
||||
"Obj2",
|
||||
"The description was set on Room(#{}).".format(rid),
|
||||
)
|
||||
self.call(building.CmdDesc(), "Obj2", "The description was set on Room(#{}).".format(rid))
|
||||
assert self.obj2.db.desc == o2d
|
||||
assert self.room1.db.desc == "Obj2" and self.room1.db.desc != r1d
|
||||
|
||||
|
|
@ -990,22 +858,14 @@ class TestBuilding(CommandTest):
|
|||
)
|
||||
|
||||
def test_dig(self):
|
||||
self.call(
|
||||
building.CmdDig(), "TestRoom1=testroom;tr,back;b", "Created room TestRoom1"
|
||||
)
|
||||
self.call(building.CmdDig(), "TestRoom1=testroom;tr,back;b", "Created room TestRoom1")
|
||||
self.call(building.CmdDig(), "", "Usage: ")
|
||||
|
||||
def test_tunnel(self):
|
||||
self.call(building.CmdTunnel(), "n = TestRoom2;test2", "Created room TestRoom2")
|
||||
self.call(building.CmdTunnel(), "", "Usage: ")
|
||||
self.call(
|
||||
building.CmdTunnel(),
|
||||
"foo = TestRoom2;test2",
|
||||
"tunnel can only understand the",
|
||||
)
|
||||
self.call(
|
||||
building.CmdTunnel(), "/tel e = TestRoom3;test3", "Created room TestRoom3"
|
||||
)
|
||||
self.call(building.CmdTunnel(), "foo = TestRoom2;test2", "tunnel can only understand the")
|
||||
self.call(building.CmdTunnel(), "/tel e = TestRoom3;test3", "Created room TestRoom3")
|
||||
DefaultRoom.objects.get_family(db_key="TestRoom3")
|
||||
exits = DefaultExit.objects.filter_family(db_key__in=("east", "west"))
|
||||
self.assertEqual(len(exits), 2)
|
||||
|
|
@ -1019,32 +879,20 @@ class TestBuilding(CommandTest):
|
|||
|
||||
def test_exit_commands(self):
|
||||
self.call(
|
||||
building.CmdOpen(),
|
||||
"TestExit1=Room2",
|
||||
"Created new Exit 'TestExit1' from Room to Room2",
|
||||
)
|
||||
self.call(
|
||||
building.CmdLink(),
|
||||
"TestExit1=Room",
|
||||
"Link created TestExit1 -> Room (one way).",
|
||||
building.CmdOpen(), "TestExit1=Room2", "Created new Exit 'TestExit1' from Room to Room2"
|
||||
)
|
||||
self.call(building.CmdLink(), "TestExit1=Room", "Link created TestExit1 -> Room (one way).")
|
||||
self.call(building.CmdUnLink(), "", "Usage: ")
|
||||
self.call(building.CmdLink(), "NotFound", "Could not find 'NotFound'.")
|
||||
self.call(building.CmdLink(), "TestExit", "TestExit1 is an exit to Room.")
|
||||
self.call(building.CmdLink(), "Obj", "Obj is not an exit. Its home location is Room.")
|
||||
self.call(
|
||||
building.CmdLink(), "Obj", "Obj is not an exit. Its home location is Room."
|
||||
)
|
||||
self.call(
|
||||
building.CmdUnLink(),
|
||||
"TestExit1",
|
||||
"Former exit TestExit1 no longer links anywhere.",
|
||||
building.CmdUnLink(), "TestExit1", "Former exit TestExit1 no longer links anywhere."
|
||||
)
|
||||
|
||||
self.char1.location = self.room2
|
||||
self.call(
|
||||
building.CmdOpen(),
|
||||
"TestExit2=Room",
|
||||
"Created new Exit 'TestExit2' from Room2 to Room.",
|
||||
building.CmdOpen(), "TestExit2=Room", "Created new Exit 'TestExit2' from Room2 to Room."
|
||||
)
|
||||
self.call(
|
||||
building.CmdOpen(),
|
||||
|
|
@ -1054,9 +902,7 @@ class TestBuilding(CommandTest):
|
|||
|
||||
# ensure it matches locally first
|
||||
self.call(
|
||||
building.CmdLink(),
|
||||
"TestExit=Room2",
|
||||
"Link created TestExit2 -> Room2 (one way).",
|
||||
building.CmdLink(), "TestExit=Room2", "Link created TestExit2 -> Room2 (one way)."
|
||||
)
|
||||
self.call(
|
||||
building.CmdLink(),
|
||||
|
|
@ -1077,29 +923,21 @@ class TestBuilding(CommandTest):
|
|||
# ensure can still match globally when not a local name
|
||||
self.call(building.CmdLink(), "TestExit1=Room2", "Note: TestExit1")
|
||||
self.call(
|
||||
building.CmdLink(),
|
||||
"TestExit1=",
|
||||
"Former exit TestExit1 no longer links anywhere.",
|
||||
building.CmdLink(), "TestExit1=", "Former exit TestExit1 no longer links anywhere."
|
||||
)
|
||||
|
||||
def test_set_home(self):
|
||||
self.call(
|
||||
building.CmdSetHome(),
|
||||
"Obj = Room2",
|
||||
"Home location of Obj was changed from Room",
|
||||
building.CmdSetHome(), "Obj = Room2", "Home location of Obj was changed from Room"
|
||||
)
|
||||
self.call(building.CmdSetHome(), "", "Usage: ")
|
||||
self.call(building.CmdSetHome(), "self", "Char's current home is Room")
|
||||
self.call(building.CmdSetHome(), "Obj", "Obj's current home is Room2")
|
||||
self.obj1.home = None
|
||||
self.call(
|
||||
building.CmdSetHome(), "Obj = Room2", "Home location of Obj was set to Room"
|
||||
)
|
||||
self.call(building.CmdSetHome(), "Obj = Room2", "Home location of Obj was set to Room")
|
||||
|
||||
def test_list_cmdsets(self):
|
||||
self.call(
|
||||
building.CmdListCmdSets(), "", "<DefaultCharacter (Union, prio 0, perm)>:"
|
||||
)
|
||||
self.call(building.CmdListCmdSets(), "", "<DefaultCharacter (Union, prio 0, perm)>:")
|
||||
self.call(building.CmdListCmdSets(), "NotFound", "Could not find 'NotFound'")
|
||||
|
||||
def test_typeclass(self):
|
||||
|
|
@ -1133,9 +971,7 @@ class TestBuilding(CommandTest):
|
|||
"/force Obj = evennia.objects.objects.DefaultExit",
|
||||
"Obj updated its existing typeclass ",
|
||||
)
|
||||
self.call(
|
||||
building.CmdTypeclass(), "Obj = evennia.objects.objects.DefaultObject"
|
||||
)
|
||||
self.call(building.CmdTypeclass(), "Obj = evennia.objects.objects.DefaultObject")
|
||||
self.call(
|
||||
building.CmdTypeclass(),
|
||||
"/show Obj",
|
||||
|
|
@ -1157,19 +993,13 @@ class TestBuilding(CommandTest):
|
|||
|
||||
def test_lock(self):
|
||||
self.call(building.CmdLock(), "", "Usage: ")
|
||||
self.call(
|
||||
building.CmdLock(), "Obj = test:all()", "Added lock 'test:all()' to Obj."
|
||||
)
|
||||
self.call(building.CmdLock(), "Obj = test:all()", "Added lock 'test:all()' to Obj.")
|
||||
self.call(
|
||||
building.CmdLock(),
|
||||
"*TestAccount = test:all()",
|
||||
"Added lock 'test:all()' to TestAccount",
|
||||
)
|
||||
self.call(
|
||||
building.CmdLock(),
|
||||
"Obj/notfound",
|
||||
"Obj has no lock of access type 'notfound'.",
|
||||
)
|
||||
self.call(building.CmdLock(), "Obj/notfound", "Obj has no lock of access type 'notfound'.")
|
||||
self.call(building.CmdLock(), "Obj/test", "test:all()")
|
||||
self.call(
|
||||
building.CmdLock(),
|
||||
|
|
@ -1190,9 +1020,7 @@ class TestBuilding(CommandTest):
|
|||
self.call(building.CmdFind(), "", "Usage: ")
|
||||
self.call(building.CmdFind(), "oom2", "One Match")
|
||||
self.call(building.CmdFind(), "oom2 = 1-{}".format(rmax), "One Match")
|
||||
self.call(
|
||||
building.CmdFind(), "oom2 = 1 {}".format(rmax), "One Match"
|
||||
) # space works too
|
||||
self.call(building.CmdFind(), "oom2 = 1 {}".format(rmax), "One Match") # space works too
|
||||
self.call(building.CmdFind(), "Char2", "One Match", cmdstring="locate")
|
||||
self.call(
|
||||
building.CmdFind(),
|
||||
|
|
@ -1218,9 +1046,7 @@ class TestBuilding(CommandTest):
|
|||
def test_script(self):
|
||||
self.call(building.CmdScript(), "Obj = ", "No scripts defined on Obj")
|
||||
self.call(
|
||||
building.CmdScript(),
|
||||
"Obj = scripts.Script",
|
||||
"Script scripts.Script successfully added",
|
||||
building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added"
|
||||
)
|
||||
self.call(building.CmdScript(), "", "Usage: ")
|
||||
self.call(
|
||||
|
|
@ -1236,9 +1062,7 @@ class TestBuilding(CommandTest):
|
|||
self.call(building.CmdScript(), "/stop Obj", "Stopping script")
|
||||
|
||||
self.call(
|
||||
building.CmdScript(),
|
||||
"Obj = scripts.Script",
|
||||
"Script scripts.Script successfully added",
|
||||
building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added"
|
||||
)
|
||||
self.call(
|
||||
building.CmdScript(),
|
||||
|
|
@ -1269,18 +1093,12 @@ class TestBuilding(CommandTest):
|
|||
oid, rid, rid2
|
||||
),
|
||||
)
|
||||
self.call(building.CmdTeleport(), "NotFound = Room", "Could not find 'NotFound'.")
|
||||
self.call(
|
||||
building.CmdTeleport(), "NotFound = Room", "Could not find 'NotFound'."
|
||||
)
|
||||
self.call(
|
||||
building.CmdTeleport(),
|
||||
"Obj = Obj",
|
||||
"You can't teleport an object inside of itself!",
|
||||
building.CmdTeleport(), "Obj = Obj", "You can't teleport an object inside of itself!"
|
||||
)
|
||||
|
||||
self.call(
|
||||
building.CmdTeleport(), "/tonone Obj2", "Teleported Obj2 -> None-location."
|
||||
)
|
||||
self.call(building.CmdTeleport(), "/tonone Obj2", "Teleported Obj2 -> None-location.")
|
||||
self.call(building.CmdTeleport(), "/quiet Room2", "Room2(#{})".format(rid2))
|
||||
self.call(
|
||||
building.CmdTeleport(),
|
||||
|
|
@ -1309,30 +1127,19 @@ class TestBuilding(CommandTest):
|
|||
self.call(
|
||||
building.CmdTag(),
|
||||
"Obj",
|
||||
"Tags on Obj: 'testtag', 'testtag2', "
|
||||
"'testtag2' (category: category1), 'testtag3'",
|
||||
"Tags on Obj: 'testtag', 'testtag2', " "'testtag2' (category: category1), 'testtag3'",
|
||||
)
|
||||
|
||||
self.call(
|
||||
building.CmdTag(),
|
||||
"/search NotFound",
|
||||
"No objects found with tag 'NotFound'.",
|
||||
)
|
||||
self.call(
|
||||
building.CmdTag(), "/search testtag", "Found 1 object with tag 'testtag':"
|
||||
)
|
||||
self.call(
|
||||
building.CmdTag(), "/search testtag2", "Found 1 object with tag 'testtag2':"
|
||||
)
|
||||
self.call(building.CmdTag(), "/search NotFound", "No objects found with tag 'NotFound'.")
|
||||
self.call(building.CmdTag(), "/search testtag", "Found 1 object with tag 'testtag':")
|
||||
self.call(building.CmdTag(), "/search testtag2", "Found 1 object with tag 'testtag2':")
|
||||
self.call(
|
||||
building.CmdTag(),
|
||||
"/search testtag2:category1",
|
||||
"Found 1 object with tag 'testtag2' (category: 'category1'):",
|
||||
)
|
||||
|
||||
self.call(
|
||||
building.CmdTag(), "/del Obj = testtag3", "Removed tag 'testtag3' from Obj."
|
||||
)
|
||||
self.call(building.CmdTag(), "/del Obj = testtag3", "Removed tag 'testtag3' from Obj.")
|
||||
self.call(
|
||||
building.CmdTag(),
|
||||
"/del Obj",
|
||||
|
|
@ -1368,8 +1175,7 @@ class TestBuilding(CommandTest):
|
|||
|
||||
self.call(
|
||||
building.CmdSpawn(),
|
||||
"/save {'key':'Test Char', "
|
||||
"'typeclass':'evennia.objects.objects.DefaultCharacter'}",
|
||||
"/save {'key':'Test Char', " "'typeclass':'evennia.objects.objects.DefaultCharacter'}",
|
||||
"To save a prototype it must have the 'prototype_key' set.",
|
||||
)
|
||||
|
||||
|
|
@ -1479,9 +1285,7 @@ class TestBuilding(CommandTest):
|
|||
|
||||
# spawn/edit with invalid prototype
|
||||
msg = self.call(
|
||||
building.CmdSpawn(),
|
||||
"/edit NO_EXISTS",
|
||||
"No prototype 'NO_EXISTS' was found.",
|
||||
building.CmdSpawn(), "/edit NO_EXISTS", "No prototype 'NO_EXISTS' was found."
|
||||
)
|
||||
|
||||
# spawn/examine (missing prototype)
|
||||
|
|
@ -1496,11 +1300,7 @@ class TestBuilding(CommandTest):
|
|||
|
||||
# spawn/examine with invalid prototype
|
||||
# shows error
|
||||
self.call(
|
||||
building.CmdSpawn(),
|
||||
"/examine NO_EXISTS",
|
||||
"No prototype 'NO_EXISTS' was found.",
|
||||
)
|
||||
self.call(building.CmdSpawn(), "/examine NO_EXISTS", "No prototype 'NO_EXISTS' was found.")
|
||||
|
||||
|
||||
class TestComms(CommandTest):
|
||||
|
|
|
|||
|
|
@ -202,11 +202,11 @@ class CmdUnconnectedCreate(COMMAND_DEFAULT_CLASS):
|
|||
# tell the caller everything went well.
|
||||
string = "A new account '%s' was created. Welcome!"
|
||||
if " " in username:
|
||||
string += "\n\nYou can now log in with the command 'connect \"%s\" <your password>'."
|
||||
else:
|
||||
string += (
|
||||
"\n\nYou can now log with the command 'connect %s <your password>'."
|
||||
"\n\nYou can now log in with the command 'connect \"%s\" <your password>'."
|
||||
)
|
||||
else:
|
||||
string += "\n\nYou can now log with the command 'connect %s <your password>'."
|
||||
session.msg(string % (username, username))
|
||||
else:
|
||||
session.msg("|R%s|n" % "\n".join(errors))
|
||||
|
|
@ -258,13 +258,9 @@ class CmdUnconnectedLook(COMMAND_DEFAULT_CLASS):
|
|||
if "connection_screen" in callables:
|
||||
connection_screen = callables["connection_screen"]()
|
||||
else:
|
||||
connection_screen = utils.random_string_from_module(
|
||||
CONNECTION_SCREEN_MODULE
|
||||
)
|
||||
connection_screen = utils.random_string_from_module(CONNECTION_SCREEN_MODULE)
|
||||
if not connection_screen:
|
||||
connection_screen = (
|
||||
"No connection screen found. Please contact an admin."
|
||||
)
|
||||
connection_screen = "No connection screen found. Please contact an admin."
|
||||
self.caller.msg(connection_screen)
|
||||
|
||||
|
||||
|
|
@ -361,8 +357,7 @@ class CmdUnconnectedEncoding(COMMAND_DEFAULT_CLASS):
|
|||
string = ""
|
||||
if pencoding:
|
||||
string += (
|
||||
"Default encoding: |g%s|n (change with |wencoding <encoding>|n)"
|
||||
% pencoding
|
||||
"Default encoding: |g%s|n (change with |wencoding <encoding>|n)" % pencoding
|
||||
)
|
||||
encodings = settings.ENCODINGS
|
||||
if encodings:
|
||||
|
|
@ -385,9 +380,9 @@ class CmdUnconnectedEncoding(COMMAND_DEFAULT_CLASS):
|
|||
)
|
||||
else:
|
||||
self.session.protocol_flags["ENCODING"] = encoding
|
||||
string = (
|
||||
"Your custom text encoding was changed from '|w%s|n' to '|w%s|n'."
|
||||
% (old_encoding, encoding)
|
||||
string = "Your custom text encoding was changed from '|w%s|n' to '|w%s|n'." % (
|
||||
old_encoding,
|
||||
encoding,
|
||||
)
|
||||
sync = True
|
||||
if sync:
|
||||
|
|
@ -441,9 +436,7 @@ class CmdUnconnectedInfo(COMMAND_DEFAULT_CLASS):
|
|||
)
|
||||
|
||||
|
||||
def _create_account(
|
||||
session, accountname, password, permissions, typeclass=None, email=None
|
||||
):
|
||||
def _create_account(session, accountname, password, permissions, typeclass=None, email=None):
|
||||
"""
|
||||
Helper function, creates an account of the specified typeclass.
|
||||
"""
|
||||
|
|
@ -468,9 +461,7 @@ def _create_account(
|
|||
# join the new account to the public channel
|
||||
pchannel = ChannelDB.objects.get_channel(settings.DEFAULT_CHANNELS[0]["key"])
|
||||
if not pchannel or not pchannel.connect(new_account):
|
||||
string = (
|
||||
"New account '%s' could not connect to public channel!" % new_account.key
|
||||
)
|
||||
string = "New account '%s' could not connect to public channel!" % new_account.key
|
||||
logger.log_err(string)
|
||||
return new_account
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue