diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index 7240a5aa44..640717050f 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -5,6 +5,7 @@ These are the (default) starting points for all in-game visible entities. """ +import time from builtins import object from future.utils import listvalues, with_metaclass @@ -1463,6 +1464,26 @@ class DefaultCharacter(DefaultObject): self.db.prelogout_location = self.location self.location = None + @property + 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.all()] + if idle: + return time.time() - float(max(idle)) + + @property + 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.all()] + if conn: + return time.time() - float(min(conn)) + # # Base Room object #