24 lines
893 B
Python
24 lines
893 B
Python
import time
|
|
from src import ModuleManager, Utils
|
|
|
|
class Module(ModuleManager.BaseModule):
|
|
@Utils.hook("received.message.channel")
|
|
def channel_message(self, event):
|
|
seen_seconds = time.time()
|
|
event["user"].set_setting("seen", seen_seconds)
|
|
|
|
@Utils.hook("received.command.seen", min_args=1, usage="<username>")
|
|
def seen(self, event):
|
|
"""
|
|
Find out when a user was last seen
|
|
"""
|
|
seen_seconds = event["server"].get_user(event["args_split"][0]
|
|
).get_setting("seen")
|
|
if seen_seconds:
|
|
since = Utils.to_pretty_time(time.time()-seen_seconds,
|
|
max_units=2)
|
|
event["stdout"].write("%s was last seen %s ago" % (
|
|
event["args_split"][0], since))
|
|
else:
|
|
event["stderr"].write("I have never seen %s before." % (
|
|
event["args_split"][0]))
|