mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-17 07:30:44 +08:00
feat: send test messages during bot connection checks
This commit is contained in:
parent
94da24538f
commit
fb61c4235f
78 changed files with 3460 additions and 210 deletions
|
|
@ -421,6 +421,22 @@ export class WhatsappRuntime {
|
|||
return this.stop();
|
||||
}
|
||||
|
||||
async sendConnectionTest(text) {
|
||||
if (!this.#status.ready || !this.#client) {
|
||||
const error = new Error('WhatsApp机器人尚未连接');
|
||||
error.code = 'test-target-unavailable';
|
||||
throw error;
|
||||
}
|
||||
if (typeof text !== 'string' || !text.trim()) {
|
||||
throw new TypeError('WhatsApp connection test text is required');
|
||||
}
|
||||
await this.#client.sendText({
|
||||
jid: this.#config.accountJid,
|
||||
selfChat: true,
|
||||
}, text);
|
||||
return { sent: true };
|
||||
}
|
||||
|
||||
async stop() {
|
||||
const session = this.#session;
|
||||
const client = this.#client;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue