Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 14 additions & 1 deletion src/matebot/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions tests/test_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading