Skip to content

论坛 API

论坛 API 用于管理论坛子频道中的帖子(Thread)。

get_threads

获取子频道下的帖子列表。

源码位置: botpy/api.py 第 1306 行

API 路由: GET /channels/{channel_id}/threads

python
async def get_threads(channel_id: str) -> ForumRsp
参数类型默认值说明
channel_idstr必填论坛子频道的 ID

返回: ForumRsp

ForumRsp 字段:

字段类型说明
threadsList[Thread]帖子列表
is_finishint是否已获取完成

get_thread_detail

获取帖子详情。

源码位置: botpy/api.py 第 1323 行

API 路由: GET /channels/{channel_id}/threads/{thread_id}

python
async def get_thread_detail(channel_id: str, thread_id: str) -> ThreadInfo
参数类型默认值说明
channel_idstr必填论坛子频道的 ID
thread_idstr必填要查询的帖子 ID

返回: ThreadInfo

ThreadInfo 字段:

字段类型说明
thread_idstr帖子 ID
titlestr帖子标题
contentstr帖子内容
date_timestr发布时间

post_thread

发表帖子。

源码位置: botpy/api.py 第 1342 行

API 路由: PUT /channels/{channel_id}/threads

python
async def post_thread(
    channel_id: str,
    title: str,
    content: str,
    format: Format,
) -> PostThreadRsp
参数类型默认值说明
channel_idstr必填论坛子频道的 ID
titlestr必填帖子标题
contentstr必填帖子内容
formatFormat必填内容格式:1 普通文本,2 HTML,3 Markdown,4 JSON

返回: PostThreadRsp

PostThreadRsp 字段:

字段类型说明
task_idstr任务 ID
create_timestr创建时间

delete_thread

删除帖子。

源码位置: botpy/api.py 第 1364 行

API 路由: DELETE /channels/{channel_id}/threads/{thread_id}

python
async def delete_thread(channel_id: str, thread_id: str) -> str
参数类型默认值说明
channel_idstr必填论坛子频道的 ID
thread_idstr必填要删除的帖子 ID

返回: 成功返回空字符串。