52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
from telegram import Update
|
|
from telegram.ext import ContextTypes
|
|
|
|
from bot.models.database import Session
|
|
from bot.models.user import User
|
|
from bot.utils.keyboards import main_keyboard
|
|
|
|
WELCOME_TEXT = (
|
|
"👋 *欢迎使用提醒机器人!*\n\n"
|
|
"我可以帮你管理各类提醒,支持:\n"
|
|
"• 一次性提醒\n"
|
|
"• 每日定时提醒\n"
|
|
"• 每周指定日期提醒\n"
|
|
"• 按间隔重复提醒(支持时间窗口)\n"
|
|
"• 自动跳过中国节假日\n\n"
|
|
"使用下方按钮或发送 /new 开始创建第一个提醒吧!"
|
|
)
|
|
|
|
HELP_TEXT = (
|
|
"*命令列表*\n\n"
|
|
"/start — 显示欢迎信息\n"
|
|
"/new — 新建提醒\n"
|
|
"/list — 查看我的提醒\n"
|
|
"/help — 显示帮助\n\n"
|
|
"*提醒类型说明*\n\n"
|
|
"• *一次性*:在指定日期时间提醒一次\n"
|
|
"• *每日*:每天在固定时间提醒\n"
|
|
"• *每周*:每周指定星期几在固定时间提醒\n"
|
|
"• *间隔*:在指定时间段内每隔 N 分钟提醒一次\n\n"
|
|
"收到提醒后可点击按钮:\n"
|
|
"✅ 完成 | ⏰ 延期10分钟 | ⏸ 暂停 | 🗑 删除"
|
|
)
|
|
|
|
|
|
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
user = update.effective_user
|
|
session = Session()
|
|
try:
|
|
User.get_or_create(session, user.id, user.username)
|
|
finally:
|
|
Session.remove()
|
|
|
|
await update.message.reply_text(
|
|
WELCOME_TEXT,
|
|
parse_mode="Markdown",
|
|
reply_markup=main_keyboard(),
|
|
)
|
|
|
|
|
|
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
await update.message.reply_text(HELP_TEXT, parse_mode="Markdown")
|