Merge pull request #1698 from TehomCD/add_force_command
Add a simple 'force' command to force objects to execute commands.
This commit is contained in:
commit
18cf0ca6c9
3 changed files with 35 additions and 1 deletions
|
|
@ -17,7 +17,7 @@ PERMISSION_HIERARCHY = [p.lower() for p in settings.PERMISSION_HIERARCHY]
|
||||||
|
|
||||||
# limit members for API inclusion
|
# limit members for API inclusion
|
||||||
__all__ = ("CmdBoot", "CmdBan", "CmdUnban",
|
__all__ = ("CmdBoot", "CmdBan", "CmdUnban",
|
||||||
"CmdEmit", "CmdNewPassword", "CmdPerm", "CmdWall")
|
"CmdEmit", "CmdNewPassword", "CmdPerm", "CmdWall", "CmdForce")
|
||||||
|
|
||||||
|
|
||||||
class CmdBoot(COMMAND_DEFAULT_CLASS):
|
class CmdBoot(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
@ -513,3 +513,33 @@ class CmdWall(COMMAND_DEFAULT_CLASS):
|
||||||
message = "%s shouts \"%s\"" % (self.caller.name, self.args)
|
message = "%s shouts \"%s\"" % (self.caller.name, self.args)
|
||||||
self.msg("Announcing to all connected sessions ...")
|
self.msg("Announcing to all connected sessions ...")
|
||||||
SESSIONS.announce_all(message)
|
SESSIONS.announce_all(message)
|
||||||
|
|
||||||
|
|
||||||
|
class CmdForce(COMMAND_DEFAULT_CLASS):
|
||||||
|
"""
|
||||||
|
forces an object to execute a command
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
@force <object>=<command string>
|
||||||
|
|
||||||
|
Example:
|
||||||
|
@force bob=get stick
|
||||||
|
"""
|
||||||
|
key = "@force"
|
||||||
|
locks = "cmd:perm(spawn) or perm(Builder)"
|
||||||
|
help_category = "Building"
|
||||||
|
perm_used = "edit"
|
||||||
|
|
||||||
|
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.")
|
||||||
|
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.")
|
||||||
|
return
|
||||||
|
targ.execute_cmd(self.rhs)
|
||||||
|
self.caller.msg("You have forced %s to: %s" % (targ, self.rhs))
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ class CharacterCmdSet(CmdSet):
|
||||||
self.add(admin.CmdEmit())
|
self.add(admin.CmdEmit())
|
||||||
self.add(admin.CmdPerm())
|
self.add(admin.CmdPerm())
|
||||||
self.add(admin.CmdWall())
|
self.add(admin.CmdWall())
|
||||||
|
self.add(admin.CmdForce())
|
||||||
|
|
||||||
# Building and world manipulation
|
# Building and world manipulation
|
||||||
self.add(building.CmdTeleport())
|
self.add(building.CmdTeleport())
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,9 @@ class TestAdmin(CommandTest):
|
||||||
def test_ban(self):
|
def test_ban(self):
|
||||||
self.call(admin.CmdBan(), "Char", "Name-Ban char was added.")
|
self.call(admin.CmdBan(), "Char", "Name-Ban char was added.")
|
||||||
|
|
||||||
|
def test_force(self):
|
||||||
|
self.call(admin.CmdForce(), "Char2=say test", 'Char2(#7) says, "test"|You have forced Char2 to: say test')
|
||||||
|
|
||||||
|
|
||||||
class TestAccount(CommandTest):
|
class TestAccount(CommandTest):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue