Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seen: modify/fix stored value & delta calculation for Aware trigger.time #2265

Merged
merged 2 commits into from
May 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions sopel/modules/seen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""
from __future__ import annotations

import datetime
import time

from sopel import plugin
Expand All @@ -31,17 +30,17 @@ def seen(bot, trigger):
bot.reply("I'm right here!")
return

timestamp = bot.db.get_nick_value(nick, 'seen_timestamp')
if not timestamp:
saw = bot.db.get_nick_value(nick, 'seen_timestamp')
if not saw:
bot.reply("Sorry, I haven't seen {nick} around.".format(nick=nick))
return

channel = bot.db.get_nick_value(nick, 'seen_channel')
message = bot.db.get_nick_value(nick, 'seen_message')
action = bot.db.get_nick_value(nick, 'seen_action')

saw = datetime.datetime.utcfromtimestamp(timestamp)
delta = seconds_to_human((trigger.time - saw).total_seconds())
# as of Sopel 8, trigger.time is an aware datetime
delta = seconds_to_human(trigger.time.timestamp() - saw)

msg = "I last saw " + nick
if bot.make_identifier(channel) == trigger.sender:
Expand Down