@puke3615/node-red-contrib-wechat
Version:
一个支持微信的Node-Red插件
23 lines (20 loc) • 633 B
JavaScript
module.exports = function (RED) {
function invoke(config) {
RED.nodes.createNode(this, config);
const {userName} = config;
const wechat = RED.nodes.getNode(config.wechat);
const node = this;
wechat.addListener(function (msg) {
const {sender, room} = msg;
if (room) {
// 该节点仅私信, 群消息直接过滤掉
return;
}
if (userName && sender !== userName) {
return;
}
node.send(msg);
});
}
RED.nodes.registerType("receive-user-msg", invoke);
};