Compare commits
3 Commits
fix/add-sm
...
fix/18-har
| Author | SHA1 | Date | |
|---|---|---|---|
| 37cecdf95a | |||
| 395c9f7a66 | |||
|
|
d36660e9eb |
@@ -9,6 +9,7 @@ Includes:
|
||||
- CmdAcademy: Show overview of all 4 wings
|
||||
- CmdSmell: Use atmosphere data for scents
|
||||
- CmdListen: Use atmosphere data for sounds
|
||||
- CmdWho: Show who is currently online
|
||||
"""
|
||||
|
||||
from evennia.commands.command import Command as BaseCommand
|
||||
@@ -365,3 +366,71 @@ class CmdListen(BaseCommand):
|
||||
self.caller.msg(f"\n The mood here is: {atmo['mood']}")
|
||||
else:
|
||||
self.caller.msg("You listen carefully but hear nothing unusual.")
|
||||
|
||||
|
||||
class CmdWho(BaseCommand):
|
||||
"""
|
||||
Show who is currently online at the Academy.
|
||||
|
||||
Usage:
|
||||
@who
|
||||
who
|
||||
|
||||
Displays connected players, their locations, and session info.
|
||||
"""
|
||||
key = "@who"
|
||||
aliases = ["who"]
|
||||
locks = "cmd:all()"
|
||||
help_category = "Academy"
|
||||
|
||||
def func(self):
|
||||
from evennia.accounts.models import AccountDB
|
||||
import time
|
||||
|
||||
online = AccountDB.objects.filter(db_is_connected=True).order_by('db_key')
|
||||
count = online.count()
|
||||
|
||||
msg = []
|
||||
msg.append("|c" + "=" * 44 + "|n")
|
||||
msg.append(f"|c TIMMY ACADEMY - Who is Online ({count})|n")
|
||||
msg.append("|c" + "=" * 44 + "|n")
|
||||
|
||||
if count == 0:
|
||||
msg.append("\n The Academy halls are empty.")
|
||||
else:
|
||||
for account in online:
|
||||
# Get the character this account is puppeting
|
||||
char = None
|
||||
try:
|
||||
sessions = account.sessions.all()
|
||||
for sess in sessions:
|
||||
puppet = sess.puppet
|
||||
if puppet:
|
||||
char = puppet
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
name = account.db_key
|
||||
location = char.location.key if char and char.location else "(nowhere)"
|
||||
idle = ""
|
||||
try:
|
||||
last_cmd = account.db_last_cmd_timestamp
|
||||
if last_cmd:
|
||||
idle_secs = time.time() - last_cmd
|
||||
if idle_secs < 60:
|
||||
idle = "active"
|
||||
elif idle_secs < 300:
|
||||
idle = f"{int(idle_secs // 60)}m idle"
|
||||
else:
|
||||
idle = f"{int(idle_secs // 60)}m idle"
|
||||
except Exception:
|
||||
idle = "?"
|
||||
|
||||
msg.append(f"\n |w{name}|n")
|
||||
msg.append(f" at |c{location}|n")
|
||||
if idle:
|
||||
msg.append(f" [{idle}]")
|
||||
|
||||
msg.append("\n|c" + "=" * 44 + "|n")
|
||||
self.caller.msg("\n".join(msg))
|
||||
|
||||
@@ -18,7 +18,7 @@ from evennia import default_cmds
|
||||
from commands.command import (
|
||||
CmdExamine, CmdRooms,
|
||||
CmdStatus, CmdMap, CmdAcademy,
|
||||
CmdSmell, CmdListen,
|
||||
CmdSmell, CmdListen, CmdWho,
|
||||
)
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
||||
self.add(CmdAcademy)
|
||||
self.add(CmdSmell)
|
||||
self.add(CmdListen)
|
||||
self.add(CmdWho)
|
||||
|
||||
|
||||
class AccountCmdSet(default_cmds.AccountCmdSet):
|
||||
|
||||
@@ -9,7 +9,7 @@ and configures the Public channel.
|
||||
Safe to rerun (idempotent).
|
||||
|
||||
Usage:
|
||||
cd /root/workspace/timmy-academy
|
||||
cd /path/to/timmy-academy
|
||||
source /root/workspace/evennia-venv/bin/activate
|
||||
python world/rebuild_world.py
|
||||
"""
|
||||
@@ -19,7 +19,7 @@ import re
|
||||
import ast
|
||||
|
||||
os.environ["DJANGO_SETTINGS_MODULE"] = "server.conf.settings"
|
||||
sys.path.insert(0, "/root/workspace/timmy-academy")
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import django
|
||||
django.setup()
|
||||
|
||||
Reference in New Issue
Block a user