ReminderBot/bot/utils/keyboards.py
leo 6901b0dd7b fix: fix interval reminder delete bug and simplify notification buttons
Remove pause/delete buttons from reminder notification popup (manage
via "我的提醒" list instead). Reorder delete operation to remove
scheduler job before DB record, preventing orphaned list entries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:14:15 +08:00

82 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardMarkup
def main_keyboard() -> ReplyKeyboardMarkup:
return ReplyKeyboardMarkup(
[
[" 新建提醒", "📋 我的提醒"],
["❓ 帮助"],
],
resize_keyboard=True,
)
def reminder_type_keyboard() -> ReplyKeyboardMarkup:
return ReplyKeyboardMarkup(
[
["一次性", "每日"],
["每周", "间隔"],
["取消"],
],
resize_keyboard=True,
one_time_keyboard=True,
)
def yes_no_keyboard() -> ReplyKeyboardMarkup:
return ReplyKeyboardMarkup(
[["", ""], ["取消"]],
resize_keyboard=True,
one_time_keyboard=True,
)
def confirm_keyboard() -> ReplyKeyboardMarkup:
return ReplyKeyboardMarkup(
[["✅ 确认创建", "❌ 取消"]],
resize_keyboard=True,
one_time_keyboard=True,
)
def reminder_action_keyboard(reminder_id: int) -> InlineKeyboardMarkup:
return InlineKeyboardMarkup(
[
[
InlineKeyboardButton("✅ 完成", callback_data=f"done_{reminder_id}"),
InlineKeyboardButton(
"⏰ 延期", callback_data=f"snooze_{reminder_id}"
),
],
]
)
def snooze_action_keyboard(reminder_id: int) -> InlineKeyboardMarkup:
return InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"❌ 关闭延期提醒", callback_data=f"cancel_snooze_{reminder_id}"
)
]
]
)
def list_item_keyboard(reminder_id: int, is_active: bool) -> InlineKeyboardMarkup:
toggle_label = "⏸ 暂停" if is_active else "▶️ 启用"
toggle_action = "pause" if is_active else "resume"
return InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
toggle_label, callback_data=f"{toggle_action}_{reminder_id}"
),
InlineKeyboardButton(
"🗑 删除", callback_data=f"delete_{reminder_id}"
),
]
]
)