guanghulab/dingtalk-bot/test-stream.js
2026-05-10 13:12:44 +08:00

16 lines
473 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

require('dotenv').config();
const { DWClient, TOPIC_ROBOT, EventAck } = require('dingtalk-stream');
const client = new DWClient({
clientId: process.env.DINGTALK_APP_KEY,
clientSecret: process.env.DINGTALK_APP_SECRET,
});
client.registerCallbackListener(TOPIC_ROBOT, async (res) => {
console.log('[DEBUG] 触发res =', JSON.stringify(res, null, 2));
return EventAck.SUCCESS;
});
client.connect();
console.log('Stream 监听中,请 @机器人 发消息...');