暫無描述

kotoyuuko 3e22d98bc9 docs: add README.md 1 月之前
.vscode d877f580cd Initial commit (by create-cloudflare CLI) 3 月之前
src 65066e5b35 feat: /history 默认过滤已完成和已取消状态,/history all 显示全部 1 月之前
test d877f580cd Initial commit (by create-cloudflare CLI) 3 月之前
.editorconfig 9f13a0688d init: MVP 3 月之前
.gitignore d877f580cd Initial commit (by create-cloudflare CLI) 3 月之前
.prettierrc d877f580cd Initial commit (by create-cloudflare CLI) 3 月之前
AGENTS.md f74a4b6534 feat: add AGENTS.md 1 月之前
CLAUDE.md c1049fc72f docs: add CLAUDE.md 1 月之前
README.md 3e22d98bc9 docs: add README.md 1 月之前
package-lock.json 65066e5b35 feat: /history 默认过滤已完成和已取消状态,/history all 显示全部 1 月之前
package.json 5911418229 feat: 交互式登录 3 月之前
tsconfig.json d877f580cd Initial commit (by create-cloudflare CLI) 3 月之前
vitest.config.mts d877f580cd Initial commit (by create-cloudflare CLI) 3 月之前
worker-configuration.d.ts d877f580cd Initial commit (by create-cloudflare CLI) 3 月之前
wrangler.jsonc 9f13a0688d init: MVP 3 月之前

README.md

CosMoe Bot

甜奈摄影会 Telegram 机器人,基于 grammy 框架,部署在 Cloudflare Workers 上。

功能

命令 说明
/start 显示欢迎信息和可用命令
/login 交互式登录 CosMoe 账户
/logout 登出并清除账户凭证
/events 查看最新活动列表
/event_{id} 查看活动详情和可预约时段
/book_{eventId}_{slotIndex} 预约活动时段
/history 查看进行中的预约记录
/history all 查看全部预约记录
/cancel_{bookingId} 取消预约

机器人每分钟自动检查新活动,并通过 Telegram 推送通知给已登录用户。

技术栈

  • 运行时: Cloudflare Workers
  • 框架: grammy (Telegram Bot)
  • 存储: Cloudflare KV(用户凭证、会话状态、调度数据)
  • 语言: TypeScript (ES2024)
  • 测试: Vitest + @cloudflare/vitest-pool-workers

开发

# 安装依赖
npm install

# 本地开发
npm run dev

# 部署
npm run deploy

# 运行测试
npm test

# 重新生成 Worker 类型
npm run cf-typegen

环境变量

.dev.vars 中配置本地开发所需的密钥:

BOT_TOKEN=your_telegram_bot_token

生产环境的密钥通过 Cloudflare Dashboard 设置。

项目结构

src/
├── index.ts              # Worker 入口(fetch + scheduled handler)
├── client/
│   └── cosmoe.ts         # CosMoe API 客户端
├── command/
│   ├── index.ts          # 命令路由和注册
│   └── handlers/         # 各命令处理器
│       ├── start.ts
│       ├── login.ts
│       ├── logout.ts
│       ├── events.ts
│       ├── eventDetails.ts
│       ├── bookEvent.ts
│       ├── cancel.ts
│       └── history.ts
└── scheduler/
    └── index.ts          # 定时任务:新活动通知

License

Private