docs(comments): 注释中文化 · internal/services/channelbridge(纯替换)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- 只翻注释/文档字符串:剥掉注释后代码行逐字节不变(机械校验只剩允许的行尾注释形态)
- 术语对齐既有译法(owner→主人、persona→角色、engage→参与度判定、quiet hours→安静时段、backoff→退避)
- 复核:go build 绿 + channelbridge 包测试绿;gofmt 干净
This commit is contained in:
AskaEth committed 2026-10-04 13:33:06 +08:00
1 parent 61cf80d5ee
commit 093f38d986
28 files changed
+1089 -1089

No files matched your search

+20 -20
View File
@@ -8,29 +8,29 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/internal/channel/adapter"
)
// bubbleSender is the per-bubble outbound call the shared IM dispatcher uses. A
// reply exits through the adapter's SendMessage (UnifiedResponse) path, a proactive
// push through its SendProactive path — both collapse to "dispatch one chat bubble to
// the platform", which is what lets the reply and the proactive push share a single
// sanitize/split/gap pipeline instead of each re-implementing it.
// bubbleSender 是共享 IM 派发器所用的单气泡出站调用。
// 回复经适配器的 SendMessage (UnifiedResponse) 路径出口,主动推送
// 经其 SendProactive 路径出口——两者都归结为「向平台派发一个聊天气泡」,
// 这正是回复与主动推送能共用同一套
// 清洗/切分/间隔流水线、而无需各自重写的原因。
type bubbleSender func(ctx context.Context, msg adapter.UnifiedMessage) error
// sendIMBubbles is the single IM outbound exit shared by sendReply (reply path) and
// SendProactive (proactive push). It turns content into the plain chat bubbles an IM
// channel should receive: role-play/action/narration markup (rendered as muted italic
// on the Web) is stripped and each <p> paragraph is delivered as its own
// bubble/message (design/17 §2), with a multi-bubble burst spacing its sends 0.5-2s
// apart so it does not flood the channel. The Web frontend is never affected — it
// renders the persisted stream directly and does not route through here.
// sendIMBubbles 是 sendReply(回复路径)与 SendProactive(主动推送)
// 共用的唯一 IM 出站出口。它把内容变成 IM 渠道应收到的纯聊天气泡:
// 角色扮演/动作/旁白标记(在 Web 上渲染为暗色斜体)会被剥离,
// 每个 <p> 段落作为独立
// 气泡/消息投递(design/17 §2),多气泡连发时相邻发送间隔 0.5-2s,
// 以免刷屏。Web 前端完全不受影响——
// 它直接渲染已持久化的流,不经过这里。
//
// target carries the platform/channel targeting fields and is copied onto every
// bubble (only Content/ContentType/Timestamp differ per bubble); sender is the
// adapter's outbound call. A content that strips to nothing (a pure action line) is
// dropped without a send, and a per-bubble failure is wrapped with its index.
// target 携带平台/渠道路由字段,并被复制到每个
// 气泡上(每个气泡只有 Content/ContentType/Timestamp 不同);sender 是
// 适配器的出站调用。被剥成空的内容(纯动作行)
// 直接丢弃不发送;单个气泡失败时会带上其下标包装返回。
func (b *Bridge) sendIMBubbles(ctx context.Context, target adapter.UnifiedMessage, sender bubbleSender, content string) error {
// splitBubbles applies stripNarration per bubble (so <action>/<narration> and the
// star-drift role-play forms are removed for IM) and splits on <p>. It is the
// single sanitize entry point, shared with the old reply path.
// splitBubbles 对每个气泡应用 stripNarration(因此 <action>/<narration> 与
// 星号漂移的角色扮演形式都会为 IM 剥离),并按 <p> 切分。它是
// 唯一的清洗入口,与旧的回复路径共用。
bubbles := splitBubbles(content)
if len(bubbles) == 0 {
b.log.Debug("im outbound has no plain text, skipped", "platform", target.Platform, "channel", target.ChannelID)
@@ -44,7 +44,7 @@ func (b *Bridge) sendIMBubbles(ctx context.Context, target adapter.UnifiedMessag
out.Content = bubble
out.ContentType = adapter.ContentText
out.Timestamp = time.Now().UTC()
// Each bubble is its own send so the gap lands between messages.
// 每个气泡各自发送一次,间隔才会落在消息之间。
if err := sender(ctx, out); err != nil {
return fmt.Errorf("channelbridge: send bubble #%d of %d: %w", i+1, len(bubbles), err)
}