- Add snooze.py handler: prompts user for snooze minutes and schedules a one-shot job with a cancel button (cancel_snooze_<id>) - Refactor callback.py: support compound action prefix parsing for cancel_snooze_*, switch snooze action to prompt-based flow - Add snooze_action_keyboard() in keyboards.py; update snooze button label - Register handle_snooze_input in group=1 to avoid ConversationHandler conflict - Filter completed once-type reminders from get_user_reminders() - Fix DateTrigger: compare and localize once_time in UTC consistently Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
86 lines
2.4 KiB
Python
86 lines
2.4 KiB
Python
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}"
|
||
),
|
||
],
|
||
[
|
||
InlineKeyboardButton("⏸ 暂停", callback_data=f"pause_{reminder_id}"),
|
||
InlineKeyboardButton("🗑 删除", callback_data=f"delete_{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}"
|
||
),
|
||
]
|
||
]
|
||
)
|