2016-03-29 11:56:58 +00:00
|
|
|
import time
|
2018-10-03 12:22:37 +00:00
|
|
|
from src import ModuleManager, utils
|
2016-03-29 11:56:58 +00:00
|
|
|
|
2018-09-26 17:27:17 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.message.channel")
|
2016-03-29 11:56:58 +00:00
|
|
|
def channel_message(self, event):
|
|
|
|
seen_seconds = time.time()
|
|
|
|
event["user"].set_setting("seen", seen_seconds)
|
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.hook("received.command.seen", min_args=1)
|
2016-03-29 11:56:58 +00:00
|
|
|
def seen(self, event):
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2018-09-30 16:29:09 +00:00
|
|
|
:help: Find out when a user was last seen
|
|
|
|
:usage: <nickname>
|
2018-09-26 17:27:17 +00:00
|
|
|
"""
|
2016-03-29 11:56:58 +00:00
|
|
|
seen_seconds = event["server"].get_user(event["args_split"][0]
|
|
|
|
).get_setting("seen")
|
|
|
|
if seen_seconds:
|
2018-10-03 12:22:37 +00:00
|
|
|
since = utils.to_pretty_time(time.time()-seen_seconds,
|
2018-08-29 14:52:04 +00:00
|
|
|
max_units=2)
|
|
|
|
event["stdout"].write("%s was last seen %s ago" % (
|
|
|
|
event["args_split"][0], since))
|
2016-03-29 11:56:58 +00:00
|
|
|
else:
|
|
|
|
event["stderr"].write("I have never seen %s before." % (
|
|
|
|
event["args_split"][0]))
|