我有节点红色的对象消息,如下所示:
{ chatId: 111111111, messageId: 1111, type: "message", content: "VENT Auto", date: "2017-12-28T19:46:45.000Z",inbound: true }
我想解析这条消息并写下如下函数:
if (chatId==111111111){return msg;}
我试过这些: json parse-1
这是节点红色中的函数:
msg=msg.payload.chatId
return msg
我想在输出中看到chatid:
if (msg.payload.chatid== 11111111){return msg)
和msg是这个功能的输出:
[{"id":"b068944.8218168","type":"chatbot-telegram-receive","z":"52d0aba5.3f0a3c","bot":"","x":170,"y":600,"wires":[["f479d424.fe9e3"]]},{"id":"f479d424.fe9e3","type":"function","z":"52d0aba5.3f0a3c","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":620,"wires":[["c8f111dc.9ac8d"]]},{"id":"ba82cead.cdf808","type":"change","z":"52d0aba5.3f0a3c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.content","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":620,"wires":[["5f96e508.3d69cc"]]},{"id":"c8f111dc.9ac8d","type":"function","z":"52d0aba5.3f0a3c","name":"","func":"msg=msg.payload.chatId\nreturn msg\n","outputs":1,"noerr":0,"x":330,"y":700,"wires":[["ba82cead.cdf808"]]}]
我向电报机器人发送消息,我想将chatid与我的聊天ID进行比较。