diff --git a/apps/telegram-bot/commands.py b/apps/telegram-bot/commands.py index 43ac0a8..23e1dd5 100644 --- a/apps/telegram-bot/commands.py +++ b/apps/telegram-bot/commands.py @@ -156,12 +156,21 @@ def format_bounty(b, show_id: bool = True, slice_length: int = 0) -> str: if b.link: parts.append(f"🔗 {b.link}") if b.due_date_ts: - due_str = time.strftime("%d %b %Y", time.localtime(b.due_date_ts)) - days_left = (b.due_date_ts - int(time.time())) // 86400 - if days_left < 0: + now = int(time.time()) + seconds_left = b.due_date_ts - now + hours_left = seconds_left // 3600 + days_left = seconds_left // 86400 + + due_str = time.strftime("%d %b %Y %H:%M", time.localtime(b.due_date_ts)) + + if seconds_left < 0: parts.append(f"⏰ {due_str} (OVERDUE)") - elif days_left == 0: - parts.append(f"⏰ Today (OVERDUE)") + elif hours_left < 48: + if hours_left < 1: + minutes_left = seconds_left // 60 + parts.append(f"⏰ {due_str} ({minutes_left}m)") + else: + parts.append(f"⏰ {due_str} ({hours_left}h)") else: parts.append(f"⏰ {due_str} ({days_left}d)") return " | ".join(parts) @@ -416,18 +425,18 @@ async def cmd_update(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: changes.append(f"Link: {old_link} → {link}") if due_date_ts is not None: old_date = ( - time.strftime("%d %b %Y", time.localtime(old_bounty.due_date_ts)) + time.strftime("%d %b %Y %H:%M", time.localtime(old_bounty.due_date_ts)) if old_bounty.due_date_ts else "(none)" ) - new_date = time.strftime("%d %b %Y", time.localtime(due_date_ts)) + new_date = time.strftime("%d %b %Y %H:%M", time.localtime(due_date_ts)) changes.append(f"Date: {old_date} → {new_date}") if clear_link: old_link = old_bounty.link or "(none)" changes.append(f"Link: {old_link} → (cleared)") if clear_date: old_date = ( - time.strftime("%d %b %Y", time.localtime(old_bounty.due_date_ts)) + time.strftime("%d %b %Y %H:%M", time.localtime(old_bounty.due_date_ts)) if old_bounty.due_date_ts else "(none)" )