parent
4f5dbbb6e0
commit
35cc2d539d
1 changed files with 9 additions and 5 deletions
|
@ -7,7 +7,7 @@ from src import ModuleManager, utils
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
def _change_seen(self, channel, user, action):
|
def _change_seen(self, channel, user, action):
|
||||||
user.set_setting("seen", time.time())
|
user.set_setting("seen", time.time())
|
||||||
user.set_setting("seen-info", {"action": action})
|
channel.set_user_setting(user.get_id(), "seen-info", {"action": action})
|
||||||
|
|
||||||
@utils.hook("formatted.message.channel")
|
@utils.hook("formatted.message.channel")
|
||||||
@utils.hook("formatted.notice.channel")
|
@utils.hook("formatted.notice.channel")
|
||||||
|
@ -30,14 +30,18 @@ class Module(ModuleManager.BaseModule):
|
||||||
seen_seconds = user.get_setting("seen")
|
seen_seconds = user.get_setting("seen")
|
||||||
|
|
||||||
if seen_seconds:
|
if seen_seconds:
|
||||||
seen_info = user.get_setting("seen-info", None)
|
seen_info = None
|
||||||
seen_info = "" if seen_info == None else (
|
if event["is_channel"]:
|
||||||
" (%s%s)" % (seen_info["action"], utils.consts.RESET))
|
seen_info = event["target"].get_user_setting(
|
||||||
|
event["user"].get_id(), "seen-info", None)
|
||||||
|
if seen_info:
|
||||||
|
seen_info = " (%s%s)" % (seen_info["action"],
|
||||||
|
utils.consts.RESET)
|
||||||
|
|
||||||
since = utils.to_pretty_time(time.time()-seen_seconds,
|
since = utils.to_pretty_time(time.time()-seen_seconds,
|
||||||
max_units=2)
|
max_units=2)
|
||||||
event["stdout"].write("%s was last seen %s ago%s" % (
|
event["stdout"].write("%s was last seen %s ago%s" % (
|
||||||
event["args_split"][0], since, seen_info))
|
event["args_split"][0], since, seen_info or ""))
|
||||||
else:
|
else:
|
||||||
event["stderr"].write("I have never seen %s before." % (
|
event["stderr"].write("I have never seen %s before." % (
|
||||||
event["args_split"][0]))
|
event["args_split"][0]))
|
||||||
|
|
Loading…
Reference in a new issue