File size: 1,459 Bytes
1e7a182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# ControllerBot-like Posts API

## Create a post with buttons
POST /api/v1/groups/{group_id}/posts

```json
{
  "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

```json
{
  "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

```json
{
  "cron_expr": "0 9 * * *",
  "enabled": true
}
```

删除定时:

DELETE /api/v1/groups/{group_id}/posts/{post_id}/schedule

## 发送执行

运行 worker 处理 post_send:

```powershell
$env:BOT_TOKEN="<your_bot_token>"
$env:DATABASE_URL="postgresql+psycopg://afool:afool@localhost:5432/afool"
venv\Scripts\python.exe scripts\worker.py
```

定时发送需要额外运行调度器:

```powershell
$env:DATABASE_URL="postgresql+psycopg://afool:afool@localhost:5432/afool"
venv\Scripts\python.exe scripts\post_scheduler.py
```