Spaces:
Sleeping
Sleeping
ControllerBot-like Posts API
Create a post with buttons
POST /api/v1/groups/{group_id}/posts
{
"title": "活动通知",
"content_type": "text",
"content": "今晚 8 点活动开始,点击按钮报名",
"buttons": [
[{"text": "报名", "url": "https://example.com/signup"}],
[{"text": "群规", "url": "https://example.com/rules"}]
],
"target_chat_id": -1001234567890,
"pin": true
}
Publish (send to channel/group)
POST /api/v1/groups/{group_id}/posts/{post_id}/publish
{
"target_chat_id": -1001234567890,
"pin": true
}
Notes:
- buttons 是二维数组,表示按钮行
- content_type 可用: text/photo/video
- 若为 photo/video,需提供 media_id
- publish 会将状态置为 queued 并发队列 post_send
定时发送(每日重复)示例
为帖子设置每日 9:00 发送:
POST /api/v1/groups/{group_id}/posts/{post_id}/schedule
{
"cron_expr": "0 9 * * *",
"enabled": true
}
删除定时:
DELETE /api/v1/groups/{group_id}/posts/{post_id}/schedule
发送执行
运行 worker 处理 post_send:
$env:BOT_TOKEN="<your_bot_token>"
$env:DATABASE_URL="postgresql+psycopg://afool:afool@localhost:5432/afool"
venv\Scripts\python.exe scripts\worker.py
定时发送需要额外运行调度器:
$env:DATABASE_URL="postgresql+psycopg://afool:afool@localhost:5432/afool"
venv\Scripts\python.exe scripts\post_scheduler.py