mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
A MUX style wiz WHO command. Will get around to making the non-staff version once we've got enough work done to merit it.
This commit is contained in:
parent
8352c939ff
commit
6f3f150442
2 changed files with 85 additions and 4 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import settings
|
||||
import time
|
||||
import functions_general
|
||||
from ansi import *
|
||||
|
||||
"""
|
||||
|
|
@ -39,9 +41,25 @@ def do_who(cdat):
|
|||
session_list = cdat['server'].session_list
|
||||
session = cdat['session']
|
||||
|
||||
retval = "Player Name\n\r"
|
||||
retval = "Player Name On For Idle Room Cmds Host\n\r"
|
||||
for player in session_list:
|
||||
retval += '%s\n\r' % (player,)
|
||||
delta_cmd = time.time() - player.cmd_last
|
||||
delta_conn = time.time() - player.conn_time
|
||||
|
||||
retval += '%-16s%9s %4s%-3s#%-6d%5d%3s%-25s\r\n' % \
|
||||
(player.name, \
|
||||
# On-time
|
||||
functions_general.time_format(delta_conn,0), \
|
||||
# Idle time
|
||||
functions_general.time_format(delta_cmd,1), \
|
||||
# Flags
|
||||
'', \
|
||||
# Location
|
||||
player.pobject.location.id, \
|
||||
player.cmd_total, \
|
||||
# More flags?
|
||||
'', \
|
||||
player.address[0])
|
||||
retval += '%d Players logged in.' % (len(session_list),)
|
||||
|
||||
session.msg(retval)
|
||||
|
|
@ -52,10 +70,10 @@ def do_say(cdat):
|
|||
"""
|
||||
session_list = cdat['server'].session_list
|
||||
session = cdat['session']
|
||||
speech = cdat['uinput']['splitted'][1:]
|
||||
speech = ''.join(cdat['uinput']['splitted'][1:])
|
||||
players_present = [player for player in session_list if player.player_loc == session.player_loc and player != session]
|
||||
|
||||
retval = "You say, '%s'" % (''.join(speech),)
|
||||
retval = "You say, '%s'" % (speech,)
|
||||
for player in players_present:
|
||||
player.msg("%s says, '%s'" % (session.name, speech,))
|
||||
|
||||
|
|
|
|||
63
evennia/trunk/functions_general.py
Normal file
63
evennia/trunk/functions_general.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
"""
|
||||
General commonly used functions.
|
||||
"""
|
||||
|
||||
def time_format(seconds, style=0):
|
||||
"""
|
||||
Function to return a 'prettified' version of a value in seconds.
|
||||
|
||||
Style 0: 1d 08:30
|
||||
Style 1: 1d
|
||||
Style 2: 1 day, 8 hours, 30 minutes, 10 seconds
|
||||
"""
|
||||
if seconds < 0:
|
||||
seconds = 0
|
||||
else:
|
||||
# We'll just use integer math, no need for decimal precision.
|
||||
seconds = int(seconds)
|
||||
|
||||
days = seconds / 86400
|
||||
seconds -= days * 86400
|
||||
hours = seconds / 3600
|
||||
seconds -= hours * 3600
|
||||
minutes = seconds / 60
|
||||
seconds -= minutes * 60
|
||||
|
||||
if style is 0:
|
||||
"""
|
||||
Standard colon-style output.
|
||||
"""
|
||||
if days > 0:
|
||||
retval = '%id %02i:%02i' % (days, hours, minutes,)
|
||||
else:
|
||||
retval = '%02i:%02i' % (hours, minutes,)
|
||||
|
||||
return retval
|
||||
elif style is 1:
|
||||
"""
|
||||
Simple, abbreviated form that only shows the highest time amount.
|
||||
"""
|
||||
if days > 0:
|
||||
return '%id' % (days,)
|
||||
elif hours > 0:
|
||||
return '%ih' % (hours,)
|
||||
elif minutes > 0:
|
||||
return '%im' % (minutes,)
|
||||
else:
|
||||
return '%is' % (seconds,)
|
||||
|
||||
elif style is 2:
|
||||
"""
|
||||
Full-detailed, long-winded format.
|
||||
"""
|
||||
days_str = hours_str = minutes_str = ''
|
||||
if days > 0:
|
||||
days_str = '%i days, ' % (days,)
|
||||
if days or hours > 0:
|
||||
hours_str = '%i hours, ' % (hours,)
|
||||
if hours or minutes > 0:
|
||||
minutes_str = '%i minutes, ' % (minutes,)
|
||||
seconds_str = '%i seconds' % (seconds,)
|
||||
|
||||
retval = '%s%s%s%s' % (days_str, hours_str, minutes_str, seconds_str,)
|
||||
return retval
|
||||
Loading…
Add table
Add a link
Reference in a new issue