@dcrays/dcgchat-test 0.3.9 → 0.3.11
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/bot.ts +1 -1
- package/src/channel.ts +20 -6
- package/src/skill.ts +2 -0
package/package.json
CHANGED
package/src/bot.ts
CHANGED
package/src/channel.ts
CHANGED
|
@@ -158,9 +158,23 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
158
158
|
// }
|
|
159
159
|
const outboundCtx = getEffectiveMsgParams(ctx.to)
|
|
160
160
|
const messageId = getCronMessageId(ctx.to)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
if (outboundCtx?.sessionId) {
|
|
162
|
+
const newCtx = messageId ? { ...outboundCtx, messageId } : outboundCtx
|
|
163
|
+
wsSendRaw(newCtx, { response: ctx.text, is_finish: -1, message_tags: { source: 'channel' } })
|
|
164
|
+
dcgLogger(`channel sendText to ${ctx.to} ${ctx.text?.slice(0, 50)}`)
|
|
165
|
+
} else {
|
|
166
|
+
const sessionInfo = ctx.to.split(':')[1]
|
|
167
|
+
const sessionId = sessionInfo.split('-')[0]
|
|
168
|
+
const agentId = sessionInfo.split('-')[1]
|
|
169
|
+
const merged = mergeDefaultParams({
|
|
170
|
+
agentId: agentId,
|
|
171
|
+
sessionId: `${sessionId}`,
|
|
172
|
+
messageId: messageId,
|
|
173
|
+
is_finish: -1
|
|
174
|
+
})
|
|
175
|
+
dcgLogger(`channel sendText to ${ctx.to} ${ctx.text?.slice(0, 50)}`)
|
|
176
|
+
wsSendRaw(merged, { response: ctx.text })
|
|
177
|
+
}
|
|
164
178
|
}
|
|
165
179
|
return {
|
|
166
180
|
channel: "dcgchat-test",
|
|
@@ -169,9 +183,9 @@ export const dcgchatPlugin: ChannelPlugin<ResolvedDcgchatAccount> = {
|
|
|
169
183
|
}
|
|
170
184
|
},
|
|
171
185
|
sendMedia: async (ctx) => {
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
await sendDcgchatMedia({ sessionKey:
|
|
186
|
+
const msgCtx = getEffectiveMsgParams(ctx.to)
|
|
187
|
+
dcgLogger(`channel sendMedia to ${ctx.to} ${ctx.mediaUrl?.slice(0, 50)}`)
|
|
188
|
+
await sendDcgchatMedia({ sessionKey: ctx.to ?? '', mediaUrl: ctx.mediaUrl ?? '' })
|
|
175
189
|
return {
|
|
176
190
|
channel: "dcgchat-test",
|
|
177
191
|
messageId: `dcg-${Date.now()}`,
|
package/src/skill.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { getWorkspaceDir } from './utils/global.js'
|
|
|
8
8
|
import { getWsConnection } from './utils/global.js'
|
|
9
9
|
import { dcgLogger } from './utils/log.js'
|
|
10
10
|
import { isWsOpen } from './transport.js'
|
|
11
|
+
import { sendMessageToGateway } from './gateway/socket.js'
|
|
11
12
|
|
|
12
13
|
type ISkillParams = {
|
|
13
14
|
path: string
|
|
@@ -127,6 +128,7 @@ export async function installSkill(params: ISkillParams, msgContent: Record<stri
|
|
|
127
128
|
})
|
|
128
129
|
})
|
|
129
130
|
sendEvent({ ...msgContent, status: 'ok' })
|
|
131
|
+
sendMessageToGateway(JSON.stringify({ method: 'skills.status', params: {} }))
|
|
130
132
|
} catch (error) {
|
|
131
133
|
// 如果安装失败,清理目录
|
|
132
134
|
if (fs.existsSync(skillDir)) {
|