@dcrays/dcgchat 0.4.25 → 0.4.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/channel.ts +4 -17
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
2
|
import type { ChannelPlugin, OpenClawConfig, PluginRuntime } from 'openclaw/plugin-sdk'
|
|
4
3
|
import { createPluginRuntimeStore, DEFAULT_ACCOUNT_ID } from 'openclaw/plugin-sdk'
|
|
5
4
|
import type { ResolvedDcgchatAccount, DcgchatConfig } from './types.js'
|
|
@@ -10,7 +9,6 @@ import {
|
|
|
10
9
|
getDcgchatRuntime,
|
|
11
10
|
getInfoBySessionKey,
|
|
12
11
|
getOpenClawConfig,
|
|
13
|
-
getWorkspaceDir,
|
|
14
12
|
hasSentMediaKey,
|
|
15
13
|
setCronMessageId
|
|
16
14
|
} from './utils/global.js'
|
|
@@ -107,19 +105,8 @@ function outboundChatId(rawTo: string | undefined, normalizedTo: string): string
|
|
|
107
105
|
}
|
|
108
106
|
|
|
109
107
|
/**
|
|
110
|
-
*
|
|
111
|
-
* - 本地绝对路径字符串
|
|
112
|
-
* - 工作区虚拟路径(如 `/mobook/xxx`,需落到 `getWorkspaceDir()`)
|
|
113
|
-
* - `mediaUrls` 为 `{ file: string }[]` 或整段 JSON 字符串
|
|
108
|
+
* 仅从 JSON / `{ file | path | url }` 等结构里取出路径字符串,不做改写(不拼 workspace、不 normalize)。
|
|
114
109
|
*/
|
|
115
|
-
function resolveWorkspaceMediaPath(p: string): string {
|
|
116
|
-
const s = p.trim()
|
|
117
|
-
if (!s) return ''
|
|
118
|
-
if (fs.existsSync(s)) return path.normalize(s)
|
|
119
|
-
const rel = s.replace(/^[\\/]+/, '')
|
|
120
|
-
return path.normalize(path.join(getWorkspaceDir(), rel))
|
|
121
|
-
}
|
|
122
|
-
|
|
123
110
|
function collectOutboundMediaPaths(item: unknown, out: string[]): void {
|
|
124
111
|
if (item == null) return
|
|
125
112
|
if (typeof item === 'string') {
|
|
@@ -134,7 +121,7 @@ function collectOutboundMediaPaths(item: unknown, out: string[]): void {
|
|
|
134
121
|
/* 非 JSON,按普通路径处理 */
|
|
135
122
|
}
|
|
136
123
|
}
|
|
137
|
-
out.push(
|
|
124
|
+
out.push(t)
|
|
138
125
|
return
|
|
139
126
|
}
|
|
140
127
|
if (Array.isArray(item)) {
|
|
@@ -145,12 +132,12 @@ function collectOutboundMediaPaths(item: unknown, out: string[]): void {
|
|
|
145
132
|
const o = item as Record<string, unknown>
|
|
146
133
|
const raw = o.file ?? o.path ?? o.url
|
|
147
134
|
if (typeof raw === 'string' && raw.trim()) {
|
|
148
|
-
out.push(
|
|
135
|
+
out.push(raw.trim())
|
|
149
136
|
}
|
|
150
137
|
}
|
|
151
138
|
}
|
|
152
139
|
|
|
153
|
-
/** 将出站 media
|
|
140
|
+
/** 将出站 media 展平为路径字符串列表(去重保序;路径保持 Core 原样) */
|
|
154
141
|
export function normalizeOutboundMediaPaths(raw: unknown): string[] {
|
|
155
142
|
const acc: string[] = []
|
|
156
143
|
collectOutboundMediaPaths(raw, acc)
|