dockerized_openAger/nodered/rootfs/data/node_modules/node-red-contrib-telegrambot/examples/livelocation.json
2020-10-17 18:42:50 +02:00

1 line
5.2 KiB
JSON

[{"id":"e1914945.0ecfd8","type":"catch","z":"725879df.541168","name":"","x":160,"y":580,"wires":[["dc7bc908.f6e5f8"]]},{"id":"dc7bc908.f6e5f8","type":"debug","z":"725879df.541168","name":"Debug","active":true,"console":"false","complete":"payload","x":370,"y":580,"wires":[]},{"id":"da4cf949.cb9118","type":"telegram sender","z":"725879df.541168","name":"send location","bot":"ecbcf512.4e9a28","x":690,"y":120,"wires":[["c95ae907.49e268"]]},{"id":"449dc685.098248","type":"telegram command","z":"725879df.541168","name":"/send to send location","command":"/send","bot":"ecbcf512.4e9a28","strict":true,"x":160,"y":120,"wires":[["9d2ef78b.a10f28"],[]]},{"id":"9d2ef78b.a10f28","type":"function","z":"725879df.541168","name":"send initial location","func":"// see https://core.telegram.org/bots/api#sendlocation\n\nvar lat = flow.get(\"lat\");\nvar lng = flow.get(\"lng\");\nvar time = flow.get(\"time\");\n\n\nmsg.payload.type = 'location';\nmsg.payload.content = {\n latitude : lat,\n longitude : lng\n};\n \nmsg.payload.options = {\n live_period : time\n}; \n\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":120,"wires":[["da4cf949.cb9118"]]},{"id":"74bc17cd.97b958","type":"telegram receiver","z":"725879df.541168","name":"message receiver","bot":"ecbcf512.4e9a28","saveDataDir":"","x":170,"y":380,"wires":[["b8b7f3c0.f220a"],[]]},{"id":"b8b7f3c0.f220a","type":"function","z":"725879df.541168","name":"reply location message","func":"if(msg.payload.type == 'location')\n{\n var lat = msg.payload.content.latitude;\n var lng = msg.payload.content.longitude;\n \n msg.payload.type = 'message';\n msg.payload.content = 'lat=' + lat + ' lon=' + lng;\n \n return msg;\n}\nelse\n{\n return null;\n}\n","outputs":1,"noerr":0,"x":420,"y":380,"wires":[["dc174ebf.53e2c"]]},{"id":"cab3ca7f.6f2778","type":"telegram command","z":"725879df.541168","name":"/update to update live location","command":"/update","bot":"ecbcf512.4e9a28","strict":true,"x":140,"y":200,"wires":[["796bfd7b.89ef04"],[]]},{"id":"796bfd7b.89ef04","type":"function","z":"725879df.541168","name":"edit initial location","func":"// see https://core.telegram.org/bots/api#editMessageLiveLocation\n\nvar messageId = flow.get(\"messageId\");\n\nvar lat = flow.get(\"lat\");\nvar lng = flow.get(\"lng\");\nlat += 0.1;\nlng += 0.1;\nflow.set(\"lat\", lat);\nflow.set(\"lng\", lng);\n\n\nvar chatId = msg.payload.chatId;\nmsg.payload.type = 'editMessageLiveLocation';\nmsg.payload.content = {\n latitude : lat,\n longitude : lng\n};\n \nmsg.payload.options = {\n chat_id : chatId,\n message_id : messageId\n}; \n\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":200,"wires":[["dc174ebf.53e2c"]]},{"id":"de720b3.43142f8","type":"telegram command","z":"725879df.541168","name":"/abort to stop live location","command":"/abort","bot":"ecbcf512.4e9a28","strict":true,"x":150,"y":280,"wires":[["ef341f1c.6ab44"],[]]},{"id":"ef341f1c.6ab44","type":"function","z":"725879df.541168","name":"stop live updating","func":"// see https://core.telegram.org/bots/api#stopMessageLiveLocation\n\nvar messageId = flow.get(\"messageId\");\nvar chatId = msg.payload.chatId;\n\nmsg.payload.type = 'stopMessageLiveLocation';\nmsg.payload.options = {\n chat_id : chatId,\n message_id : messageId\n}; \n\n\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":280,"wires":[["dc174ebf.53e2c"]]},{"id":"36afbf82.a7e8a","type":"inject","z":"725879df.541168","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"0.1","x":110,"y":60,"wires":[["4cd6fcae.338154"]]},{"id":"4cd6fcae.338154","type":"function","z":"725879df.541168","name":"intialize location","func":"// Here we initialize some sample data \n// for later usage\n\nflow.set(\"lat\", 47);\nflow.set(\"lng\", 10);\n\n// the live_period in seconds\nflow.set(\"time\", 600);\n\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":60,"wires":[[]]},{"id":"dc174ebf.53e2c","type":"telegram sender","z":"725879df.541168","name":"send response","bot":"ecbcf512.4e9a28","x":700,"y":300,"wires":[[]]},{"id":"c95ae907.49e268","type":"function","z":"725879df.541168","name":"store messageId","func":"// Here we store the message id of the live location message, \n// as we need to update exactly this one later\n\nvar messageId = msg.payload.sentMessageId;\nflow.set(\"messageId\", messageId);\nreturn msg;","outputs":1,"noerr":0,"x":900,"y":120,"wires":[[]]},{"id":"ecf89a6f.b65cf8","type":"telegram event","z":"725879df.541168","name":"live location receiver","bot":"ecbcf512.4e9a28","event":"edited_message","autoanswer":"","x":170,"y":480,"wires":[["7c39a13.7fa4c6"]]},{"id":"7c39a13.7fa4c6","type":"function","z":"725879df.541168","name":"filter live location","func":"if(msg.payload.location)\n{\n var lat = msg.payload.location.latitude;\n var lng = msg.payload.location.longitude;\n var user = msg.payload.from.username;\n \n msg.payload.type = 'message';\n msg.payload.content = user + ' moved to lat=' + lat + ' lon=' + lng;\n \n return msg;\n}\nelse\n{\n return null;\n}\n","outputs":1,"noerr":0,"x":400,"y":480,"wires":[["dc174ebf.53e2c"]]},{"id":"ecbcf512.4e9a28","type":"telegram bot","z":"725879df.541168","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","pollinterval":""}]