跳到正文
nonebot-pluginparser-lite

正文内容类型

post.content 中各类内容项的结构与渲染建议

post.content 包含帖子的全部正文元素,模板需要按 type 分别渲染:

type说明
text文本
image / cover图片与封面
live_photo实况照片
graphic带说明的独立图片
sticker贴纸 / 表情
video / audio音视频
link / quote链接卡片与引用
poll投票
unknown未知类型兜底

text

{ "type": "text", "text": "第一行正文\n第二行正文" }

文本可能包含换行符,建议:

.text {
  white-space: pre-wrap;
  word-break: break-word;
}

image / cover

{
  "type": "image",
  "src": "file:///path/to/img.png",
  "layout": "grid",
  "width": 800,
  "height": 400,
  "orientation": "landscape",
  "source_url": "https://..."
}

cover 结构相同,额外带 alt。音乐平台的第一张图片或封面卡片会被标记为 cover。

字段类型说明
srcstring本地文件 URI
layoutstring布局建议:"grid"(网格)或 "x"(横向推特流)
width / heightnumber像素尺寸
orientationstring"portrait"(高 / 宽 ≥ 0.9)或 "landscape"
source_urlstring原始网络地址,不建议模板直接请求

live_photo

与 image 字段相同,额外带 is_live: true。可据此在图片上叠加「实况 / Live」角标。

graphic

{
  "type": "graphic",
  "src": "file:///path/to/img.png",
  "width": 800,
  "height": 400,
  "orientation": "landscape",
  "alt": "...",
  "source_url": "https://..."
}

graphic 是带说明的独立图片,不要混入普通多图网格展示。

sticker

{ "type": "sticker", "src": "...", "size": "small", "description": "笑哭", "source_url": "..." }
字段类型说明
srcstring | null贴纸图片 URI
sizestringsmall 或 medium
descriptionstring贴纸描述

src 为 null 时应回退显示描述文字,如 [笑哭]。

video / audio

{ "type": "video", "src": "封面URI", "duration": "01:23", "speedup": "1.25x", "size": "12.34MB", "source_url": "..." }
{ "type": "audio", "duration": "03:45", "speedup": null, "size": "7.63MB", "source_url": "..." }
字段类型说明
srcstring | null视频封面 URI;音频为 null
durationstring时长,如 "01:23"
speedupstring | null倍速标签,1 倍速时为 null,见 媒体倍速
sizestring文件大小,如 "12.34MB"
{
  "type": "link",
  "url": "string",
  "title": "string",
  "site_name": "string | null",
  "description": "string | null",
  "icon": "uri | null",
  "preview": "uri | null"
}
{ "type": "quote", "text": "引用内容", "title": "string | null", "url": "string | null", "icon": "uri | null" }

poll

{
  "type": "poll",
  "title": "string | null",
  "options": [{ "text": "选项 A", "votes": 10, "percentage": 62.5, "image": "uri | null" }],
  "option_vote_total": 123,
  "total_votes": 123,
  "total_voters": 123,
  "multiple": false,
  "closed": false,
  "close_at": "2026-...",
  "has_images": false
}
字段类型说明
titlestring | null投票标题
optionsarray选项,percentage 已算好百分比
option_vote_totalnumber选项票数之和
total_votesnumber | null平台返回的总票数(多选时可能大于投票人数)
total_votersnumber | null投票人数
multipleboolean是否多选
closedboolean是否已结束
close_atstring | null结束时间(平台原始格式)
has_imagesboolean是否有选项图片
<div class="poll-bar" style="width: {{ '%.2f'|format(option.percentage) }}%"></div>

unknown

为了向前兼容,无法识别的新类型统一为 type="unknown"。模板最后应留一个兜底分支:

{% if item.type == 'text' %}
  <p>{{ item.text }}</p>
{% elif item.type == 'image' %}
  <img src="{{ item.src }}" />
{% else %}
  <p class="unknown-type">{{ item.text }}</p>
{% endif %}
在 GitHub 上编辑此页

本页目录