From f981dd27be1d24a288bc8d333893eb7eaaa0f02b Mon Sep 17 00:00:00 2001 From: Alexander Nicolay Date: Mon, 6 Jul 2026 07:38:13 +0200 Subject: [PATCH] Time-aware sign-off after logging --- src/matebot/conversation.py | 15 ++++++++++++++- tests/test_conversation.py | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/matebot/conversation.py b/src/matebot/conversation.py index 4ececfd..6a26835 100644 --- a/src/matebot/conversation.py +++ b/src/matebot/conversation.py @@ -51,6 +51,17 @@ def _fmt_duration(ms: int) -> str: return f"{ms / 1000:.0f}s" +def _signoff(hour: int) -> str: + """A closing line that knows what time it is (no 'sweet dreams' at 7 am).""" + if 5 <= hour < 11: + return "Enjoy the kickstart." + if 11 <= hour < 17: + return "Back to it." + if 17 <= hour < 22: + return "Enjoy the evening — bold choice, by the way." + return "Sweet dreams tonight. Eventually." + + @dataclass class PendingShot: shot_id: int @@ -232,9 +243,11 @@ async def _finish(self, superseded_by: int | None = None) -> None: stars = "★" * int(answers.get("rating", 0)) suffix = f" (superseded by #{superseded_by})" if superseded_by else "" ratio = f" · 1:{answers['ratio']}" if answers.get("ratio") else "" + from datetime import datetime + await self.messenger.send( f"✅ Shot #{pending.shot_id} logged{suffix}. {stars}{ratio}\n" - "Filed straight into your GaggiMate shot notes. Sweet dreams tonight." + f"Filed straight into your GaggiMate shot notes. {_signoff(datetime.now().hour)}" ) else: await self.messenger.send( diff --git a/tests/test_conversation.py b/tests/test_conversation.py index 260b095..767c502 100644 --- a/tests/test_conversation.py +++ b/tests/test_conversation.py @@ -158,3 +158,13 @@ async def test_save_failure_reported(tmp_path): for step in ("bt", "bean", "grind", "din", "dout", "txt"): await answer(c, f"g|65|{step}|skip") assert "⚠️" in fm.sent[-1][0] + + +def test_signoff_matches_time_of_day(): + from matebot.conversation import _signoff + + assert "kickstart" in _signoff(7) # 7 am is not bedtime + assert "Back to it" in _signoff(13) + assert "evening" in _signoff(19) + assert "dreams" in _signoff(23) + assert "dreams" in _signoff(2)