show first-words datestamp on !words output
This commit is contained in:
parent
35cdc5321f
commit
2cb55306c3
2 changed files with 12 additions and 2 deletions
|
@ -75,8 +75,15 @@ class Module(ModuleManager.BaseModule):
|
|||
total = 0
|
||||
for channel in words:
|
||||
total += words[channel]
|
||||
event["stdout"].write("%s has used %d words (%d in %s)" % (
|
||||
target.nickname, total, this_channel, event["target"].name))
|
||||
|
||||
since = ""
|
||||
first_words = target.get_setting("first-words", None)
|
||||
if not first_words == None:
|
||||
since = " since %s" % utils.date_human(
|
||||
utils.datetime_timestamp(first_words))
|
||||
|
||||
event["stdout"].write("%s has used %d words (%d in %s)%s" % (
|
||||
target.nickname, total, this_channel, event["target"].name, since))
|
||||
|
||||
@utils.hook("received.command.trackword", min_args=1)
|
||||
def track_word(self, event):
|
||||
|
|
|
@ -18,6 +18,9 @@ DATE_HUMAN = "%Y-%m-%d"
|
|||
|
||||
def datetime_utcnow() -> datetime.datetime:
|
||||
return datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
|
||||
def datetime_timestamp(seconds: float) -> datetime.datetime:
|
||||
return datetime.datetime.fromtimestamp(seconds).replace(
|
||||
tzinfo=datetime.timezone.utc)
|
||||
|
||||
def iso8601_format(dt: datetime.datetime, milliseconds: bool=False) -> str:
|
||||
dt_format = dt.strftime(ISO8601_FORMAT_DT)
|
||||
|
|
Loading…
Reference in a new issue