fix: support Harness interactions across IM channels

This commit is contained in:
xmanrui 2026-08-18 14:13:10 +08:00
parent 3e7e1dcdd7
commit cd8175d341
30 changed files with 5433 additions and 555 deletions

View file

@ -238,6 +238,7 @@ export class DiscordRuntime {
status: this.#status,
logger: this.#logger,
replyTimeoutMs: this.#replyTimeoutMs,
signal: controller.signal,
});
let timer;
try {
@ -346,7 +347,16 @@ export class DiscordRuntime {
markReady();
} else if (packet.t === 'MESSAGE_CREATE') {
const message = normalizeDiscordMessage(packet.d, this.#config.platformId);
if (message) void this.#bridge?.accept(message);
const bridge = this.#bridge;
if (message && bridge) {
void bridge.accept(message).catch((error) => {
if (generation !== this.#generation || this.#stopped) return;
this.#logger.error?.(
`[dsh-im:discord] bot ${this.#config.botId} message handling failed:`,
error,
);
});
}
}
});
addSocketListener(socket, 'close', (event = {}) => {

View file

@ -1,3 +1,11 @@
import { HarnessClient } from '../weixin/harness-client.mjs';
import { HarnessClient } from '../shared/harness-client.mjs';
export class DiscordHarnessClient extends HarnessClient {}
export class DiscordHarnessClient extends HarnessClient {
constructor(options) {
super({
...options,
rpcIdPrefix: 'discord',
logPrefix: 'dsh-discord',
});
}
}