- 只翻注释/文档字符串:剥掉注释后代码行逐字节不变(机械校验只剩允许的行尾注释形态) - 术语对齐既有译法(owner→主人、persona→角色、engage→参与度判定、quiet hours→安静时段、backoff→退避) - 复核:go build 绿 + channelbridge 包测试绿;gofmt 干净
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package channelbridge
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"git.yeij.top/AskaEth/Cyrene_v2/internal/channel/adapter"
|
|
)
|
|
|
|
// 本文件承载出站回复路径(design/16 §4.6 §5):循环产生的文本
|
|
// 通过接收该消息的同一账号适配器
|
|
// 送回来源会话。
|
|
|
|
// sendReply 把循环产生的文本送回渠道的来源会话,
|
|
// 经由接收该消息的账号适配器(多账号安全,
|
|
// design/16 §4.6 §5)。它照搬入站消息的渠道路由字段,
|
|
// 使适配器解析出消息来自的同一对端,并经
|
|
// 共享的 IM 气泡派发器出口(剥离角色扮演/旁白 + 按 <p> 切分 + 0.5-2s 间隔)。
|
|
func (b *Bridge) sendReply(ctx context.Context, in adapter.UnifiedMessage, a adapter.PlatformAdapter, text string) error {
|
|
if a == nil {
|
|
a = b.adapter(in.Platform)
|
|
}
|
|
if a == nil {
|
|
return fmt.Errorf("channelbridge: no adapter for platform %q", in.Platform)
|
|
}
|
|
return b.sendIMBubbles(ctx, in, func(ctx context.Context, msg adapter.UnifiedMessage) error {
|
|
return a.SendMessage(ctx, adapter.UnifiedResponse{Messages: []adapter.UnifiedMessage{msg}})
|
|
}, text)
|
|
}
|