Skip to content

Commit

Permalink
fixed #384
Browse files Browse the repository at this point in the history
  • Loading branch information
windka committed Jul 5, 2024
1 parent 3b01a8b commit bb892ad
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/editinlinekeyboard.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"id":"20636f59.fed13","type":"telegram event","z":"ed43e0f7.31d9","name":"","bot":"fcc25e57.4073a","event":"callback_query","autoanswer":true,"x":120,"y":160,"wires":[["f0a3c788.7bbb18"]]},{"id":"d0ae190d.071828","type":"telegram sender","z":"ed43e0f7.31d9","name":"show inline keyboard","bot":"fcc25e57.4073a","haserroroutput":false,"outputs":1,"x":562.7594223022461,"y":53.30331039428711,"wires":[["23220303.4a427c"]]},{"id":"3426758a.a2d09a","type":"function","z":"ed43e0f7.31d9","name":"initial inline keyboard message","func":"context.global.keyboard = { messageId : msg.payload.messageId };\n\nvar opts = {\n reply_to_message_id: msg.payload.messageId,\n reply_markup: JSON.stringify({\n \"inline_keyboard\": [[\n {\n \"text\": \"Yes\",\n \"callback_data\": \"FOO YES\" \n }, \n {\n \"text\": \"No\",\n \"callback_data\": \"FOO NO\" \n }]\n ]\n })\n};\n\nmsg.payload.content = 'Do you want to hide the inline keyboard?';\nmsg.payload.options = opts;\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"x":301.7592468261719,"y":54.3032283782959,"wires":[["d0ae190d.071828"]]},{"id":"d7bfbd4.da4e34","type":"telegram command","z":"ed43e0f7.31d9","name":"/foo","command":"/foo","bot":"fcc25e57.4073a","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":82.75931549072266,"y":60.30321025848389,"wires":[["3426758a.a2d09a"]]},{"id":"43cecef5.e2e93","type":"function","z":"ed43e0f7.31d9","name":"YES REALLY","func":"// Hide the keyboard and forget the messageId\nmsg.payload.type = 'deleteMessage';\nmsg.payload.content = context.global.keyboard.messageId\ncontext.global.keyboard.messageId = null;\n\n// You could also send a editMessageReplyMarkup with an empty reply_markup here\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":160,"wires":[["8e746981.f48368"]]},{"id":"8e746981.f48368","type":"telegram sender","z":"ed43e0f7.31d9","name":"","bot":"fcc25e57.4073a","haserroroutput":false,"outputs":1,"x":790,"y":160,"wires":[["2e9b911.c6c726e"]]},{"id":"2c6089c4.883006","type":"function","z":"ed43e0f7.31d9","name":"YES","func":"// This is the message id of the initial keyboard that is simply exchanged by a new one.\nvar messageId = context.global.keyboard.messageId;\n\n// This is a sample of how to send a second inline keyboard with modified buttons\nvar reply_markup = JSON.stringify({\n \"inline_keyboard\": [[\n {\n \"text\": \"Are you really sure?\",\n \"callback_data\": \"FOO YES REALLY\" \n }, \n {\n \"text\": \"No\",\n \"callback_data\": \"FOO NO\" \n }]\n ]\n });\n\n\nvar options = {\n chat_id : msg.payload.chatId,\n reply_markup : reply_markup,\n message_id : messageId\n};\n\nmsg.payload.type = 'editMessageReplyMarkup';\nmsg.payload.content = reply_markup;\nmsg.payload.options = options;\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":530,"y":120,"wires":[["8e746981.f48368"]]},{"id":"23220303.4a427c","type":"function","z":"ed43e0f7.31d9","name":"save messageId","func":"// We store the messageId to be able to edit this reply in the callback query. \ncontext.global.keyboard.messageId = msg.payload.sentMessageId;\nreturn [ msg ];\n","outputs":"1","noerr":0,"x":780.6667861938477,"y":53.66671276092529,"wires":[[]]},{"id":"2e9b911.c6c726e","type":"debug","z":"ed43e0f7.31d9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":160,"wires":[]},{"id":"f0a3c788.7bbb18","type":"switch","z":"ed43e0f7.31d9","name":"check callback data","property":"payload.content","propertyType":"msg","rules":[{"t":"eq","v":"FOO YES","vt":"str"},{"t":"eq","v":"FOO YES REALLY","vt":"str"},{"t":"eq","v":"FOO NO","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":330,"y":160,"wires":[["2c6089c4.883006"],["43cecef5.e2e93"],["8e23029e.001b7"]]},{"id":"8e23029e.001b7","type":"function","z":"ed43e0f7.31d9","name":"NO","func":"var show_alert = true; // you can set this to true to open a dialog with the answer in the client.\n\n// msg.payload.content contains the callback data from the keyboard.\n// You may change this value here.\nmsg.payload.options = show_alert;\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":200,"wires":[["8e746981.f48368"]]},{"id":"fcc25e57.4073a","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]
[{"id":"20636f59.fed13","type":"telegram event","z":"a4fc2021eddfd308","name":"","bot":"65ca12172854cc2d","event":"callback_query","autoanswer":true,"x":120,"y":440,"wires":[["f0a3c788.7bbb18"]]},{"id":"d0ae190d.071828","type":"telegram sender","z":"a4fc2021eddfd308","name":"show inline keyboard","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":562.7594223022461,"y":333.3033103942871,"wires":[["23220303.4a427c"]]},{"id":"3426758a.a2d09a","type":"function","z":"a4fc2021eddfd308","name":"initial inline keyboard message","func":"context.global.keyboard = { messageId : msg.payload.messageId };\n\nvar opts = {\n reply_to_message_id: msg.payload.messageId,\n reply_markup: JSON.stringify({\n \"inline_keyboard\": [[\n {\n \"text\": \"Yes\",\n \"callback_data\": \"FOO YES\" \n }, \n {\n \"text\": \"No\",\n \"callback_data\": \"FOO NO\" \n }]\n ]\n })\n};\n\nmsg.payload.content = 'Do you want to hide the inline keyboard?';\nmsg.payload.options = opts;\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"x":301.7592468261719,"y":334.3032283782959,"wires":[["d0ae190d.071828"]]},{"id":"d7bfbd4.da4e34","type":"telegram command","z":"a4fc2021eddfd308","name":"/foo","command":"/foo","description":"","registercommand":false,"language":"","bot":"65ca12172854cc2d","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":82.75931549072266,"y":340.3032102584839,"wires":[["3426758a.a2d09a"]]},{"id":"43cecef5.e2e93","type":"function","z":"a4fc2021eddfd308","name":"YES REALLY","func":"// Hide the keyboard and forget the messageId\nmsg.payload.type = 'deleteMessage';\nmsg.payload.content = context.global.keyboard.messageId;\ncontext.global.keyboard.messageId = null;\n\n// You could also send a editMessageReplyMarkup with an empty reply_markup here\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":440,"wires":[["8e746981.f48368"]]},{"id":"8e746981.f48368","type":"telegram sender","z":"a4fc2021eddfd308","name":"","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":790,"y":440,"wires":[["2e9b911.c6c726e"]]},{"id":"2c6089c4.883006","type":"function","z":"a4fc2021eddfd308","name":"YES","func":"// This is the message id of the initial keyboard that is simply exchanged by a new one.\nvar messageId = context.global.keyboard.messageId;\n\n// This is a sample of how to send a second inline keyboard with modified buttons\nvar reply_markup = JSON.stringify({\n \"inline_keyboard\": [[\n {\n \"text\": \"Are you really sure?\",\n \"callback_data\": \"FOO YES REALLY\" \n }, \n {\n \"text\": \"No\",\n \"callback_data\": \"FOO NO\" \n }]\n ]\n });\n\n\nvar options = {\n chat_id : msg.payload.chatId,\n reply_markup : reply_markup,\n message_id : messageId\n};\n\nmsg.payload.type = 'editMessageReplyMarkup';\nmsg.payload.content = reply_markup;\nmsg.payload.options = options;\n\nreturn [ msg ];\n","outputs":"1","timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":400,"wires":[["8e746981.f48368"]]},{"id":"23220303.4a427c","type":"function","z":"a4fc2021eddfd308","name":"save messageId","func":"// We store the messageId to be able to edit this reply in the callback query. \ncontext.global.keyboard.messageId = msg.payload.sentMessageId;\nreturn [ msg ];\n","outputs":"1","noerr":0,"x":780.6667861938477,"y":333.6667127609253,"wires":[[]]},{"id":"2e9b911.c6c726e","type":"debug","z":"a4fc2021eddfd308","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":440,"wires":[]},{"id":"f0a3c788.7bbb18","type":"switch","z":"a4fc2021eddfd308","name":"check callback data","property":"payload.content","propertyType":"msg","rules":[{"t":"eq","v":"FOO YES","vt":"str"},{"t":"eq","v":"FOO YES REALLY","vt":"str"},{"t":"eq","v":"FOO NO","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":330,"y":440,"wires":[["2c6089c4.883006"],["43cecef5.e2e93"],["8e23029e.001b7"]]},{"id":"8e23029e.001b7","type":"function","z":"a4fc2021eddfd308","name":"NO","func":"msg.payload.type = 'answerCallbackQuery';\nmsg.payload.options = {\n text : msg.payload.content,\n show_alert : true, // you can set this to true to open a dialog with the answer in the client.\n};\n\nreturn msg;\n\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":480,"wires":[["8e746981.f48368"]]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","testenvironment":false,"updatemode":"polling","pollinterval":"1000","usesocks":false,"sockshost":"","socksprotocol":"socks5","socksport":"1080","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":true,"verboselogging":true}]
2 changes: 1 addition & 1 deletion examples/replytomessage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"id":"bcd88438.e77e68","type":"telegram receiver","z":"c513a2fb.133e3","name":"","bot":"19f02f8b.fa0c5","saveDataDir":"","x":150,"y":80,"wires":[["d518a4a2.1bded8"],[]]},{"id":"ba1931f2.6acf9","type":"telegram sender","z":"c513a2fb.133e3","name":"","bot":"19f02f8b.fa0c5","x":630,"y":80,"wires":[[]]},{"id":"d518a4a2.1bded8","type":"function","z":"c513a2fb.133e3","name":"reply to message","func":"var opts = {\n reply_to_message_id: msg.payload.messageId\n};\n\nmsg.payload.content = 'I received your message';\nmsg.payload.options = opts;\n\nreturn msg;\n","outputs":"1","noerr":0,"x":370,"y":60,"wires":[["ba1931f2.6acf9"]]},{"id":"19f02f8b.fa0c5","type":"telegram bot","z":"c513a2fb.133e3","botname":"HeinzBot","usernames":"Windhose","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"188.40.170.80","socksport":"1080","socksusername":"anonymous","sockspassword":"none","bothost":"ihive.spdns.de","localbotport":"","publicbotport":"","privatekey":"C:\\\\Temp\\\\SSL\\\\PRIVATE.key","certificate":"C:\\\\Temp\\\\SSL\\\\PUBLIC.pem","useselfsignedcertificate":true,"verboselogging":true}]
[{"id":"bcd88438.e77e68","type":"telegram receiver","z":"c513a2fb.133e3","name":"","bot":"19f02f8b.fa0c5","saveDataDir":"","x":150,"y":80,"wires":[["d518a4a2.1bded8"],[]]},{"id":"ba1931f2.6acf9","type":"telegram sender","z":"c513a2fb.133e3","name":"","bot":"19f02f8b.fa0c5","x":630,"y":80,"wires":[[]]},{"id":"d518a4a2.1bded8","type":"function","z":"c513a2fb.133e3","name":"reply to message","func":"var opts = {\n reply_to_message_id: msg.payload.messageId\n};\n\nmsg.payload.content = 'I received your message';\nmsg.payload.options = opts;\n\nreturn msg;\n","outputs":"1","noerr":0,"x":370,"y":60,"wires":[["ba1931f2.6acf9"]]},{"id":"19f02f8b.fa0c5","type":"telegram bot","z":"c513a2fb.133e3","botname":"HeinzBot","usernames":"Windhose","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"188.40.170.80","socksport":"1080","socksusername":"anonymous","sockspassword":"none","bothost":"","localbotport":"","publicbotport":"","privatekey":"C:\\\\Temp\\\\SSL\\\\PRIVATE.key","certificate":"C:\\\\Temp\\\\SSL\\\\PUBLIC.pem","useselfsignedcertificate":true,"verboselogging":true}]
2 changes: 1 addition & 1 deletion examples/triggerCommandFromControlNode.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"id":"8c682765.b34cf8","type":"telegram command","z":"2aad377dfdc4367e","name":"/foo","command":"/foo","description":"","registercommand":false,"language":"","bot":"65ca12172854cc2d","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":550,"y":160,"wires":[["22ce65840450e170"]]},{"id":"6e9683e1a39526da","type":"telegram command","z":"2aad377dfdc4367e","name":"/bar","command":"/bar","description":"","registercommand":false,"language":"","bot":"65ca12172854cc2d","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":550,"y":240,"wires":[["471e47ea5a959c01"]]},{"id":"22ce65840450e170","type":"debug","z":"2aad377dfdc4367e","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":160,"wires":[]},{"id":"471e47ea5a959c01","type":"debug","z":"2aad377dfdc4367e","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":240,"wires":[]},{"id":"df5bccfb0eaa9772","type":"telegram control","z":"2aad377dfdc4367e","name":"","bot":"65ca12172854cc2d","outputs":1,"checkconnection":false,"hostname":"","interval":10,"timeout":1,"x":560,"y":320,"wires":[["6aa222d848819333"]]},{"id":"6aa222d848819333","type":"debug","z":"2aad377dfdc4367e","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":320,"wires":[]},{"id":"319bb010c9ef672d","type":"inject","z":"2aad377dfdc4367e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":320,"wires":[["44b3db9131df60e0"]]},{"id":"44b3db9131df60e0","type":"function","z":"2aad377dfdc4367e","name":"/foo","func":"// see https://core.telegram.org/bots/api#message\n\nlet newMsg = {\n payload : {\n command: \"command\",\n message: {\n text: \"/foo\",\n \n // these are optional\n // from : { id : 0, username : 'somebody' },\n // chat : { id : 0 }\n }\n }\n};\n\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":320,"wires":[["df5bccfb0eaa9772"]]},{"id":"70307757bc6de41d","type":"inject","z":"2aad377dfdc4367e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":360,"wires":[["89ccaa8f0e3594be"]]},{"id":"89ccaa8f0e3594be","type":"function","z":"2aad377dfdc4367e","name":"/bar","func":"// see https://core.telegram.org/bots/api#message\n\nlet newMsg = {\n payload : {\n command: \"command\",\n message: {\n text: \"/bar\",\n \n // these are optional\n // from : { id : 0, username : 'somebody' },\n // chat : { id : 0 }\n }\n }\n};\n\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":360,"wires":[["df5bccfb0eaa9772"]]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"1000","usesocks":false,"sockshost":"192.168.178.200","socksprotocol":"socks5","socksport":"1080","socksusername":"","sockspassword":"","bothost":"ihive.spdns.de","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":true,"verboselogging":true}]
[{"id":"8c682765.b34cf8","type":"telegram command","z":"2aad377dfdc4367e","name":"/foo","command":"/foo","description":"","registercommand":false,"language":"","bot":"65ca12172854cc2d","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":550,"y":160,"wires":[["22ce65840450e170"]]},{"id":"6e9683e1a39526da","type":"telegram command","z":"2aad377dfdc4367e","name":"/bar","command":"/bar","description":"","registercommand":false,"language":"","bot":"65ca12172854cc2d","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":550,"y":240,"wires":[["471e47ea5a959c01"]]},{"id":"22ce65840450e170","type":"debug","z":"2aad377dfdc4367e","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":160,"wires":[]},{"id":"471e47ea5a959c01","type":"debug","z":"2aad377dfdc4367e","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":240,"wires":[]},{"id":"df5bccfb0eaa9772","type":"telegram control","z":"2aad377dfdc4367e","name":"","bot":"65ca12172854cc2d","outputs":1,"checkconnection":false,"hostname":"","interval":10,"timeout":1,"x":560,"y":320,"wires":[["6aa222d848819333"]]},{"id":"6aa222d848819333","type":"debug","z":"2aad377dfdc4367e","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":320,"wires":[]},{"id":"319bb010c9ef672d","type":"inject","z":"2aad377dfdc4367e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":320,"wires":[["44b3db9131df60e0"]]},{"id":"44b3db9131df60e0","type":"function","z":"2aad377dfdc4367e","name":"/foo","func":"// see https://core.telegram.org/bots/api#message\n\nlet newMsg = {\n payload : {\n command: \"command\",\n message: {\n text: \"/foo\",\n \n // these are optional\n // from : { id : 0, username : 'somebody' },\n // chat : { id : 0 }\n }\n }\n};\n\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":320,"wires":[["df5bccfb0eaa9772"]]},{"id":"70307757bc6de41d","type":"inject","z":"2aad377dfdc4367e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":360,"wires":[["89ccaa8f0e3594be"]]},{"id":"89ccaa8f0e3594be","type":"function","z":"2aad377dfdc4367e","name":"/bar","func":"// see https://core.telegram.org/bots/api#message\n\nlet newMsg = {\n payload : {\n command: \"command\",\n message: {\n text: \"/bar\",\n \n // these are optional\n // from : { id : 0, username : 'somebody' },\n // chat : { id : 0 }\n }\n }\n};\n\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":360,"wires":[["df5bccfb0eaa9772"]]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"1000","usesocks":false,"sockshost":"192.168.178.200","socksprotocol":"socks5","socksport":"1080","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":true,"verboselogging":true}]

0 comments on commit bb892ad

Please sign in to comment.