- Adding support for connection_time and idle_time methods to DefaultPlayer.
This commit is contained in:
parent
5d32d4f94e
commit
3d36cd343a
1 changed files with 18 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ instead for most things).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import time
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from evennia.typeclasses.models import TypeclassBase
|
from evennia.typeclasses.models import TypeclassBase
|
||||||
|
|
@ -744,6 +745,23 @@ class DefaultPlayer(PlayerDB):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def idle_time(self):
|
||||||
|
"""
|
||||||
|
Returns the idle time of the least idle session in seconds. If
|
||||||
|
no sessions are connected it returns nothing.
|
||||||
|
"""
|
||||||
|
idle = [session.cmd_last_visible for session in self.sessions]
|
||||||
|
if idle:
|
||||||
|
return time.time() - float(max(idle))
|
||||||
|
|
||||||
|
def connection_time(self):
|
||||||
|
"""
|
||||||
|
Returns the maximum connection time of all connected sessions
|
||||||
|
in seconds. Returns nothing if there are no sessions.
|
||||||
|
"""
|
||||||
|
conn = [session.conn_time for session in self.sessions]
|
||||||
|
if conn:
|
||||||
|
return time.time() - float(min(conn))
|
||||||
|
|
||||||
class DefaultGuest(DefaultPlayer):
|
class DefaultGuest(DefaultPlayer):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue