mirror of
https://github.com/evennia/evennia.git
synced 2026-04-07 00:45:22 +02:00
Added @sessions command for viewing active sessions connected to a given account.
This commit is contained in:
parent
25505d69a6
commit
458e3e7599
4 changed files with 53 additions and 5 deletions
|
|
@ -31,6 +31,7 @@ class DefaultCmdSet(CmdSet):
|
|||
self.add(general.CmdSay())
|
||||
self.add(general.CmdAccess())
|
||||
self.add(general.CmdColorTest())
|
||||
self.add(general.CmdSessions())
|
||||
|
||||
# The help system
|
||||
self.add(help.CmdHelp())
|
||||
|
|
|
|||
|
|
@ -530,6 +530,46 @@ class CmdSay(MuxCommand):
|
|||
speech)
|
||||
caller.location.msg_contents(emit_string,
|
||||
exclude=caller)
|
||||
class CmdSessions(MuxCommand):
|
||||
"""
|
||||
check connected session(s)
|
||||
|
||||
Usage:
|
||||
@sessions
|
||||
|
||||
Lists the sessions currently connected to your account.
|
||||
|
||||
"""
|
||||
key = "@sessions"
|
||||
locks = "cmd:all()"
|
||||
help_category = "General"
|
||||
|
||||
def func(self):
|
||||
"Implement function"
|
||||
|
||||
# make sure we work on the player, not on the character
|
||||
player = self.caller
|
||||
if hasattr(player, "player"):
|
||||
player = player.player
|
||||
|
||||
sessions = player.get_all_sessions()
|
||||
|
||||
table = [["sessid"], ["host"], ["character"], ["location"]]
|
||||
for sess in sorted(sessions, key=lambda x:x.sessid):
|
||||
sessid = sess.sessid
|
||||
char = player.get_character(sessid)
|
||||
table[0].append(str(sess.sessid))
|
||||
table[1].append(str(sess.address[0]))
|
||||
table[2].append(char and str(char) or "None")
|
||||
table[3].append(char and str(char.location) or "N/A")
|
||||
ftable = utils.format_table(table, 5)
|
||||
string = ""
|
||||
for ir, row in enumerate(ftable):
|
||||
if ir == 0:
|
||||
string += "\n" + "{w%s{n" % ("".join(row))
|
||||
else:
|
||||
string += "\n" + "".join(row)
|
||||
self.msg(string)
|
||||
|
||||
|
||||
class CmdPose(MuxCommand):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue