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

+17 -17
View File
@@ -6,12 +6,12 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/internal/channel/adapter"
)
// This file holds the small package-level helpers shared across the bridge files:
// platform/account naming, the sender label, and generic slice readers.
// 本文件承载桥接器各文件共用的小型包级辅助函数:
// 平台/账号命名、发送者标签,以及通用切片读取。
// basePlatform returns the bare platform name of a (possibly multi-account)
// adapter name like "telegram:conf0" → "telegram", so the credential gate and the
// reply-routing fallback treat every account of a platform identically.
// basePlatform 返回(可能多账号的)适配器名称的裸平台名,
// 如 "telegram:conf0" → "telegram",使凭据闸门与
// 回复路由回退把同一平台的每个账号一视同仁。
func basePlatform(name string) string {
if base, _, ok := strings.Cut(name, ":"); ok {
return base
@@ -19,11 +19,11 @@ func basePlatform(name string) string {
return name
}
// adapterName returns the account-adapter registration name (e.g. "kook:3bef...")
// for the adapter that received a message, or "" when a is nil. The single-account
// convenience path (process) and a platform with no registered adapter can pass a nil
// adapter, so the persist hooks tolerate it and store an empty adapter_id rather than
// dereferencing a nil adapter.
// adapterName 返回接收消息的账号适配器注册名(如 "kook:3bef..."),
// a 为 nil 时返回 ""。单账号
// 便捷路径(process)以及没有已注册适配器的平台都可能传入 nil
// 适配器,因此持久化钩子容忍它,存空 adapter_id,而不是
// 解引用 nil 适配器。
func adapterName(a adapter.PlatformAdapter) string {
if a == nil {
return ""
@@ -31,11 +31,11 @@ func adapterName(a adapter.PlatformAdapter) string {
return a.Name()
}
// senderDisplayName returns the human-readable sender name used to label a
// third-party message. It prefers the resolved actor's display name (which the
// channel layer derived from channel metadata + the raw SenderName), falling back
// to the message's own SenderName, so an empty SenderName always means "the
// owner/unlabeled" rather than a nickname that resolved to nothing.
// senderDisplayName 返回用于标注第三方消息的
// 人类可读发送者名。它优先取已解析 actor 的显示名(由
// 渠道层依据渠道元数据 + 原始 SenderName 推导),回退到
// 消息自身的 SenderName,因此空的 SenderName 始终表示
// 「主人/未标注」,而不是解析不出结果的昵称。
func senderDisplayName(msg adapter.UnifiedMessage, actor adapter.Actor) string {
if actor.DisplayName != "" {
return actor.DisplayName
@@ -43,7 +43,7 @@ func senderDisplayName(msg adapter.UnifiedMessage, actor adapter.Actor) string {
return msg.SenderName
}
// sliceContains reports whether s is present in list.
// sliceContains 报告 s 是否存在于 list 中。
func sliceContains(list []string, s string) bool {
for _, v := range list {
if v == s {
@@ -53,7 +53,7 @@ func sliceContains(list []string, s string) bool {
return false
}
// firstNonEmptyStr returns a when non-empty, otherwise b.
// firstNonEmptyStr 在 a 非空时返回 a,否则返回 b。
func firstNonEmptyStr(a, b string) string {
if a != "" {
return a