├── .gitignore ├── .github ├── FUNDING.yml └── workflows │ ├── node.js.yml │ └── npm-publish.yml ├── images ├── TelegramBotEcho.png ├── TelegramBotHelp.png ├── TelegramBotHelp2.png ├── TelegramBotHelp3.png ├── TelegramBotExample.png ├── TelegramBotLocation.png ├── TelegramBotLocation2.png ├── TelegramBotNodeEvent.png ├── TelegramBotNodeReply.png ├── TelegramBotSecurity.png ├── TelegramBotSendPhoto.png ├── TelegramBotNodeCommand.png ├── TelegramBotNodeSender.png ├── TelegramBotSendContact.png ├── TelegramBotSendPhoto2.png ├── TelegramBotSendToChat.png ├── TelegramBotSendToChat2.png ├── TelegramBotErrorHandling.png ├── TelegramBotErrorHandling2.png ├── TelegramBotInlineQuery1.png ├── TelegramBotInlineQuery2.png ├── TelegramBotLiveLocation.png ├── TelegramBotNodeReceiver.png ├── TelegramBotOnReplyMessage.png ├── TelegramBotSendChatAction.png ├── TelegramBotSendContact2.png ├── TelegramBotSendContact3.png ├── TelegramBotSendMediaGroup.png ├── TelegramBotSocks5Docker1.png ├── TelegramBotSocks5Docker2.png ├── TelegramBotSocks5Docker3.png ├── TelegramBotSocks5Docker4.png ├── TelegramBotSocks5Docker5.png ├── TelegramBotSocks5Docker6.png ├── TelegramBotSocks5Docker7.png ├── TelegramBotSocks5Docker8.png ├── TelegramBotSocks5Docker9.png ├── TelegramSettingsUsername.png ├── TelegramBotInlineKeyboard1.png ├── TelegramBotInlineKeyboard2.png ├── TelegramBotInlineKeyboard3.png ├── TelegramBotInlineKeyboard4.png ├── TelegramBotInlineKeyboard5.png ├── TelegramBotOnReplyMessage2.png ├── TelegramBotOnReplyMessage3.png ├── TelegramBotSendChatAction2.png ├── TelegramBotSendMediaGroup2.png ├── TelegramBotConfirmationMessage.png ├── TelegramBotEditInlineKeyboard1.png ├── TelegramBotEditInlineKeyboard2.png ├── TelegramBotEditInlineKeyboard3.png ├── TelegramBotEditInlineKeyboard4.png ├── TelegramBotEditInlineKeyboard5.png ├── TelegramBotEditInlineKeyboard6.png ├── TelegramBotEditInlineKeyboard7.png ├── TelegramBotSendMessageToChat.png ├── TelegramBotSendToChatMarkdown.png ├── TelegramBotSocks5Configuration.png ├── TelegramBotUnauthorizedAccess.png ├── TelegramBotUnauthorizedAccess2.png ├── TelegramBotConfirmationMessage2.png ├── TelegramBotConfirmationMessage3.png ├── TelegramBotConfirmationMessage4.png ├── TelegramBotConfirmationMessage5.png ├── TelegramBotDynamicAuthorization.png ├── TelegramBotDynamicAuthorization2.png ├── TelegramBotDynamicAuthorization3.png ├── TelegramBotWebHookConfiguration.png ├── TelegramBotConfigurationDialogEvent.png ├── TelegramBotConfigurationNodeDialog.png ├── TelegramBotCustomKeyboardBasicFlow.png └── TelegramBotInlineKeyboardBasicFlow.png ├── telegrambot ├── icons │ ├── telegram.png │ └── telegram_cmd.png ├── 99-telegrambot.js └── nodes │ ├── reply-node.js │ ├── event-node.js │ ├── control-node.js │ ├── command-node.js │ └── in-node.js ├── .prettierrc ├── .eslintrc.yaml ├── examples ├── echo.json ├── command.json ├── makecert.bat ├── unauthorizedaccess.json ├── sendmessagetochat.json ├── sendcontacttochat.json ├── copymessage.json ├── forwardmessage.json ├── replytomessage.json ├── receivinglocation.json ├── sendtomanychats.json ├── sendhelpmessage.json ├── senddice.json ├── sendphoto.json ├── setmessagereaction.json ├── sendmediagroup.json ├── sendchataction.json ├── getfile.json ├── downloadfile.json ├── sendtotopic.json ├── control.json ├── onreplymessage.json ├── inlinequery.json ├── senddocumenttochat.json ├── sendkeyboardtochat.json ├── basiccustomkeyboard.json ├── keyboard.json ├── command2.json ├── externalreceiver1.json ├── sendinvoice.json ├── webappdata.json ├── inlinekeyboard.json ├── createpoll.json ├── basicinlinekeyboard.json ├── editMessageText.json ├── editMessageCaption.json ├── dynamicauthorization.json ├── externalreceiver2.json ├── sendphotobuffer.json ├── triggerCommandFromControlNode.json ├── errorhandling.json ├── simplebot.json ├── commandScopes.json ├── editMessageMedia.json ├── sendInvoice2.json ├── pinningMultipleMessages.json ├── editinlinekeyboard.json ├── livelocation.json └── supergroupadmin.json ├── LICENSE ├── package.json ├── SOCKS5.md └── WEBHOOK.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ['https://www.paypal.me/windkh', 'https://www.buymeacoffee.com/windka'] 2 | -------------------------------------------------------------------------------- /images/TelegramBotEcho.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotEcho.png -------------------------------------------------------------------------------- /images/TelegramBotHelp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotHelp.png -------------------------------------------------------------------------------- /images/TelegramBotHelp2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotHelp2.png -------------------------------------------------------------------------------- /images/TelegramBotHelp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotHelp3.png -------------------------------------------------------------------------------- /images/TelegramBotExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotExample.png -------------------------------------------------------------------------------- /images/TelegramBotLocation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotLocation.png -------------------------------------------------------------------------------- /images/TelegramBotLocation2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotLocation2.png -------------------------------------------------------------------------------- /images/TelegramBotNodeEvent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotNodeEvent.png -------------------------------------------------------------------------------- /images/TelegramBotNodeReply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotNodeReply.png -------------------------------------------------------------------------------- /images/TelegramBotSecurity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSecurity.png -------------------------------------------------------------------------------- /images/TelegramBotSendPhoto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendPhoto.png -------------------------------------------------------------------------------- /telegrambot/icons/telegram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/telegrambot/icons/telegram.png -------------------------------------------------------------------------------- /images/TelegramBotNodeCommand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotNodeCommand.png -------------------------------------------------------------------------------- /images/TelegramBotNodeSender.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotNodeSender.png -------------------------------------------------------------------------------- /images/TelegramBotSendContact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendContact.png -------------------------------------------------------------------------------- /images/TelegramBotSendPhoto2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendPhoto2.png -------------------------------------------------------------------------------- /images/TelegramBotSendToChat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendToChat.png -------------------------------------------------------------------------------- /images/TelegramBotSendToChat2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendToChat2.png -------------------------------------------------------------------------------- /images/TelegramBotErrorHandling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotErrorHandling.png -------------------------------------------------------------------------------- /images/TelegramBotErrorHandling2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotErrorHandling2.png -------------------------------------------------------------------------------- /images/TelegramBotInlineQuery1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotInlineQuery1.png -------------------------------------------------------------------------------- /images/TelegramBotInlineQuery2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotInlineQuery2.png -------------------------------------------------------------------------------- /images/TelegramBotLiveLocation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotLiveLocation.png -------------------------------------------------------------------------------- /images/TelegramBotNodeReceiver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotNodeReceiver.png -------------------------------------------------------------------------------- /images/TelegramBotOnReplyMessage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotOnReplyMessage.png -------------------------------------------------------------------------------- /images/TelegramBotSendChatAction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendChatAction.png -------------------------------------------------------------------------------- /images/TelegramBotSendContact2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendContact2.png -------------------------------------------------------------------------------- /images/TelegramBotSendContact3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendContact3.png -------------------------------------------------------------------------------- /images/TelegramBotSendMediaGroup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendMediaGroup.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker1.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker2.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker3.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker4.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker5.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker6.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker7.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker8.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Docker9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Docker9.png -------------------------------------------------------------------------------- /images/TelegramSettingsUsername.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramSettingsUsername.png -------------------------------------------------------------------------------- /telegrambot/icons/telegram_cmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/telegrambot/icons/telegram_cmd.png -------------------------------------------------------------------------------- /images/TelegramBotInlineKeyboard1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotInlineKeyboard1.png -------------------------------------------------------------------------------- /images/TelegramBotInlineKeyboard2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotInlineKeyboard2.png -------------------------------------------------------------------------------- /images/TelegramBotInlineKeyboard3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotInlineKeyboard3.png -------------------------------------------------------------------------------- /images/TelegramBotInlineKeyboard4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotInlineKeyboard4.png -------------------------------------------------------------------------------- /images/TelegramBotInlineKeyboard5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotInlineKeyboard5.png -------------------------------------------------------------------------------- /images/TelegramBotOnReplyMessage2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotOnReplyMessage2.png -------------------------------------------------------------------------------- /images/TelegramBotOnReplyMessage3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotOnReplyMessage3.png -------------------------------------------------------------------------------- /images/TelegramBotSendChatAction2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendChatAction2.png -------------------------------------------------------------------------------- /images/TelegramBotSendMediaGroup2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendMediaGroup2.png -------------------------------------------------------------------------------- /images/TelegramBotConfirmationMessage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotConfirmationMessage.png -------------------------------------------------------------------------------- /images/TelegramBotEditInlineKeyboard1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotEditInlineKeyboard1.png -------------------------------------------------------------------------------- /images/TelegramBotEditInlineKeyboard2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotEditInlineKeyboard2.png -------------------------------------------------------------------------------- /images/TelegramBotEditInlineKeyboard3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotEditInlineKeyboard3.png -------------------------------------------------------------------------------- /images/TelegramBotEditInlineKeyboard4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotEditInlineKeyboard4.png -------------------------------------------------------------------------------- /images/TelegramBotEditInlineKeyboard5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotEditInlineKeyboard5.png -------------------------------------------------------------------------------- /images/TelegramBotEditInlineKeyboard6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotEditInlineKeyboard6.png -------------------------------------------------------------------------------- /images/TelegramBotEditInlineKeyboard7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotEditInlineKeyboard7.png -------------------------------------------------------------------------------- /images/TelegramBotSendMessageToChat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendMessageToChat.png -------------------------------------------------------------------------------- /images/TelegramBotSendToChatMarkdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSendToChatMarkdown.png -------------------------------------------------------------------------------- /images/TelegramBotSocks5Configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotSocks5Configuration.png -------------------------------------------------------------------------------- /images/TelegramBotUnauthorizedAccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotUnauthorizedAccess.png -------------------------------------------------------------------------------- /images/TelegramBotUnauthorizedAccess2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotUnauthorizedAccess2.png -------------------------------------------------------------------------------- /images/TelegramBotConfirmationMessage2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotConfirmationMessage2.png -------------------------------------------------------------------------------- /images/TelegramBotConfirmationMessage3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotConfirmationMessage3.png -------------------------------------------------------------------------------- /images/TelegramBotConfirmationMessage4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotConfirmationMessage4.png -------------------------------------------------------------------------------- /images/TelegramBotConfirmationMessage5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotConfirmationMessage5.png -------------------------------------------------------------------------------- /images/TelegramBotDynamicAuthorization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotDynamicAuthorization.png -------------------------------------------------------------------------------- /images/TelegramBotDynamicAuthorization2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotDynamicAuthorization2.png -------------------------------------------------------------------------------- /images/TelegramBotDynamicAuthorization3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotDynamicAuthorization3.png -------------------------------------------------------------------------------- /images/TelegramBotWebHookConfiguration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotWebHookConfiguration.png -------------------------------------------------------------------------------- /images/TelegramBotConfigurationDialogEvent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotConfigurationDialogEvent.png -------------------------------------------------------------------------------- /images/TelegramBotConfigurationNodeDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotConfigurationNodeDialog.png -------------------------------------------------------------------------------- /images/TelegramBotCustomKeyboardBasicFlow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotCustomKeyboardBasicFlow.png -------------------------------------------------------------------------------- /images/TelegramBotInlineKeyboardBasicFlow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windkh/node-red-contrib-telegrambot/HEAD/images/TelegramBotInlineKeyboardBasicFlow.png -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "tabWidth": 4, 4 | "semi": true, 5 | "singleQuote": true, 6 | "bracketSpacing": true, 7 | "endOfLine": "auto", 8 | "printWidth" : 160 9 | } -------------------------------------------------------------------------------- /.eslintrc.yaml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - prettier 3 | extends: 4 | - eslint:recommended 5 | - plugin:prettier/recommended 6 | env: 7 | es6: true 8 | node: true 9 | browser: true 10 | rules: 11 | prettier/prettier: [error, {endOfLine: auto}] 12 | quotes: [warn, single] 13 | no-var: error -------------------------------------------------------------------------------- /examples/echo.json: -------------------------------------------------------------------------------- 1 | [{"id":"1f3cb0bd.e0c34f","type":"telegram bot","z":"8fa6460.f7059b8","botname":"HeinzBot"},{"id":"59aeb36e.a6514c","type":"telegram receiver","z":"8fa6460.f7059b8","name":"","bot":"1f3cb0bd.e0c34f","x":109,"y":128,"wires":[["ec7432bc.138bd"]]},{"id":"ec7432bc.138bd","type":"telegram sender","z":"8fa6460.f7059b8","name":"","bot":"","x":386,"y":128,"wires":[]}] -------------------------------------------------------------------------------- /examples/command.json: -------------------------------------------------------------------------------- 1 | [{"id":"ff78bc5a.00874","type":"telegram bot","z":"70c3f45a.8f3c0c","botname":"HeinzBot","usernames":"","chatids":""},{"id":"a3b2b972.7ee418","type":"telegram sender","z":"70c3f45a.8f3c0c","name":"","bot":"ff78bc5a.00874","x":405.51483154296875,"y":738.9999771118164,"wires":[[]]},{"id":"2b76dc18.af49e4","type":"telegram command","z":"70c3f45a.8f3c0c","name":"/foo","command":"/foo","bot":"ff78bc5a.00874","x":146.510498046875,"y":744.3689804077148,"wires":[["a3b2b972.7ee418"],[]]}] -------------------------------------------------------------------------------- /examples/makecert.bat: -------------------------------------------------------------------------------- 1 | REM We assume that git for windows is installed: openssl.exe can be found there. 2 | REM Follow these steps to install a webhook 3 | REM make sure that your server is reachable from the internet: e.g. yourname.spdns.de 4 | REM make sure that your router allows traffic via TCP port 8443 to your server 5 | REM create a certificate with the correct internet address see above: yourname.spdns.de 6 | REM configure the bot in node-red: webhook, public port 8443, private port 8443, path to PRIVATE.key and path to PUBLIC.pem 7 | REM make sure that the checkbox "Certificate is self signed is checked" 8 | 9 | set OPENSSL="%ProgramFiles%\Git\usr\bin\openssl.exe" 10 | 11 | del PRIVATE.key 12 | del PUBLIC.pem 13 | %OPENSSL% req -newkey rsa:2048 -sha256 -nodes -keyout PRIVATE.key -x509 -days 365 -out PUBLIC.pem -subj "/C=DE/ST=Bavaria/L=Munich/O=FooBot/CN=foo.spdns.de" 14 | 15 | pause -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [16.x, 18.x, 19.x, 20.x] 20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 21 | 22 | steps: 23 | - uses: actions/checkout@v2 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v1 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | - run: npm ci 29 | - run: npm run lint 30 | -------------------------------------------------------------------------------- /examples/unauthorizedaccess.json: -------------------------------------------------------------------------------- 1 | [{"id":"51481804.ffa4e8","type":"telegram receiver","z":"1f6b5f62.c79df1","name":"","bot":"45ef79a0.ed7688","saveDataDir":"","x":200,"y":60,"wires":[[],["7d693fc7.9db0d"]]},{"id":"7d693fc7.9db0d","type":"function","z":"1f6b5f62.c79df1","name":"create log string","func":"var chatId = msg.payload.chatId;\nvar username = msg.originalMessage.from.username;\nmsg.originalMessage.timestamp = new Date();\nvar message = JSON.stringify(msg.originalMessage);\n\nmsg.topic = username + ' ' + chatId;\nmsg.payload = [msg.topic, message];\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":80,"wires":[["3a8044a2.4c34ac"]]},{"id":"3a8044a2.4c34ac","type":"file","z":"1f6b5f62.c79df1","name":"LogFile","filename":"c:\\unauthorized.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","x":600,"y":80,"wires":[]},{"id":"45ef79a0.ed7688","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"1","baseapiurl":"","pollinterval":""}] -------------------------------------------------------------------------------- /examples/sendmessagetochat.json: -------------------------------------------------------------------------------- 1 | [{"id":"ff78bc5a.00874","type":"telegram bot","z":"70c3f45a.8f3c0c","botname":"HeinzBot","usernames":"","chatids":""},{"id":"8369d2d4.722d7","type":"telegram sender","z":"70c3f45a.8f3c0c","name":"","bot":"ff78bc5a.00874","x":526.5148315429688,"y":708.5407104492188,"wires":[[]]},{"id":"49cf240b.2ca1ac","type":"function","z":"70c3f45a.8f3c0c","name":"send markdown","func":"var message = 'You can also send *markdown* formatted messages.';\nmsg.payload = {chatId : 138708568, type : 'message', content : message};\n\n// activate markdown\nmsg.payload.options = {disable_web_page_preview : true, parse_mode : \"Markdown\"};\nreturn msg;","outputs":1,"noerr":0,"x":305.51483154296875,"y":706.5407333374023,"wires":[["8369d2d4.722d7"]]},{"id":"df89602b.3cc31","type":"inject","z":"70c3f45a.8f3c0c","name":"Trigger","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":104.83332824707031,"y":706.0000839233398,"wires":[["49cf240b.2ca1ac"]]}] -------------------------------------------------------------------------------- /examples/sendcontacttochat.json: -------------------------------------------------------------------------------- 1 | [{"id":"7bf5e4e9.495b74","type":"telegram sender","z":"c8b50aaa.e632d","name":"","bot":"233d0697.0c2c6a","x":650,"y":860,"wires":[[]]},{"id":"a35c4e19.9ed248","type":"function","z":"c8b50aaa.e632d","name":"contact","func":"msg.payload =\n{\n chatId : 12345,\n type : \"contact\",\n content :\n {\n phone_number: \"+49 30 987654321\",\n first_name: \"Max\",\n last_name: \"Mustermann\"\n },\n options :\n {\n disable_notification : true\n }\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":459.66669845581055,"y":860.3333539962769,"wires":[["7bf5e4e9.495b74"]]},{"id":"b9f0a60f.c5efb8","type":"inject","z":"c8b50aaa.e632d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"str","x":281.66668701171875,"y":859.6667280197144,"wires":[["a35c4e19.9ed248"]]},{"id":"233d0697.0c2c6a","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":""}] 2 | -------------------------------------------------------------------------------- /examples/copymessage.json: -------------------------------------------------------------------------------- 1 | [{"id":"7727eeae.3ff06","type":"function","z":"ed43e0f7.31d9","name":"copy","func":"msg.payload.copy = { chatId : -292227168 };\n\nmsg.payload.copy.options = {\n disable_notification : true\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":420,"wires":[["5deafc81.1b37d4"]]},{"id":"c4d6200e.a014b","type":"telegram receiver","z":"ed43e0f7.31d9","name":"","bot":"5f67fb38.18d094","saveDataDir":"","filterCommands":false,"x":150,"y":420,"wires":[["7727eeae.3ff06"],[]]},{"id":"5deafc81.1b37d4","type":"telegram sender","z":"ed43e0f7.31d9","name":"","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":580,"y":420,"wires":[[]]},{"id":"5f67fb38.18d094","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}] -------------------------------------------------------------------------------- /examples/forwardmessage.json: -------------------------------------------------------------------------------- 1 | [{"id":"2f17b49a.ba9b7c","type":"telegram receiver","z":"ed43e0f7.31d9","name":"","bot":"5f67fb38.18d094","saveDataDir":"","filterCommands":false,"x":150,"y":280,"wires":[["ceb21a7e.1564c8"],[]]},{"id":"981acf13.a4a1b","type":"telegram sender","z":"ed43e0f7.31d9","name":"","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":580,"y":280,"wires":[[]]},{"id":"ceb21a7e.1564c8","type":"function","z":"ed43e0f7.31d9","name":"forward","func":"msg.payload.forward = { chatId : -292227168 };\n\nmsg.payload.forward.options = {\n disable_notification : true\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":280,"wires":[["981acf13.a4a1b"]]},{"id":"5f67fb38.18d094","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}] -------------------------------------------------------------------------------- /examples/replytomessage.json: -------------------------------------------------------------------------------- 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":"","localbotport":"","publicbotport":"","privatekey":"C:\\\\Temp\\\\SSL\\\\PRIVATE.key","certificate":"C:\\\\Temp\\\\SSL\\\\PUBLIC.pem","useselfsignedcertificate":true,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/receivinglocation.json: -------------------------------------------------------------------------------- 1 | [{"id":"7654a517.757b84","type":"telegram event","z":"e4aa33b0.1d4fd","name":"live location receiver","bot":"d086776c.7de82","event":"edited_message","autoanswer":"","x":260,"y":1360,"wires":[["365556c8.2d4362"]]},{"id":"365556c8.2d4362","type":"function","z":"e4aa33b0.1d4fd","name":"create location message","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,"initialize":"","finalize":"","x":540,"y":1360,"wires":[[]]},{"id":"d086776c.7de82","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}] 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Extended MIT like License (MIT+) 2 | Copyright (c) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | If you intend to include this package a commercial products, then you must contact the author and ask for permission. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /examples/sendtomanychats.json: -------------------------------------------------------------------------------- 1 | [{"id":"f1af007a.70fe1","type":"telegram sender","z":"8436a552.ae1f78","name":"","bot":"c3670dce.18aa8","x":690,"y":80,"wires":[[]]},{"id":"9a0d55f1.532a78","type":"telegram receiver","z":"8436a552.ae1f78","name":"","bot":"c3670dce.18aa8","saveDataDir":"c:\\temp\\foo","x":150,"y":80,"wires":[["a779c31c.90401","6040d5c7.d86f9c"],[]]},{"id":"a779c31c.90401","type":"debug","z":"8436a552.ae1f78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":220,"wires":[]},{"id":"6040d5c7.d86f9c","type":"function","z":"8436a552.ae1f78","name":"to many chats","func":"var chatIds = [];\nchatIds.push(msg.payload.chatId);\nchatIds.push(msg.payload.chatId);\n\nmsg.payload.chatId = chatIds;\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":60,"wires":[["f1af007a.70fe1"]]},{"id":"c3670dce.18aa8","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/sendhelpmessage.json: -------------------------------------------------------------------------------- 1 | [{"id":"7ae934e9.94a1d4","type":"telegram command","z":"b7fa06fe.1d0608","name":"/help","command":"/help","bot":"2db9661a.cf3b0a","strict":false,"hasresponse":false,"x":190,"y":60,"wires":[["11b04bce.b00ed4"]]},{"id":"11b04bce.b00ed4","type":"function","z":"b7fa06fe.1d0608","name":"create help text","func":"var helpMessage = \"/help - shows help\";\n\nhelpMessage += \"\\r\\n/foo - opens a dialog\";\n\nhelpMessage += \"\\r\\n\";\nhelpMessage += \"\\r\\nYou are welcome: \"+msg.originalMessage.from.username;\nhelpMessage += \"\\r\\nYour chat id is \" + msg.payload.chatId;\nhelpMessage += \"\\r\\n\";\n\nmsg.payload.content = helpMessage;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":60,"wires":[["2b5fd25.13e2c2e"]]},{"id":"2b5fd25.13e2c2e","type":"telegram sender","z":"b7fa06fe.1d0608","name":"send response","bot":"2db9661a.cf3b0a","x":620,"y":60,"wires":[[]]},{"id":"2db9661a.cf3b0a","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}] 2 | -------------------------------------------------------------------------------- /examples/senddice.json: -------------------------------------------------------------------------------- 1 | [{"id":"44baff779a3bd309","type":"telegram sender","z":"312066c9ad97fb02","name":"","bot":"3b6bfbc0.423a04","haserroroutput":false,"outputs":1,"x":630,"y":80,"wires":[[]]},{"id":"402cdb75652dcb0c","type":"function","z":"312066c9ad97fb02","name":"roll the dice","func":"msg.payload.type = \"dice\";\n\nlet min = 1;\nlet max = 6;\nlet value = Math.floor(Math.random() * (max - min + 1) + min);\nmsg.payload.content = {\n emoji : \"🎲\",\n value : value\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":80,"wires":[["44baff779a3bd309"]]},{"id":"7792329629a4e33b","type":"telegram command","z":"312066c9ad97fb02","name":"roll the dice","command":"/roll","description":"","registercommand":false,"language":"","scope":"default","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":170,"y":80,"wires":[["402cdb75652dcb0c"],[]]},{"id":"3b6bfbc0.423a04","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"1000","usesocks":false,"sockshost":"192.168.178.200","socksport":"1080","socksusername":"user","sockspassword":"password","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}] -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-red-contrib-telegrambot", 3 | "version": "17.0.3", 4 | "description": "Telegram bot nodes for Node-RED", 5 | "dependencies": { 6 | "bluebird": "^3.7.2", 7 | "node-telegram-bot-api": "^0.66.0", 8 | "socks-proxy-agent": "^8.0.3" 9 | }, 10 | "scripts": { 11 | "lint": "eslint telegrambot/*.js", 12 | "postlint": "echo ✅ lint valid" 13 | }, 14 | "husky": { 15 | "hooks": { 16 | "pre-commit": "npm run lint" 17 | } 18 | }, 19 | "node-red": { 20 | "version": ">=1.3.7", 21 | "nodes": { 22 | "telegrambot": "telegrambot/99-telegrambot.js" 23 | } 24 | }, 25 | "engines": { 26 | "node": ">=12.0.0" 27 | }, 28 | "keywords": [ 29 | "node-red", 30 | "telegram", 31 | "bot" 32 | ], 33 | "repository": { 34 | "type": "git", 35 | "url": "https://github.com/windkh/node-red-contrib-telegrambot" 36 | }, 37 | "author": "Karl-Heinz Wind", 38 | "license": "MIT", 39 | "devDependencies": { 40 | "eslint": "^8.20.0", 41 | "eslint-config-prettier": "^8.5.0", 42 | "eslint-plugin-prettier": "^4.2.1", 43 | "husky": "^8.0.1", 44 | "prettier": "^2.7.1" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/sendphoto.json: -------------------------------------------------------------------------------- 1 | [{"id":"1bdded1.fbdcf13","type":"telegram sender","z":"f86d9fd2.9f14c","name":"","bot":"ff78bc5a.00874","haserroroutput":false,"outputs":1,"x":570,"y":520,"wires":[[]]},{"id":"33b83c10.13de64","type":"function","z":"f86d9fd2.9f14c","name":"send picture","func":"// content can be a file_id, url, local path...\nmsg.payload.content = 'https://www.cleverfiles.com/howto/wp-content/uploads/2018/03/minion.jpg';\nmsg.payload.type = 'photo';\nmsg.payload.caption = \"super cool\"\n\n/* type can be one of the following\nphoto\naudio\nvideo\nsticker\nvoice\ndocument\n*/\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":353,"y":520,"wires":[["1bdded1.fbdcf13"]]},{"id":"ebd84fc3.d97fa8","type":"telegram command","z":"f86d9fd2.9f14c","name":"/foo","command":"/foo","bot":"ff78bc5a.00874","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":162.99566650390625,"y":519.8282470703125,"wires":[["33b83c10.13de64"]]},{"id":"ff78bc5a.00874","type":"telegram bot","z":"f86d9fd2.9f14c","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"webhook","pollinterval":"","usesocks":false,"sockshost":"","socksport":"","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"C:\\Temp\\PRIVATE.key","certificate":"C:\\Temp\\PUBLIC.pem","useselfsignedcertificate":true,"sslterminated":false,"verboselogging":false}] -------------------------------------------------------------------------------- /examples/setmessagereaction.json: -------------------------------------------------------------------------------- 1 | [{"id":"1d5e4fc2f90630dc","type":"telegram sender","z":"d03a174f444c9696","name":"","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":710,"y":460,"wires":[[]]},{"id":"55070f1127b2e5d5","type":"telegram receiver","z":"d03a174f444c9696","name":"","bot":"65ca12172854cc2d","saveDataDir":"","filterCommands":false,"x":190,"y":460,"wires":[["cad82037a06ca06d"],[]]},{"id":"cad82037a06ca06d","type":"function","z":"d03a174f444c9696","name":"setMessageReaction","func":"// see https://core.telegram.org/bots/api#setmessagereaction\nmsg.payload.type = 'setMessageReaction';\nmsg.payload.content = msg.payload.messageId;\nmsg.payload.options = {\n reaction : [\n { type : 'emoji', emoji : '👍'}\n ],\n is_big : false\n\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":460,"wires":[["1d5e4fc2f90630dc"]]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","testenvironment":false,"updatemode":"polling","addressfamily":"","pollinterval":"1000","usesocks":false,"sockshost":"192.168.178.200","socksprotocol":"socks4","socksport":"1080","socksusername":"user","sockspassword":"password","bothost":"ihive.spdns.de","botpath":"","localbothost":"127.0.0.1","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":true,"verboselogging":true}] -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-node@v1 16 | with: 17 | node-version: 12 18 | - run: npm ci 19 | - run: npm run lint 20 | 21 | publish-npm: 22 | needs: build 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | - uses: actions/setup-node@v1 27 | with: 28 | node-version: 12 29 | registry-url: https://registry.npmjs.org/ 30 | - run: npm ci 31 | - run: npm publish 32 | env: 33 | NODE_AUTH_TOKEN: ${{secrets.npm_token}} 34 | 35 | # publish-gpr: 36 | # needs: build 37 | # runs-on: ubuntu-latest 38 | # steps: 39 | # - uses: actions/checkout@v2 40 | # - uses: actions/setup-node@v1 41 | # with: 42 | # node-version: 12 43 | # registry-url: https://npm.pkg.github.com/ 44 | # - run: npm ci 45 | # - run: npm publish 46 | # env: 47 | # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 48 | -------------------------------------------------------------------------------- /examples/sendmediagroup.json: -------------------------------------------------------------------------------- 1 | [{"id":"d8e187c1.a57758","type":"telegram sender","z":"b4ae6b65.273bd","name":"","bot":"1ca301b6.26e06e","x":621,"y":1331,"wires":[[]]},{"id":"321d3711.941f58","type":"telegram command","z":"b4ae6b65.273bd","name":"","command":"/send","bot":"1ca301b6.26e06e","strict":false,"hasresponse":false,"x":230.5,"y":1331,"wires":[["8ee7cd38.72be1"]]},{"id":"8ee7cd38.72be1","type":"function","z":"b4ae6b65.273bd","name":"create media group","func":"// sendMediaGroup example: send between 2 and 10 media.\n// Note that type can also be video.\n// and the caption property is optional.\n// see https://core.telegram.org/bots/api#inputmediaphoto\n// see https://core.telegram.org/bots/api#inputmediavideo\n\nmsg.payload.type = \"mediaGroup\";\nmsg.payload.content = [\n {\n type : \"photo\",\n media : \"c:\\\\Temp\\\\1.jpg\",\n caption : \"Photo 1\"\n },\n {\n type : \"photo\",\n media : \"c:\\\\Temp\\\\2.jpg\",\n caption : \"Photo 2\"\n }\n];\n\nreturn msg;","outputs":1,"noerr":0,"x":405,"y":1331,"wires":[["d8e187c1.a57758"]]},{"id":"1ca301b6.26e06e","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"Windhose","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"verboselogging":false}] 2 | -------------------------------------------------------------------------------- /examples/sendchataction.json: -------------------------------------------------------------------------------- 1 | [{"id":"e76a862e.a03858","type":"telegram receiver","z":"725879df.541168","name":"","bot":"bd029d64.0546a","saveDataDir":"","x":150,"y":140,"wires":[["594c315e.57fec"],[]]},{"id":"cc0d5363.33275","type":"telegram sender","z":"725879df.541168","name":"","bot":"bd029d64.0546a","x":610,"y":140,"wires":[[]]},{"id":"594c315e.57fec","type":"function","z":"725879df.541168","name":"send chat action","func":"// demonstrates sending a chat action (see https://core.telegram.org/bots/api#sendchataction)\nvar type = msg.payload.type;\nmsg.payload.type = \"action\";\n\nswitch(type){\n case \"message\":\n msg.payload.content = \"typing\"; \n break;\n\n case \"photo\":\n msg.payload.content = \"upload_photo\"; \n break;\n\n case \"video\":\n msg.payload.content = \"upload_video\"; \n break;\n\n case \"audio\":\n msg.payload.content = \"upload_audio\"; \n break;\n\n case \"document\":\n msg.payload.content = \"upload_document\"; \n break;\n\n case \"location\":\n msg.payload.content = \"find_location\"; \n break;\n\n case \"video_note\":\n msg.payload.content = \"upload_video_note\"; \n break;\n \n default:\n msg = null;\n break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":140,"wires":[["cc0d5363.33275"]]},{"id":"bd029d64.0546a","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","pollinterval":"300"}] -------------------------------------------------------------------------------- /examples/getfile.json: -------------------------------------------------------------------------------- 1 | [{"id":"56385912acc6a6ba","type":"telegram receiver","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","saveDataDir":"","filterCommands":false,"x":190,"y":220,"wires":[["c570b04911862843","3f26294392ed5771"],[]]},{"id":"c7d66fca7bbfef5b","type":"telegram sender","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":750,"y":220,"wires":[["4321b804e33f0b4a"]]},{"id":"4321b804e33f0b4a","type":"debug","z":"ec1cf3fd9654e7e5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":220,"wires":[]},{"id":"3f26294392ed5771","type":"function","z":"ec1cf3fd9654e7e5","name":"get info about first photo manually","func":"if(msg.payload.type === 'photo'){\n \n // manually download the first photo using the fileId.\n msg.payload.getfile = {\n fileId : msg.payload.photos[msg.payload.photos.length - 1].file_id,\n }\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":220,"wires":[["c7d66fca7bbfef5b"]]},{"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":false,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/downloadfile.json: -------------------------------------------------------------------------------- 1 | [{"id":"5b61e831f6a6d74d","type":"telegram receiver","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","saveDataDir":"","filterCommands":false,"x":110,"y":120,"wires":[["7781831794d26351"],[]]},{"id":"e701c4fe8f5db67f","type":"telegram sender","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":630,"y":120,"wires":[["f7fd168fb734c5cb"]]},{"id":"7781831794d26351","type":"function","z":"ec1cf3fd9654e7e5","name":"download first photo manually","func":"if(msg.payload.type === 'photo'){\n \n // manually download the first photo using the fileId.\n msg.payload.download = {\n fileId : msg.payload.photos[0].file_id,\n filePath : \"c:\\\\temp\",\n // fileName : \"foo.jpg\" // optional\n }\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":120,"wires":[["e701c4fe8f5db67f"]]},{"id":"f7fd168fb734c5cb","type":"debug","z":"ec1cf3fd9654e7e5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":120,"wires":[]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"3000","usesocks":false,"sockshost":"192.168.178.200","socksprotocol":"socks5","socksport":"1080","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/sendtotopic.json: -------------------------------------------------------------------------------- 1 | [{"id":"7698c9e0dd353093","type":"telegram sender","z":"066f4fb0d4219c61","name":"","bot":"39c2553806e29aae","haserroroutput":false,"outputs":1,"x":720,"y":3020,"wires":[[]]},{"id":"c832534442939a04","type":"function","z":"066f4fb0d4219c61","name":"General","func":"var message = 'Test Message in General';\nmsg.payload = { chatId: -000000000000, type : 'message', content : message};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":419,"y":3018.0000228881836,"wires":[["7698c9e0dd353093"]]},{"id":"3384c5256d23d9ee","type":"inject","z":"066f4fb0d4219c61","name":"Trigger","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":269,"y":3018.0000228881836,"wires":[["c832534442939a04"]]},{"id":"0cbc33f5ba35083d","type":"function","z":"066f4fb0d4219c61","name":"Other Topic","func":"var message = 'Test Message in Other Topic';\nmsg.payload = { chatId: -000000000000, type : 'message', content : message};\n\nmsg.payload.options = {\n message_thread_id: 14,\n };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":3080,"wires":[["7698c9e0dd353093"]]},{"id":"d968b9aaee0f7034","type":"inject","z":"066f4fb0d4219c61","name":"Trigger","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":270,"y":3080,"wires":[["0cbc33f5ba35083d"]]},{"id":"39c2553806e29aae","type":"telegram bot","z":"066f4fb0d4219c61","botname":"HeinzBot","usernames":"","chatids":""}] 2 | -------------------------------------------------------------------------------- /telegrambot/99-telegrambot.js: -------------------------------------------------------------------------------- 1 | // Created by Karl-Heinz Wind 2 | 3 | // Avoid that node-telegram-bot-api will enable automatci promise cancellation (fix for 0.30.0 api) 4 | process.env['NTBA_FIX_319'] = 1; 5 | 6 | module.exports = function (RED) { 7 | 'use strict'; 8 | 9 | let Promise = require('bluebird'); 10 | Promise.config({ 11 | cancellation: true, 12 | }); 13 | 14 | const pkg = require('./../package.json'); 15 | RED.log.info('node-red-contrib-telegrambot version: v' + pkg.version); 16 | 17 | const TelegramBotNode = require('./nodes/bot-node.js')(RED); 18 | RED.nodes.registerType('telegram bot', TelegramBotNode, { 19 | credentials: { 20 | token: { type: 'text' }, 21 | }, 22 | }); 23 | 24 | const TelegramInNode = require('./nodes/in-node.js')(RED); 25 | RED.nodes.registerType('telegram receiver', TelegramInNode); 26 | 27 | const TelegramCommandNode = require('./nodes/command-node.js')(RED); 28 | RED.nodes.registerType('telegram command', TelegramCommandNode); 29 | 30 | const TelegramEventNode = require('./nodes/event-node.js')(RED); 31 | RED.nodes.registerType('telegram event', TelegramEventNode); 32 | 33 | const TelegramOutNode = require('./nodes/out-node.js')(RED); 34 | RED.nodes.registerType('telegram sender', TelegramOutNode); 35 | 36 | const TelegramReplyNode = require('./nodes/reply-node.js')(RED); 37 | RED.nodes.registerType('telegram reply', TelegramReplyNode); 38 | 39 | const TelegramControlNode = require('./nodes/control-node.js')(RED); 40 | RED.nodes.registerType('telegram control', TelegramControlNode); 41 | }; 42 | -------------------------------------------------------------------------------- /examples/control.json: -------------------------------------------------------------------------------- 1 | [{"id":"d84b5890b57e3c20","type":"telegram control","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","outputs":1,"x":340,"y":420,"wires":[["79bd4f875c7c41af"]]},{"id":"79bd4f875c7c41af","type":"debug","z":"ec1cf3fd9654e7e5","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":520,"y":420,"wires":[]},{"id":"07bdd839635f4012","type":"inject","z":"ec1cf3fd9654e7e5","name":"start","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"start\"}","payloadType":"json","x":130,"y":380,"wires":[["d84b5890b57e3c20"]]},{"id":"c75ee8c58e5f3338","type":"inject","z":"ec1cf3fd9654e7e5","name":"stop","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"stop\"}","payloadType":"json","x":130,"y":440,"wires":[["d84b5890b57e3c20"]]},{"id":"8054c09af5ba8a3a","type":"inject","z":"ec1cf3fd9654e7e5","name":"restart","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"restart\",\"delay\":1000}","payloadType":"json","x":130,"y":500,"wires":[["d84b5890b57e3c20"]]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"3000","usesocks":false,"sockshost":"192.168.178.200","socksprotocol":"socks5","socksport":"1080","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/onreplymessage.json: -------------------------------------------------------------------------------- 1 | [{"id":"f0f40237.40f438","type":"function","z":"117ca2b6.9952d5","name":"create question","func":"msg.payload.type = 'message';\nmsg.payload.content = 'Really?';\nmsg.payload.options = {reply_to_message_id : msg.payload.messageId}\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":290,"y":3480,"wires":[["7705422f.822834"]]},{"id":"4c7274da.77331c","type":"telegram command","z":"117ca2b6.9952d5","name":"/foo","command":"/foo","bot":"d086776c.7de82","strict":false,"hasresponse":false,"x":110,"y":3480,"wires":[["f0f40237.40f438"]]},{"id":"7705422f.822834","type":"telegram sender","z":"117ca2b6.9952d5","name":"send question","bot":"d086776c.7de82","x":500,"y":3480,"wires":[["b84786d5.195848"]]},{"id":"b84786d5.195848","type":"telegram reply","z":"117ca2b6.9952d5","name":"get reply","bot":"d086776c.7de82","x":675,"y":3480,"wires":[["29d8ebcb.f400fc"]]},{"id":"29d8ebcb.f400fc","type":"function","z":"117ca2b6.9952d5","name":"switch answer","func":"if(msg.payload.content === 'Yes')\n{\n return [msg, null]; \n}\nelse\n{\n return [null, msg]; \n}\n","outputs":"2","noerr":0,"initialize":"","finalize":"","x":847,"y":3480,"wires":[["6a50edd.6235114"],["b599b2a2.4b0278"]]},{"id":"6a50edd.6235114","type":"debug","z":"117ca2b6.9952d5","name":"Yes","active":true,"console":"false","complete":"payload","x":1050,"y":3460,"wires":[]},{"id":"b599b2a2.4b0278","type":"debug","z":"117ca2b6.9952d5","name":"No","active":true,"console":"false","complete":"payload","x":1050,"y":3500,"wires":[]},{"id":"d086776c.7de82","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}] 2 | -------------------------------------------------------------------------------- /examples/inlinequery.json: -------------------------------------------------------------------------------- 1 | [{"id":"5fb5e66e.d8ebe8","type":"debug","z":"1f6b5f62.c79df1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":350,"y":40,"wires":[]},{"id":"ebf5edfa.8c331","type":"catch","z":"1f6b5f62.c79df1","name":"","scope":null,"x":100,"y":40,"wires":[["5fb5e66e.d8ebe8"]]},{"id":"65b3afb9.8d92","type":"telegram event","z":"1f6b5f62.c79df1","name":"","bot":"45ef79a0.ed7688","event":"inline_query","autoanswer":true,"x":110,"y":100,"wires":[["c7f9eaaa.0207c8"]]},{"id":"c7f9eaaa.0207c8","type":"function","z":"1f6b5f62.c79df1","name":"create results","func":"// we have to set the results propery with the answer(s)\n// see https://core.telegram.org/bots/api#inlinequeryresult\nvar results = [\n // result 1 is InlineQueryResultArticle\n {\n type : \"article\",\n id : \"1\",\n title : \"Result 1\",\n \n // InputTextMessageContent see https://core.telegram.org/bots/api#inputmessagecontent\n input_message_content : {\n message_text : \"The message 1\",\n parse_mode : \"Markdown\",\n disable_web_page_preview : true\n }\n },\n \n // result 2 is InlineQueryResultArticle\n {\n type : \"article\",\n id : \"2\",\n title : \"Result 2\",\n \n // InputTextMessageContent see https://core.telegram.org/bots/api#inputmessagecontent\n input_message_content : {\n message_text : \"The message 2\",\n parse_mode : \"Markdown\",\n disable_web_page_preview : false\n }\n }\n ];\n\n\nmsg.payload.results = results;\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":100,"wires":[["2c870509.1e08ca"]]},{"id":"2c870509.1e08ca","type":"telegram sender","z":"1f6b5f62.c79df1","name":"","bot":"45ef79a0.ed7688","x":590,"y":100,"wires":[[]]},{"id":"45ef79a0.ed7688","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","pollinterval":""}] -------------------------------------------------------------------------------- /examples/senddocumenttochat.json: -------------------------------------------------------------------------------- 1 | [{"id":"46b012eb.3634bc","type":"telegram sender","z":"ed43e0f7.31d9","name":"","bot":"fcc25e57.4073a","haserroroutput":false,"outputs":1,"x":510,"y":120,"wires":[["dbe8656.f963498"]]},{"id":"edd05cdc.ccba7","type":"inject","z":"ed43e0f7.31d9","name":"send csv string","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"a, b, c, d","payloadType":"str","x":120,"y":120,"wires":[["62a75af3.7db694"]]},{"id":"62a75af3.7db694","type":"function","z":"ed43e0f7.31d9","name":"send document","func":"var chatId = flow.get(\"chatId\");\n\nvar doc = Buffer.from(msg.payload);\n\nvar fileOptions = {\n filename : \"foo.csv\",\n contentType : \"text/csv\"\n}\n\nvar payload = {\n type: \"document\",\n chatId: chatId,\n content: doc,\n fileOptions : fileOptions\n}\n\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":120,"wires":[["46b012eb.3634bc"]]},{"id":"e25b5de9.7e1ca","type":"inject","z":"ed43e0f7.31d9","name":"once","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"-1001456177533","payloadType":"num","x":100,"y":40,"wires":[["fe6d2966.bcc568"]]},{"id":"fe6d2966.bcc568","type":"function","z":"ed43e0f7.31d9","name":"set chatId","func":"flow.set(\"chatId\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":40,"wires":[[]]},{"id":"dbe8656.f963498","type":"debug","z":"ed43e0f7.31d9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":120,"wires":[]},{"id":"fcc25e57.4073a","type":"telegram bot","botname":"TestBot","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}] -------------------------------------------------------------------------------- /examples/sendkeyboardtochat.json: -------------------------------------------------------------------------------- 1 | [{"id":"d69380f4.8f204","type":"function","z":"3068ac13.951064","name":"create response","func":"if(context.global.keyboard.pending)\n{\n context.global.keyboard.pending = false;\n \n if(msg.payload.content === 'Yes')\n {\n msg.payload.content = 'Yes';\n return [msg, null]; \n }\n else\n {\n msg.payload.content = 'No';\n return [null, msg]; \n }\n}\n","outputs":"2","noerr":0,"x":335.0000457763672,"y":135.0000343322754,"wires":[["c9c5ff32.8db61"],[]]},{"id":"c9c5ff32.8db61","type":"telegram sender","z":"3068ac13.951064","name":"sender","bot":"6cc03fc7.9b8fb","x":529.0000991821289,"y":108.0000228881836,"wires":[[]]},{"id":"44bd3c3f.c0a614","type":"inject","z":"3068ac13.951064","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":99.16667175292969,"y":43,"wires":[["a293fe2.aa058"]]},{"id":"e936d5da.8433f8","type":"telegram receiver","z":"3068ac13.951064","name":"receiver","bot":"6cc03fc7.9b8fb","saveDataDir":"","x":89.16667175292969,"y":140.33334732055664,"wires":[["d69380f4.8f204"],[]]},{"id":"a293fe2.aa058","type":"function","z":"3068ac13.951064","name":"create keyboard message","func":"// Here you must adapt the chatId.\nvar chatId = 123;\n\ncontext.global.keyboard = { pending : true };\n\nvar opts = {\n reply_to_message_id: 0,\n reply_markup: JSON.stringify({\n keyboard: [\n ['Yes'],\n ['No']],\n 'resize_keyboard' : true, \n 'one_time_keyboard' : true\n })\n};\n\nvar payload = {\n chatId : chatId,\n type : 'message',\n content : 'Really?',\n options : opts,\n};\n\n\nmsg.payload = payload;\nreturn [ msg ];","outputs":1,"noerr":0,"x":304.16668701171875,"y":44,"wires":[["c9c5ff32.8db61"]]},{"id":"6cc03fc7.9b8fb","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"Windhose","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"verboselogging":false}] -------------------------------------------------------------------------------- /examples/basiccustomkeyboard.json: -------------------------------------------------------------------------------- 1 | [{"id":"80211883.fcf5f","type":"telegram receiver","z":"c8b50aaa.e632d","name":"","bot":"2db9661a.cf3b0a","saveDataDir":"","filterCommands":false,"x":250,"y":1262,"wires":[["d719b18b.da75f8"],[]]},{"id":"d719b18b.da75f8","type":"debug","z":"c8b50aaa.e632d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":430,"y":1262,"wires":[]},{"id":"cd98abdd.e338f","type":"inject","z":"c8b50aaa.e632d","name":"","props":[{"p":"payload.content","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":230,"y":1160,"wires":[["2c2e5956.54b846"]]},{"id":"c8a8015.60267","type":"telegram sender","z":"c8b50aaa.e632d","name":"","bot":"2db9661a.cf3b0a","x":730,"y":1160,"wires":[[]]},{"id":"2c2e5956.54b846","type":"function","z":"c8b50aaa.e632d","name":"build keyboard","func":"var opts = {\n reply_markup: JSON.stringify({\n keyboard: [\n ['A1'],\n ['A2']],\n 'resize_keyboard' : true, \n 'one_time_keyboard' : true\n })\n};\n\n\nmsg.error = false;\n// Dialogaufbau\nmsg.payload.content = 'Selection?';\nmsg.payload.options = opts;\n\n\nmsg.payload.chatId = 123445;\nmsg.payload.messageId = 99;\nmsg.payload.sentMessageId = 99;\nmsg.payload.type = \"message\";\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":470,"y":1160,"wires":[["c8a8015.60267","17b67c4e.c4738c"]]},{"id":"17b67c4e.c4738c","type":"debug","z":"c8b50aaa.e632d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":1220,"wires":[]},{"id":"4f9f29f7.8abc78","type":"comment","z":"c8b50aaa.e632d","name":"Custom keyboard: Reply with \"Telegram receiver\"","info":"","x":370,"y":1102,"wires":[]},{"id":"2db9661a.cf3b0a","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}] 2 | -------------------------------------------------------------------------------- /examples/keyboard.json: -------------------------------------------------------------------------------- 1 | [{"id":"e8ce557a.c772a8","type":"catch","z":"117ca2b6.9952d5","name":"","x":240,"y":2540,"wires":[["cd3e5352.717538"]]},{"id":"cd3e5352.717538","type":"debug","z":"117ca2b6.9952d5","name":"Debug","active":false,"console":"false","complete":"payload","x":700,"y":2540,"wires":[]},{"id":"cfe3317f.d2ce7","type":"telegram sender","z":"117ca2b6.9952d5","name":"show keyboard","bot":"d086776c.7de82","x":730,"y":2380,"wires":[[]]},{"id":"db28aeae.a44ba8","type":"function","z":"117ca2b6.9952d5","name":"confirmation message","func":"context.global.keyboard = { pending : true };\n\nvar opts = {\n reply_to_message_id: msg.payload.messageId,\n reply_markup: JSON.stringify({\n keyboard: [\n ['Yes'],\n ['No']],\n 'resize_keyboard' : true, \n 'one_time_keyboard' : true\n })\n};\n\nmsg.payload.content = 'Really?';\nmsg.payload.options = opts;\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":470,"y":2380,"wires":[["cfe3317f.d2ce7"]]},{"id":"cc400aac.97c5f8","type":"telegram command","z":"117ca2b6.9952d5","name":"/foo","command":"/foo","bot":"d086776c.7de82","strict":false,"hasresponse":true,"x":230,"y":2420,"wires":[["db28aeae.a44ba8"],["469a1a73.b143cc"]]},{"id":"469a1a73.b143cc","type":"function","z":"117ca2b6.9952d5","name":"create response","func":"if (context.global.keyboard.pending) {\n context.global.keyboard.pending = false;\n \n if(msg.payload.content === 'Yes') {\n msg.payload.content = 'Yes';\n return [msg, null]; \n }\n else {\n msg.payload.content = 'No';\n return [null, msg]; \n }\n}","outputs":"2","noerr":0,"initialize":"","finalize":"","x":450,"y":2460,"wires":[["d044e1c5.953458"],["cd3e5352.717538"]]},{"id":"d044e1c5.953458","type":"telegram sender","z":"117ca2b6.9952d5","name":"send response","bot":"d086776c.7de82","x":720,"y":2440,"wires":[[]]},{"id":"d086776c.7de82","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}] 2 | -------------------------------------------------------------------------------- /examples/command2.json: -------------------------------------------------------------------------------- 1 | [{"id":"d6d9ccd1.801f6","type":"telegram command","z":"c70c2a9e.b44248","name":"fly","command":"/fly","description":"fly","registercommand":true,"language":"en","bot":"c6c7223.f86e7e","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":150,"y":180,"wires":[["7313e4b1.71c23c"],[]]},{"id":"7313e4b1.71c23c","type":"debug","z":"c70c2a9e.b44248","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":410,"y":180,"wires":[]},{"id":"44b84a66.0f9c54","type":"telegram command","z":"c70c2a9e.b44248","name":"flieg","command":"/flieg","description":"flieg","registercommand":true,"language":"de","bot":"c6c7223.f86e7e","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":150,"y":240,"wires":[["c8ce8fe9.0cd4e"],[]]},{"id":"c8ce8fe9.0cd4e","type":"debug","z":"c70c2a9e.b44248","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":410,"y":240,"wires":[]},{"id":"857af061.cdfaf","type":"telegram command","z":"c70c2a9e.b44248","name":" mouche","command":"/ mouche","description":" mouche","registercommand":true,"language":"fr","bot":"c6c7223.f86e7e","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":150,"y":300,"wires":[["ccf2de10.6c27e"],[]]},{"id":"ccf2de10.6c27e","type":"debug","z":"c70c2a9e.b44248","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":410,"y":300,"wires":[]},{"id":"806c23f5.6a583","type":"comment","z":"c70c2a9e.b44248","name":"The same command in three different languages.","info":"/fly as english with empty language en \n\n/flieg in german with language code de\n\n/mouche in french with language code fr\n","x":280,"y":100,"wires":[]},{"id":"c6c7223.f86e7e","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}] -------------------------------------------------------------------------------- /examples/externalreceiver1.json: -------------------------------------------------------------------------------- 1 | [{"id":"2d5c9313bbf6bd50","type":"telegram receiver","z":"f9295af027c7e5e7","name":"","bot":"65ca12172854cc2d","saveDataDir":"","filterCommands":false,"hasinput":true,"inputs":1,"x":750,"y":560,"wires":[["1b2188ae52d7c9df"],[]]},{"id":"1b2188ae52d7c9df","type":"debug","z":"f9295af027c7e5e7","name":"debug 55","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":940,"y":560,"wires":[]},{"id":"544b9de355a4db12","type":"inject","z":"f9295af027c7e5e7","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":560,"wires":[["3ad636d773fcffd7"]]},{"id":"3ad636d773fcffd7","type":"function","z":"f9295af027c7e5e7","name":"create sample update","func":"// Note that payload is an array, which means you can inject more than one update at a time.\n// However you can also send single updates as an alternative.\nmsg.payload = [{\n \"update_id\": 123,\n \"message\": {\n \"message_id\": 123,\n \"from\": {\n \"id\": 123,\n \"is_bot\": false,\n \"first_name\": \"Bigfoot\",\n \"last_name\": \"Yeti\",\n \"username\": \"Bigfoot\",\n \"language_code\": \"en\"\n },\n \"chat\": {\n \"id\": 123,\n \"first_name\": \"Bigfoot\",\n \"last_name\": \"Yeti\",\n \"username\": \"Bigfoot\",\n \"type\": \"private\"\n },\n \"date\": 1763891508,\n \"text\": \"Hello guys\"\n }\n}]\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":560,"wires":[["2d5c9313bbf6bd50"]]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","testenvironment":false,"updatemode":"none","addressfamily":"","pollinterval":"1000","usesocks":false,"sockshost":"192.168.178.200","socksprotocol":"socks4","socksport":"1080","socksusername":"user","sockspassword":"password","bothost":"ihive.spdns.de","botpath":"","localbothost":"127.0.0.1","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":true,"verboselogging":false}] -------------------------------------------------------------------------------- /examples/sendinvoice.json: -------------------------------------------------------------------------------- 1 | [{"id":"20955c6ff3a72337","type":"telegram command","z":"5c2564baa1f544ec","name":"","command":"/buy","description":"","registercommand":false,"language":"","bot":"65ca12172854cc2d","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":170,"y":140,"wires":[["d696a2fcc65ee1b9"],[]]},{"id":"d696a2fcc65ee1b9","type":"function","z":"5c2564baa1f544ec","name":"send invoice","func":"// Invoice Information see https://core.telegram.org/bots/api#sendinvoice\nmsg.payload.type = \"sendInvoice\";\n\nmsg.payload.content = {\n    title : \"Your title here\",\n    description : \"Your description here\",\n    payload : \"some private field\",\n    providerToken: \"the token from your bank\",\n    currency: \"EUR\", // see https://core.telegram.org/bots/payments#supported-currencies\n    prices : [ {\n        label: \"Price\",\n        amount : 12300 } ], //12300 this is 123.00EUR\n}\n\n// Optional\n// msg.payload.options\n//    provider_data\n//    photo_url\n//    photo_size\n//    photo_width\n//    photo_height\n//    need_name\n//    need_phone_number\n//    need_email\n//    need_shipping_address\n//    send_phone_number_to_provider\n//    send_email_to_provider\n//    is_flexible\n//    disable_notification\n//    reply_to_message_id\n//    reply_markup\n\nmsg.payload.options = {\n    reply_to_message_id : msg.payload.messageId,\n    need_name : false,\n    need_phone_number : false,\n    need_email : false,\n    is_flexible : false,\n    protect_content: false\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":140,"wires":[["5c37c75d438debfa"]]},{"id":"5c37c75d438debfa","type":"telegram sender","z":"5c2564baa1f544ec","name":"","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":630,"y":140,"wires":[["1f26627e93b7e04f"]]},{"id":"1f26627e93b7e04f","type":"debug","z":"5c2564baa1f544ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":140,"wires":[]},{"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":false,"verboselogging":false}] -------------------------------------------------------------------------------- /examples/webappdata.json: -------------------------------------------------------------------------------- 1 | [{"id":"75c35f9c5a3311e2","type":"telegram receiver","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","saveDataDir":"","filterCommands":false,"x":190,"y":180,"wires":[["6dcc7cba5e039545"],[]]},{"id":"6dcc7cba5e039545","type":"debug","z":"ec1cf3fd9654e7e5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":390,"y":180,"wires":[]},{"id":"e6c4ec0e9fed9c4a","type":"telegram sender","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":550,"y":240,"wires":[[]]},{"id":"6ec2de9f5dd9876a","type":"function","z":"ec1cf3fd9654e7e5","name":"","func":"var chatId = msg.payload.chatId;\n\nmsg.payload={\n reply_to_message_id: msg.payload.messageId,\n type: \"message\",\n content: \"Managing stuff..\",\n chatId: chatId,\n options: {\n reply_markup: JSON.stringify({\n keyboard:[\n [\n {\n \"text\": \"Managing stuff..\",\n \"web_app\": {\n \"url\":\"https://www.wind.li/test.html?\" + Math.random()\n }\n }\n ]\n ]\n })\n }\n };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":240,"wires":[["e6c4ec0e9fed9c4a"]]},{"id":"4d6829fc9dbe05ee","type":"telegram command","z":"ec1cf3fd9654e7e5","name":"","command":"/foo","description":"","registercommand":false,"language":"","scope":"default","bot":"65ca12172854cc2d","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":150,"y":240,"wires":[["6ec2de9f5dd9876a"],[]]},{"id":"6142734b9a08b890","type":"comment","z":"ec1cf3fd9654e7e5","name":"Example WebApp for your public web server","info":" \n","x":270,"y":120,"wires":[]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"3000","usesocks":false,"sockshost":"","socksprotocol":"socks5","socksport":"","socksusername":"","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/inlinekeyboard.json: -------------------------------------------------------------------------------- 1 | [{"id":"a18dc3fa.71502","type":"debug","z":"8436a552.ae1f78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":410,"y":260,"wires":[]},{"id":"a9816fa8.102ee","type":"catch","z":"8436a552.ae1f78","name":"","scope":null,"x":160,"y":260,"wires":[["a18dc3fa.71502"]]},{"id":"9666af3d.3da7e","type":"telegram event","z":"8436a552.ae1f78","name":"","bot":"c3670dce.18aa8","event":"callback_query","autoanswer":true,"x":180,"y":320,"wires":[["92ee3303.4cd04"]]},{"id":"78034690.513038","type":"telegram sender","z":"8436a552.ae1f78","name":"show inline keyboard","bot":"c3670dce.18aa8","x":720,"y":400,"wires":[[]]},{"id":"74e8cf35.a5ba8","type":"function","z":"8436a552.ae1f78","name":"inline keyboard message","func":"var 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 = 'Are you sure?';\nmsg.payload.options = opts;\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"x":450,"y":400,"wires":[["78034690.513038"]]},{"id":"67692ad7.9de0d4","type":"telegram command","z":"8436a552.ae1f78","name":"/foo","command":"/foo","bot":"c3670dce.18aa8","strict":false,"hasresponse":false,"x":150,"y":400,"wires":[["74e8cf35.a5ba8"]]},{"id":"92ee3303.4cd04","type":"function","z":"8436a552.ae1f78","name":"set answer options","func":"var show_alert = false; // 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","outputs":"1","noerr":0,"x":430,"y":320,"wires":[["18bd53db.5ba47c"]]},{"id":"18bd53db.5ba47c","type":"telegram sender","z":"8436a552.ae1f78","name":"answer callback query","bot":"c3670dce.18aa8","x":720,"y":320,"wires":[[]]},{"id":"c3670dce.18aa8","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/createpoll.json: -------------------------------------------------------------------------------- 1 | [{"id":"29f1d57e.66b52a","type":"telegram sender","z":"7652eee0.6d11b","name":"","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":790,"y":40,"wires":[[]]},{"id":"aeb4e2e8.ee8b","type":"telegram event","z":"7652eee0.6d11b","name":"Poll","bot":"5f67fb38.18d094","event":"poll","autoanswer":false,"x":190,"y":360,"wires":[["78b59b12.6793e4"]]},{"id":"1e912334.8a1d2d","type":"telegram receiver","z":"7652eee0.6d11b","name":"","bot":"5f67fb38.18d094","saveDataDir":"","filterCommands":false,"x":230,"y":260,"wires":[["78b59b12.6793e4","29f1d57e.66b52a"],[]]},{"id":"78b59b12.6793e4","type":"debug","z":"7652eee0.6d11b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":300,"wires":[]},{"id":"2bab010d.920a9e","type":"telegram event","z":"7652eee0.6d11b","name":"Poll Answer","bot":"5f67fb38.18d094","event":"poll_answer","autoanswer":false,"x":210,"y":440,"wires":[["78b59b12.6793e4"]]},{"id":"75a3afbd.a59c8","type":"telegram command","z":"7652eee0.6d11b","name":"","command":"/newpoll1","bot":"5f67fb38.18d094","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":200,"y":40,"wires":[["c50749bf.376108"],[]]},{"id":"c50749bf.376108","type":"function","z":"7652eee0.6d11b","name":"create poll","func":"msg.payload.type = 'poll';\nmsg.payload.content = \"What do you think?\";\nmsg.payload.options = [\"A\", \"B\", \"C\" ];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":40,"wires":[["29f1d57e.66b52a"]]},{"id":"6a2b097c.bc1428","type":"telegram command","z":"7652eee0.6d11b","name":"","command":"/newpoll2","bot":"5f67fb38.18d094","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":200,"y":120,"wires":[["b2033371.73ece"],[]]},{"id":"b2033371.73ece","type":"function","z":"7652eee0.6d11b","name":"create poll with optional arguments","func":"msg.payload.type = 'poll';\nmsg.payload.content = \"What do you think?\";\nmsg.payload.options = [\"A\", \"B\", \"C\" ];\n\n// you can add optional arguments see\n// https://core.telegram.org/bots/api#sendpoll\nmsg.payload.optional = {\n allows_multiple_answers : true\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":100,"wires":[["29f1d57e.66b52a"]]},{"id":"5f67fb38.18d094","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}] -------------------------------------------------------------------------------- /examples/basicinlinekeyboard.json: -------------------------------------------------------------------------------- 1 | [{"id":"f7c18f49.063c4","type":"telegram sender","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","haserroroutput":false,"outputs":1,"x":670,"y":420,"wires":[[]]},{"id":"f97878f7.de1bf8","type":"function","z":"ec1cf3fd9654e7e5","name":"build keyboard","func":"var opts = {\n reply_markup: JSON.stringify({\n \"inline_keyboard\": [[\n {\n \"text\": \"A1\",\n \"callback_data\": \"1\" \n }, \n {\n \"text\": \"A2\",\n \"callback_data\": \"2\" \n }]\n ]\n })\n};\n\nmsg.payload.content = \"Selection?\";\nmsg.payload.options = opts;\nmsg.payload.chatId = 138708568;\nmsg.payload.messageId = 29;\nmsg.payload.sentMessageId = 29;\nmsg.payload.type = \"message\";\n\nreturn [ msg ];\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":420,"wires":[["f7c18f49.063c4","67925ff5.4c7c9"]]},{"id":"67925ff5.4c7c9","type":"debug","z":"ec1cf3fd9654e7e5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":380,"wires":[]},{"id":"e1a6a394.269598","type":"inject","z":"ec1cf3fd9654e7e5","name":"","props":[{"p":"payload.content","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":170,"y":420,"wires":[["f97878f7.de1bf8"]]},{"id":"981d4537.1ced18","type":"telegram event","z":"ec1cf3fd9654e7e5","name":"","bot":"65ca12172854cc2d","event":"callback_query","autoanswer":false,"x":180,"y":502,"wires":[["385615779f4b3364"]]},{"id":"93430912.0f4f4","type":"comment","z":"ec1cf3fd9654e7e5","name":"Inline keyboard: Reply with \"callback_query\"","info":"","x":290,"y":362,"wires":[]},{"id":"385615779f4b3364","type":"function","z":"ec1cf3fd9654e7e5","name":"answerCallbackQuery","func":"var text = \"You clicked \" + msg.payload.content;\nvar options = {\n // text : text, <-- you can set the text here or use msg.payload.content \n show_alert : true,\n cache_time : 10\n};\n\nmsg.payload.content = text;\nmsg.payload.options = options;\nmsg.payload.type = \"answerCallbackQuery\";\n\nreturn [ msg ];\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":500,"wires":[["f7c18f49.063c4"]]},{"id":"65ca12172854cc2d","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}] -------------------------------------------------------------------------------- /examples/editMessageText.json: -------------------------------------------------------------------------------- 1 | [{"id":"edcf10da.82f94","type":"telegram sender","z":"7652eee0.6d11b","name":"send initial message","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":642.7594223022461,"y":133.3033103942871,"wires":[["db8e5a96.69f8f8"]]},{"id":"d338f266.95ff8","type":"function","z":"7652eee0.6d11b","name":"original message","func":"msg.payload.type = 'message'\nmsg.payload.content = 'The original message';\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":341.7592468261719,"y":134.3032283782959,"wires":[["edcf10da.82f94"]]},{"id":"8c682765.b34cf8","type":"telegram command","z":"7652eee0.6d11b","name":"/foo","command":"/foo","bot":"5f67fb38.18d094","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":162.75931549072266,"y":140.3032102584839,"wires":[["d338f266.95ff8"]]},{"id":"ad64ec3d.4d2b4","type":"telegram sender","z":"7652eee0.6d11b","name":"","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":630,"y":240,"wires":[["3499a9a6.8ae146"]]},{"id":"3dc83d60.7cbcc2","type":"function","z":"7652eee0.6d11b","name":"modified message","func":"var messageId = context.global.messageId;\nvar chatId = context.global.chatId;\n\nvar options = {\n chat_id : chatId,\n message_id : messageId\n};\n\nmsg.payload = {\n type : 'editMessageText',\n content : \"The modified message\",\n options : options,\n}\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":350,"y":240,"wires":[["ad64ec3d.4d2b4"]]},{"id":"db8e5a96.69f8f8","type":"function","z":"7652eee0.6d11b","name":"save IDs","func":"// We store the messageId to be able to edit this reply in the callback query. \ncontext.global.messageId = msg.payload.sentMessageId;\ncontext.global.chatId = msg.payload.chatId;\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":840.6667861938477,"y":133.6667127609253,"wires":[[]]},{"id":"3499a9a6.8ae146","type":"debug","z":"7652eee0.6d11b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":240,"wires":[]},{"id":"b55fa9d6.a7e438","type":"inject","z":"7652eee0.6d11b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":170,"y":240,"wires":[["3dc83d60.7cbcc2"]]},{"id":"5f67fb38.18d094","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}] -------------------------------------------------------------------------------- /examples/editMessageCaption.json: -------------------------------------------------------------------------------- 1 | [{"id":"ca63e749.f0e1f8","type":"telegram sender","z":"7652eee0.6d11b","name":"send initial message","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":620,"y":100,"wires":[["5c718b42.c971d4"]]},{"id":"b613abd7.8bda68","type":"telegram command","z":"7652eee0.6d11b","name":"/foo","command":"/foo","bot":"5f67fb38.18d094","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":130,"y":100,"wires":[["5be9089.9ff5ff8"]]},{"id":"5ebcc0ff.a1205","type":"telegram sender","z":"7652eee0.6d11b","name":"","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":607.2405776977539,"y":206.6966896057129,"wires":[["ffecee00.85cf3"]]},{"id":"a3dfc497.3dd828","type":"function","z":"7652eee0.6d11b","name":"modified message","func":"var messageId = context.global.messageId;\nvar chatId = context.global.chatId;\n\nvar options = {\n chat_id : chatId,\n message_id : messageId\n};\n\nmsg.payload = {\n type : 'editMessageCaption',\n content : \"The modified caption\",\n options : options,\n}\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":327.2405776977539,"y":206.6966896057129,"wires":[["5ebcc0ff.a1205"]]},{"id":"5c718b42.c971d4","type":"function","z":"7652eee0.6d11b","name":"save IDs","func":"// We store the messageId to be able to edit this reply in the callback query. \ncontext.global.messageId = msg.payload.sentMessageId;\ncontext.global.chatId = msg.payload.chatId;\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":817.9073638916016,"y":100.36340236663818,"wires":[[]]},{"id":"ffecee00.85cf3","type":"debug","z":"7652eee0.6d11b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":827.2405776977539,"y":206.6966896057129,"wires":[]},{"id":"b1c82a24.f874f8","type":"inject","z":"7652eee0.6d11b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":147.2405776977539,"y":206.6966896057129,"wires":[["a3dfc497.3dd828"]]},{"id":"5be9089.9ff5ff8","type":"function","z":"7652eee0.6d11b","name":"original message","func":"// content can be a file_id, url, local path...\nmsg.payload.content = 'https://www.cleverfiles.com/howto/wp-content/uploads/2018/03/minion.jpg';\nmsg.payload.type = 'photo';\nmsg.payload.caption = \"super cool\"\n\n/* type can be one of the following\nphoto\naudio\nvideo\nsticker\nvoice\ndocument\n*/\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":100,"wires":[["ca63e749.f0e1f8"]]},{"id":"5f67fb38.18d094","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}] -------------------------------------------------------------------------------- /examples/dynamicauthorization.json: -------------------------------------------------------------------------------- 1 | [{"id":"ee5ccada.43f59","type":"telegram sender","z":"117ca2b6.9952d5","name":"","bot":"","x":570,"y":380,"wires":[[]]},{"id":"aa3d783b.53061","type":"telegram receiver","z":"117ca2b6.9952d5","name":"","bot":"","saveDataDir":"c:\\temp\\foo","filterCommands":false,"x":290,"y":420,"wires":[["3fe23b0b.35503c","ee5ccada.43f59"],[]]},{"id":"3fe23b0b.35503c","type":"debug","z":"117ca2b6.9952d5","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":560,"y":440,"wires":[]},{"id":"7b3b2aee.330974","type":"inject","z":"117ca2b6.9952d5","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":680,"wires":[["c140074e.b4b44"]]},{"id":"c140074e.b4b44","type":"function","z":"117ca2b6.9952d5","name":"No Access","func":"// classic aproach for using context.\ncontext.global.usernames = [];\ncontext.global.chatids = [];\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":680,"wires":[[]]},{"id":"cd683e65.cff7b8","type":"inject","z":"117ca2b6.9952d5","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":720,"wires":[["72b7bffd.9a79"]]},{"id":"72b7bffd.9a79","type":"function","z":"117ca2b6.9952d5","name":"Grant access to User and chat 1","func":"// classic aproach for using context.\ncontext.global.usernames = [ \"User\" ];\ncontext.global.chatids = [ 1 ];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":570,"y":720,"wires":[[]]},{"id":"d9d3a4c6.9ed7f","type":"change","z":"117ca2b6.9952d5","name":"Grant access to Sepp and Egon","rules":[{"t":"set","p":"usernames","pt":"global","to":"[\"Sepp\", \"Egon\"]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":620,"wires":[[]]},{"id":"6929b4a6.06892c","type":"inject","z":"117ca2b6.9952d5","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":620,"wires":[["d9d3a4c6.9ed7f"]]},{"id":"fa9290c0.e55dc","type":"change","z":"117ca2b6.9952d5","name":"No Access","rules":[{"t":"set","p":"usernames","pt":"global","to":"[\"Sepp\", \"Egon\"]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":580,"wires":[[]]},{"id":"6eebcb8a.ae350c","type":"inject","z":"117ca2b6.9952d5","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":580,"wires":[["fa9290c0.e55dc"]]},{"id":"5615bf9b.6e0f38","type":"comment","z":"117ca2b6.9952d5","name":"","info":"You can make use of the context in two ways:\n1. context.global.key = value\n2. global.set(key, value)\n\nOnly the latter one can be seen in the context browser window while the first is only stored as variable in memory.\n\nThe config node must be configured as follows:\n1. {context.global.hereyourkey} for approach one\n2. {gobal.get(\"hereyoukey\")} for approach two\n\nIf the config starts with { and ends with } the expression is evaluated as script.\n\nIn this example you can write\n{context.global.username}\n{context.global.chatids}\n\nor \n{global.get(\"usernames\")}\n{global.get(\"chatids\")}\n\nI would recommend the latter one.\n","x":260,"y":520,"wires":[]}] 2 | -------------------------------------------------------------------------------- /examples/externalreceiver2.json: -------------------------------------------------------------------------------- 1 | [{"id":"21e19a0e7b231297","type":"telegram receiver","z":"5bf8995c5bcae0bd","name":"","bot":"65ca12172854cc2d","saveDataDir":"","filterCommands":false,"hasinput":true,"inputs":1,"x":790,"y":320,"wires":[["31b70ebc109e1528"],[]]},{"id":"31b70ebc109e1528","type":"debug","z":"5bf8995c5bcae0bd","name":"debug 56","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":980,"y":320,"wires":[]},{"id":"55179d7f45e11a59","type":"http request","z":"5bf8995c5bcae0bd","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":true,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":570,"y":280,"wires":[["d3ea80fac1a34577","21e19a0e7b231297","4907bf64279072ba"]]},{"id":"d3ea80fac1a34577","type":"debug","z":"5bf8995c5bcae0bd","name":"debug 57","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":980,"y":260,"wires":[]},{"id":"925ad86cbee184a6","type":"inject","z":"5bf8995c5bcae0bd","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":280,"wires":[["20f92b7829f272e3"]]},{"id":"20f92b7829f272e3","type":"function","z":"5bf8995c5bcae0bd","name":"create request","func":"let offset = flow.get(\"offset\");\nlet timeout = 10;\nlet token = \"\";\nmsg.method = \"POST\";\nmsg.url = \"https://api.telegram.org/bot\" + token + \"/getUpdates?offset=\"+offset+\"&timeout=\" + timeout;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":280,"wires":[["55179d7f45e11a59","13c46adfbf916ea0"]]},{"id":"4907bf64279072ba","type":"function","z":"5bf8995c5bcae0bd","name":"update offset","func":"if(msg.payload.ok === true) {\n let msgOffset = msg.payload.result.length - 1;\n if(msgOffset >= 0) {\n let offset = msg.payload.result[msgOffset].update_id + 1;\n flow.set(\"offset\", offset);\n }\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":220,"wires":[["20f92b7829f272e3"]]},{"id":"13c46adfbf916ea0","type":"debug","z":"5bf8995c5bcae0bd","name":"debug 58","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":340,"wires":[]},{"id":"726a7e63c79777fc","type":"inject","z":"5bf8995c5bcae0bd","name":"Initialization","props":[],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":210,"y":180,"wires":[["04a640784be8d59c"]]},{"id":"04a640784be8d59c","type":"function","z":"5bf8995c5bcae0bd","name":"initialize offset","func":"flow.set(\"offset\", 0)\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":180,"wires":[[]]},{"id":"65ca12172854cc2d","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","testenvironment":false,"updatemode":"none","addressfamily":"","pollinterval":"1000","usesocks":false,"sockshost":"192.168.178.200","socksprotocol":"socks4","socksport":"1080","socksusername":"user","sockspassword":"password","bothost":"ihive.spdns.de","botpath":"","localbothost":"127.0.0.1","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":true,"verboselogging":false}] -------------------------------------------------------------------------------- /examples/sendphotobuffer.json: -------------------------------------------------------------------------------- 1 | [{"id":"99ee972c.22d088","type":"telegram sender","z":"84387cfd03f1f8f5","name":"","bot":"3b6bfbc0.423a04","haserroroutput":false,"outputs":1,"x":890,"y":540,"wires":[["72b71335.355a9c"]]},{"id":"58e78fc.dd0b27","type":"telegram command","z":"84387cfd03f1f8f5","name":"/fromfile","command":"/fromfile","description":"","registercommand":false,"language":"","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":170,"y":540,"wires":[["7c8090ca.00c02"]]},{"id":"72b71335.355a9c","type":"debug","z":"84387cfd03f1f8f5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":540,"wires":[]},{"id":"2058d729.1a3a48","type":"function","z":"84387cfd03f1f8f5","name":"send image","func":"var buffer = msg.payload;\nvar payload = {\n content: buffer,\n message: `The requested image`,\n type : 'photo',\n chatId: msg.originalMessage.chat.id,\n chat: msg.originalMessage.chat,\n from: msg.originalMessage.from,\n message_id : msg.originalMessage.message_id\n}\n\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":540,"wires":[["99ee972c.22d088"]]},{"id":"959c0404.742708","type":"image","z":"84387cfd03f1f8f5","name":"","width":160,"data":"payload","dataType":"msg","thumbnail":false,"active":true,"outputs":1,"x":700,"y":620,"wires":[[]]},{"id":"7c8090ca.00c02","type":"file in","z":"84387cfd03f1f8f5","name":"image from file","filename":"C:\\temp\\test.jpg","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":460,"y":540,"wires":[["2058d729.1a3a48","959c0404.742708"]]},{"id":"dec15032.19344","type":"http request","z":"84387cfd03f1f8f5","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"https://picsum.photos/200/300","tls":"","persist":false,"proxy":"","authType":"","x":470,"y":620,"wires":[["959c0404.742708","2058d729.1a3a48"]]},{"id":"db7296d38fa309cf","type":"telegram command","z":"84387cfd03f1f8f5","name":"/frominternet","command":"/frominternet","description":"","registercommand":false,"language":"","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":190,"y":620,"wires":[["dec15032.19344"]]},{"id":"2da41ceac90ece65","type":"comment","z":"84387cfd03f1f8f5","name":"","info":"# Flow demonstrates sending a photo as buffer.\nAs few people do not know that image files can also be sent directly from within memory this example flow was created.\nThe complete description can be found here:\nhttps://core.telegram.org/bots/api#sending-files\n\n## pic1\nFile is loaded from a local file and sent as buffer.\n\n## pic2\nFile is downloaded from internet and directly sent as buffer.\n\nCredits:\nflow was derived from see also:\nhttps://discourse.nodered.org/t/taking-a-picture-and-sending-it-via-telegram/27905/4\n","x":180,"y":460,"wires":[]},{"id":"3b6bfbc0.423a04","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}] -------------------------------------------------------------------------------- /examples/triggerCommandFromControlNode.json: -------------------------------------------------------------------------------- 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":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":true,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/errorhandling.json: -------------------------------------------------------------------------------- 1 | [{"id":"fbcbaf0f.1a4c3","type":"catch","z":"f86d9fd2.9f14c","name":"","scope":null,"uncaught":false,"x":156,"y":140,"wires":[["dab98e0e.f83fb"]]},{"id":"cc0d5363.33275","type":"telegram sender","z":"f86d9fd2.9f14c","name":"","bot":"b5326aaf.cdbb18","haserroroutput":false,"outputs":1,"x":390,"y":200,"wires":[["8a49c6d5.37ccf8"]]},{"id":"80ba48a1.4af1e8","type":"debug","z":"f86d9fd2.9f14c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":570,"y":400,"wires":[]},{"id":"8a49c6d5.37ccf8","type":"debug","z":"f86d9fd2.9f14c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":200,"wires":[]},{"id":"dab98e0e.f83fb","type":"debug","z":"f86d9fd2.9f14c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":336,"y":140,"wires":[]},{"id":"fc55722d.e837c","type":"inject","z":"f86d9fd2.9f14c","name":"error","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"chatId\":\"138708568\",\"type\":\"action\",\"content\":\"This will be handled by the catch-all error node.\"}","payloadType":"json","x":156,"y":200,"wires":[["cc0d5363.33275"]]},{"id":"35318513.23421a","type":"inject","z":"f86d9fd2.9f14c","name":"error","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"chatId\":\"138708568\",\"type\":\"action\",\"content\":\"This will be handled by the second output of the sender node.\"}","payloadType":"json","x":156,"y":380,"wires":[["ff53180b.fc6bf8"]]},{"id":"ff53180b.fc6bf8","type":"telegram sender","z":"f86d9fd2.9f14c","name":"","bot":"b5326aaf.cdbb18","haserroroutput":true,"outputs":2,"x":390,"y":380,"wires":[["cfb0ed56.6673"],["80ba48a1.4af1e8"]]},{"id":"cfb0ed56.6673","type":"debug","z":"f86d9fd2.9f14c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":360,"wires":[]},{"id":"6a07e213.40bd6c","type":"comment","z":"f86d9fd2.9f14c","name":"Example 1: errors are handled in \"catch all\"","info":"","x":256,"y":100,"wires":[]},{"id":"33a85a47.7ed9d6","type":"comment","z":"f86d9fd2.9f14c","name":"Example 2: errors are handled using second output","info":"","x":290,"y":340,"wires":[]},{"id":"8ab80062.2a838","type":"inject","z":"f86d9fd2.9f14c","name":"success","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"chatId\":\"138708568\",\"type\":\"message\",\"content\":\"This should be successful.\"}","payloadType":"json","x":160,"y":240,"wires":[["cc0d5363.33275"]]},{"id":"39defe26.6a5382","type":"inject","z":"f86d9fd2.9f14c","name":"success","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"chatId\":\"138708568\",\"type\":\"message\",\"content\":\"This should be successful.\"}","payloadType":"json","x":160,"y":420,"wires":[["ff53180b.fc6bf8"]]},{"id":"b5326aaf.cdbb18","type":"telegram bot","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}] -------------------------------------------------------------------------------- /examples/simplebot.json: -------------------------------------------------------------------------------- 1 | [{"id":"a42b2347.05b25","type":"catch","z":"8436a552.ae1f78","name":"","x":160,"y":680,"wires":[["bd03654d.09ecb8"]]},{"id":"bd03654d.09ecb8","type":"debug","z":"8436a552.ae1f78","name":"Debug","active":true,"console":"false","complete":"payload","x":596,"y":678,"wires":[]},{"id":"614d1cf1.695f64","type":"function","z":"8436a552.ae1f78","name":"confirmation message","func":"var opts = {\n reply_to_message_id: msg.payload.messageId,\n reply_markup: JSON.stringify({\n keyboard: [\n ['Yes'],\n ['No']],\n 'resize_keyboard' : true, \n 'one_time_keyboard' : true\n })\n};\n\nmsg.payload.content = 'Really?';\nmsg.payload.options = opts;\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"x":391,"y":251,"wires":[["9e138687.ee43a8"]]},{"id":"93c8fa9f.7a1138","type":"telegram command","z":"8436a552.ae1f78","name":"/foo","command":"/foo","bot":"c3670dce.18aa8","strict":false,"hasresponse":true,"x":174,"y":304,"wires":[["614d1cf1.695f64"],["4e1d3979.e32fa8"]]},{"id":"4e1d3979.e32fa8","type":"function","z":"8436a552.ae1f78","name":"create response","func":"if(msg.payload.content === 'Yes')\n{\n msg.payload.content = 'Yes';\n return [msg, null]; \n}\nelse\n{\n msg.payload.content = 'No';\n return [null, msg]; \n}\n","outputs":"2","noerr":0,"x":375,"y":310,"wires":[["9e138687.ee43a8"],[]]},{"id":"9e138687.ee43a8","type":"telegram sender","z":"8436a552.ae1f78","name":"send response","bot":"c3670dce.18aa8","x":615,"y":304,"wires":[[]]},{"id":"6908dd72.a30c74","type":"telegram command","z":"8436a552.ae1f78","name":"/help","command":"/help","bot":"c3670dce.18aa8","strict":false,"hasresponse":false,"x":170,"y":416,"wires":[["c105c26c.7cbe5"]]},{"id":"c105c26c.7cbe5","type":"function","z":"8436a552.ae1f78","name":"create help text","func":"\nvar helpMessage = \"/help - shows help\\r\\n\";\nhelpMessage += \"/foo - opens a dialog\\r\\n\";\nhelpMessage += \"Your chat id is \" + msg.payload.chatId;\n\nhelpMessage += \"\\r\\n\";\nhelpMessage += \"You are welcome: \"+msg.originalMessage.from.username;\nhelpMessage += \"\\r\\n\";\n\n\n\nmsg.payload.content = helpMessage;\nreturn msg;","outputs":1,"noerr":0,"x":371,"y":410,"wires":[["9e138687.ee43a8"]]},{"id":"511a51f2.dd1b6","type":"telegram receiver","z":"8436a552.ae1f78","name":"location","bot":"c3670dce.18aa8","saveDataDir":"","x":173,"y":502,"wires":[["90bfc801.af6738"],[]]},{"id":"90bfc801.af6738","type":"function","z":"8436a552.ae1f78","name":"create 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 return msg;\n}\nelse\n{\n return null;\n}\n","outputs":1,"noerr":0,"x":396,"y":502,"wires":[["9e138687.ee43a8"]]},{"id":"dbc2c834.f29f98","type":"inject","z":"8436a552.ae1f78","name":"ping","topic":"","payload":"ping","payloadType":"string","repeat":"","crontab":"","once":false,"x":170,"y":604,"wires":[["f1873176.02a26"]]},{"id":"f1873176.02a26","type":"function","z":"8436a552.ae1f78","name":"send to specific chat","func":"\nmsg.payload = {chatId : 138708568, type : 'message', content : 'ping'}\nreturn msg;","outputs":1,"noerr":0,"x":378,"y":604,"wires":[["9e138687.ee43a8"]]},{"id":"c3670dce.18aa8","type":"telegram bot","z":"","botname":"HeinzBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}] -------------------------------------------------------------------------------- /examples/commandScopes.json: -------------------------------------------------------------------------------- 1 | [{"id":"563fc70dfa8d7e2c","type":"telegram command","z":"aafea27d96f58f0f","name":"/default","command":"/default","description":"Default Scope","registercommand":true,"language":"","scope":"default","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":130,"y":80,"wires":[["4f10207aaad4513b"],[]]},{"id":"8b2142df67587b3f","type":"telegram command","z":"aafea27d96f58f0f","name":"/default_de","command":"/default_de","description":"Default Scope German","registercommand":true,"language":"de","scope":"default","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":140,"y":140,"wires":[["4f10207aaad4513b"],[]]},{"id":"4f10207aaad4513b","type":"debug","z":"aafea27d96f58f0f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":390,"y":100,"wires":[]},{"id":"a94c0280e4461bc8","type":"telegram command","z":"aafea27d96f58f0f","name":"/private","command":"/private","description":"All Private Chats","registercommand":true,"language":"","scope":"all_private_chats","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":130,"y":200,"wires":[["4f10207aaad4513b"],[]]},{"id":"bc9e074b21e2cf91","type":"telegram command","z":"aafea27d96f58f0f","name":"/private_de","command":"/private_de","description":"All Private Chats German","registercommand":true,"language":"de","scope":"all_private_chats","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":140,"y":260,"wires":[["4f10207aaad4513b"],[]]},{"id":"958d3f6064860334","type":"telegram command","z":"aafea27d96f58f0f","name":"/group","command":"/group","description":"All Group Chats","registercommand":true,"language":"","scope":"all_group_chats","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":130,"y":320,"wires":[["4f10207aaad4513b"],[]]},{"id":"f4a1a96173e2c73e","type":"telegram command","z":"aafea27d96f58f0f","name":"/group_de","command":"/group_de","description":"All Group Chats German","registercommand":true,"language":"de","scope":"all_group_chats","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":140,"y":380,"wires":[["4f10207aaad4513b"],[]]},{"id":"4fd086c44b0a7c0a","type":"telegram command","z":"aafea27d96f58f0f","name":"/administrators","command":"/administrators","description":"All Chats Administrators","registercommand":true,"language":"","scope":"all_chat_administrators","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":160,"y":440,"wires":[["4f10207aaad4513b"],[]]},{"id":"4df70894300fa784","type":"telegram command","z":"aafea27d96f58f0f","name":"/administrators_de","command":"/administrators_de","description":"All Chats Administrators German","registercommand":true,"language":"","scope":"all_chat_administrators","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":170,"y":500,"wires":[["4f10207aaad4513b"],[]]},{"id":"3b6bfbc0.423a04","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}] -------------------------------------------------------------------------------- /SOCKS5.md: -------------------------------------------------------------------------------- 1 | # Socks5 Documentation 2 | You can enable SOCKS proxy support if you want to re-route your calls to the telegram bot api server (api.telergam.org) via an anonymous server. 3 | 4 | If the proxy server requires authentication you need to provide a username and password. If not, the fields must be empty: 5 | 6 | 7 | # General Notes 8 | - The default port for socks5 is 1080. 9 | - As the underlying request lib pools the agent, you need to restart node red when changing IP or the PORT. 10 | 11 | # Finding a SOCKS proxy 12 | ## Internet 13 | You can google for free socks5 proxy in the internet to find one, however this is not recommended as you do not know who 14 | is able to intercept your calls to the telegram bot server. Traffic between you and the telegram server is done using the https protocol, but that is not 100% safe. You can also pay a provider of your choice for a socks5 instance running in the internet but the best choice is to set up your own one. 15 | 16 | ## Localhost (ssh) 17 | You can set up your own server for testing in your local network as follows: 18 | https://catonmat.net/linux-socks5-proxy 19 | 20 | ## Local network (socks5-server) 21 | An easy way to set up your own server is creating a docker container using socks5-server which is available here: 22 | https://github.com/serjs/socks5-server 23 | 24 | ### Example using QNAP Container Station 25 | 26 | #### 1. Open Container Station and Select "Create" from the menu and search for "serjs/go-socks5-proxy" and install the package. 27 | 28 | The image in the screenshot is already downloaded but can be found under the tab "Docker Hub" 29 | See also https://hub.docker.com/r/serjs/go-socks5-proxy/ 30 | 31 | 32 | #### 2. Select Advanced Settings 33 | 34 | 35 | 36 | #### 3. Configure Network Port 37 | 38 | You can choose NAT or as shown in the screenshot bridge which means that the IP is the one from your NAS and the port is the default one 1080 or the one configured in PROXY_PORT. 39 | 40 | 41 | #### 4. Configure username and password 42 | 43 | Remove PROXY_USER and PROXY_PASSWORD if you do not need any authentication in your local network. 44 | 45 | 46 | #### 5. Click create to finish configuration 47 | 48 | 49 | 50 | #### 6. The docker image should be up and running 51 | 52 | 53 | 54 | #### 7. Enter the IP of your Container Station and the port 1080 in your node-red telegram bot configuration and you are done. 55 | Watch the output in the docker console. If user name and passord are wrong the output shows: 56 | 57 | 58 | 59 | #### 8. Enter user name and password in your node-red telegram bot configuration and you are done. 60 | 61 | 62 | 63 | #### 9. When the node shows status "Connected" then everything should work as expected.. 64 | 65 | 66 | 67 | Network is now routed via the docker image in the container station in your local network. 68 | This is only for testing and not to improve security. Remember that the socks5 proxy should be running somewhere else in the internet. 69 | -------------------------------------------------------------------------------- /examples/editMessageMedia.json: -------------------------------------------------------------------------------- 1 | [{"id":"edcf10da.82f94","type":"telegram sender","z":"7652eee0.6d11b","name":"send initial media","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":632.7594223022461,"y":133.3033103942871,"wires":[["db8e5a96.69f8f8"]]},{"id":"d338f266.95ff8","type":"function","z":"7652eee0.6d11b","name":"original media","func":"// content can be a file_id, url, local path...\nmsg.payload.content = \"c:\\\\temp\\\\sample1.png\";\nmsg.payload.type = \"photo\";\nmsg.payload.caption = \"Original Media\"\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":331.7592468261719,"y":134.3032283782959,"wires":[["edcf10da.82f94"]]},{"id":"8c682765.b34cf8","type":"telegram command","z":"7652eee0.6d11b","name":"/foo","command":"/foo","bot":"5f67fb38.18d094","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":162.75931549072266,"y":140.3032102584839,"wires":[["d338f266.95ff8"]]},{"id":"ad64ec3d.4d2b4","type":"telegram sender","z":"7652eee0.6d11b","name":"send modified media","bot":"5f67fb38.18d094","haserroroutput":false,"outputs":1,"x":640,"y":240,"wires":[["3499a9a6.8ae146"]]},{"id":"3dc83d60.7cbcc2","type":"function","z":"7652eee0.6d11b","name":"modified media (local file)","func":"var messageId = context.global.messageId;\nvar chatId = context.global.chatId;\n\nvar options = {\n chat_id : chatId,\n message_id : messageId\n};\n\n// see https://core.telegram.org/bots/api#inputmediaphoto\nvar inputMediaPhoto = {\n type : \"photo\",\n media : \"c:\\\\temp\\\\sample2.png\",\n caption : \"modified image\"\n}\n \nmsg.payload = {\n type : 'editMessageMedia',\n content : inputMediaPhoto,\n options : options,\n}\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":370,"y":240,"wires":[["ad64ec3d.4d2b4"]]},{"id":"db8e5a96.69f8f8","type":"function","z":"7652eee0.6d11b","name":"save IDs","func":"// We store the messageId to be able to edit this reply in the callback query. \ncontext.global.messageId = msg.payload.sentMessageId;\ncontext.global.chatId = msg.payload.chatId;\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":840.6667861938477,"y":133.6667127609253,"wires":[[]]},{"id":"3499a9a6.8ae146","type":"debug","z":"7652eee0.6d11b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":240,"wires":[]},{"id":"b55fa9d6.a7e438","type":"inject","z":"7652eee0.6d11b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":170,"y":240,"wires":[["3dc83d60.7cbcc2"]]},{"id":"8873ddbb.78ace","type":"function","z":"7652eee0.6d11b","name":"modified media (web url)","func":"var messageId = context.global.messageId;\nvar chatId = context.global.chatId;\n\nvar options = {\n chat_id : chatId,\n message_id : messageId\n};\n\n// see https://core.telegram.org/bots/api#inputmediaphoto\nvar inputMediaPhoto = {\n type : \"photo\",\n media : \"https://www.cleverfiles.com/howto/wp-content/uploads/2018/03/minion.jpg\",\n caption : \"modified image\"\n}\n \nmsg.payload = {\n type : 'editMessageMedia',\n content : inputMediaPhoto,\n options : options,\n}\n\nreturn [ msg ];\n","outputs":"1","noerr":0,"initialize":"","finalize":"","x":370,"y":300,"wires":[["ad64ec3d.4d2b4"]]},{"id":"5cb8a895.4191e8","type":"inject","z":"7652eee0.6d11b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":170,"y":300,"wires":[["8873ddbb.78ace"]]},{"id":"5f67fb38.18d094","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}] -------------------------------------------------------------------------------- /examples/sendInvoice2.json: -------------------------------------------------------------------------------- 1 | [{"id":"147ec1f1de43e1dd","type":"telegram command","z":"5c2564baa1f544ec","name":"","command":"/buy","description":"","registercommand":false,"language":"","bot":"3b6bfbc0.423a04","strict":false,"hasresponse":true,"useregex":false,"removeregexcommand":false,"outputs":2,"x":210,"y":320,"wires":[["a716035a2c1abd5a"],[]]},{"id":"a716035a2c1abd5a","type":"function","z":"5c2564baa1f544ec","name":"send invoice","func":"// Invoice Information see https://core.telegram.org/bots/api#sendinvoice\nmsg.payload.type = \"sendInvoice\";\n\nmsg.payload.content = {\n title : \"Super Toy\",\n description : \"The best toy you can buy\",\n payload : \"secret token\",\n providerToken : \"the token from your bank\",\n currency : \"EUR\", // see https://core.telegram.org/bots/payments#supported-currencies\n prices : [ {\n label : \"price\",\n amount : 15000 } ], // this is 150.00EUR\n}\n\n// Optional\n// msg.payload.options\n// provider_data\n// photo_url\n// photo_size\n// photo_width\n// photo_height\n// need_name\n// need_phone_number\n// need_email\n// need_shipping_address\n// send_phone_number_to_provider\n// send_email_to_provider\n// is_flexible\n// disable_notification\n// reply_to_message_id\n// reply_markup\n\nmsg.payload.options = {\n reply_to_message_id : msg.payload.messageId,\n need_name : true,\n need_phone_number : true,\n need_email : true,\n is_flexible : true\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":433,"y":315,"wires":[["7c2e9864f8dec2e2"]]},{"id":"7c2e9864f8dec2e2","type":"telegram sender","z":"5c2564baa1f544ec","name":"","bot":"3b6bfbc0.423a04","haserroroutput":false,"outputs":1,"x":773,"y":435,"wires":[["9e8f4f0d501588d8"]]},{"id":"3210b28f7015a16d","type":"telegram event","z":"5c2564baa1f544ec","name":"","bot":"3b6bfbc0.423a04","event":"pre_checkout_query","autoanswer":false,"x":173,"y":475,"wires":[["5b30dcc6d2644982"]]},{"id":"5b30dcc6d2644982","type":"function","z":"5c2564baa1f544ec","name":"answer checkout","func":"// Invoice Information see https://core.telegram.org/bots/api#answerprecheckoutquery\nmsg.payload.type = \"answerPreCheckoutQuery\";\nmsg.payload.ok = true;\n\nmsg.payload.options = {\n error_message : \"Product not available anymore!\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":453,"y":475,"wires":[["7c2e9864f8dec2e2"]]},{"id":"9e8f4f0d501588d8","type":"debug","z":"5c2564baa1f544ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":973,"y":435,"wires":[]},{"id":"fe805bc20926906b","type":"function","z":"5c2564baa1f544ec","name":"thank you","func":"// see https://core.telegram.org/bots/api#successfulpayment\nif (msg.payload.type === \"successful_payment\") {\n msg.payload.type = \"message\";\n msg.payload.content = \"Thank you for your purchase!\";\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":423,"y":555,"wires":[["7c2e9864f8dec2e2"]]},{"id":"0a522589bdacc2ca","type":"telegram receiver","z":"5c2564baa1f544ec","name":"","bot":"3b6bfbc0.423a04","saveDataDir":"","filterCommands":false,"x":171,"y":562,"wires":[["fe805bc20926906b"],[]]},{"id":"74ebbb35041a3d28","type":"telegram event","z":"5c2564baa1f544ec","name":"","bot":"3b6bfbc0.423a04","event":"shipping_query","autoanswer":false,"x":183,"y":395,"wires":[["60f6230b559b70fd"]]},{"id":"60f6230b559b70fd","type":"function","z":"5c2564baa1f544ec","name":"answer shipping","func":"// Invoice Information see https://core.telegram.org/bots/api#answershippingquery\nmsg.payload.type = \"answerShippingQuery\";\nmsg.payload.ok = true;\n\nmsg.payload.options = {\n error_message : \"We cannot deliver to your address\",\n shipping_options: [\n {\n id: \"shipping\",\n title: \"Shipping by seller\",\n prices: [\n { label: \"Shipping by seller 1\", amount: 500 },\n { label: \"Shipping by seller 2\", amount: 500 }\n ]\n },\n {\n id: \"takeaway\",\n title: \"Take away\",\n prices: [{ label: \"-Take away\", amount: 0 }]\n }\n ]\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":443,"y":395,"wires":[["7c2e9864f8dec2e2"]]},{"id":"f30f2b26304282dc","type":"comment","z":"5c2564baa1f544ec","name":"Payment Example","info":"In order to be able to run the example you must set the providerToken in the \"send invoice\" node.\nsee also https://core.telegram.org/bots/api#sendinvoice","x":180,"y":260,"wires":[]},{"id":"3b6bfbc0.423a04","type":"telegram bot","botname":"smarthomesolutions_bot","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}] -------------------------------------------------------------------------------- /examples/pinningMultipleMessages.json: -------------------------------------------------------------------------------- 1 | [{"id":"46b012eb.3634bc","type":"telegram sender","z":"ed43e0f7.31d9","name":"","bot":"fcc25e57.4073a","haserroroutput":false,"outputs":1,"x":430,"y":120,"wires":[["90c8183c.df50d8"]]},{"id":"edd05cdc.ccba7","type":"inject","z":"ed43e0f7.31d9","name":"Pin 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"Pinned 1","payloadType":"str","x":90,"y":120,"wires":[["62a75af3.7db694"]]},{"id":"239ac48e.7aaafc","type":"function","z":"ed43e0f7.31d9","name":"unpin","func":"var chatId = flow.get(\"chatId\");\n\nvar message_id = flow.get(\"message1\");\nvar options = {};\noptions = {\n message_id : message_id,\n chat_id : chatId\n};\n\nvar payload = {\n type: \"unpinChatMessage\",\n chatId: chatId,\n content: options\n}\n\nmsg.payload = payload;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":300,"wires":[["14e472e9.7fd11d"]]},{"id":"d14be332.4bb58","type":"inject","z":"ed43e0f7.31d9","name":"Unpin 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"1","payloadType":"num","x":90,"y":300,"wires":[["239ac48e.7aaafc"]]},{"id":"90c8183c.df50d8","type":"function","z":"ed43e0f7.31d9","name":"pin","func":"var chatId = flow.get(\"chatId\");\n\nvar message_id = msg.payload.sentMessageId;\nflow.set(\"message1\", message_id);\n\nvar payload = {\n type: \"pinChatMessage\",\n chatId: chatId,\n content: message_id\n}\n\nmsg.payload = payload;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":120,"wires":[["14e472e9.7fd11d"]]},{"id":"62a75af3.7db694","type":"function","z":"ed43e0f7.31d9","name":"send message","func":"var chatId = flow.get(\"chatId\");\n\nvar message = msg.payload;\n\nvar payload = {\n type: \"message\",\n chatId: chatId,\n content: message\n}\n\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":120,"wires":[["46b012eb.3634bc"]]},{"id":"2dd330e0.b9c11","type":"inject","z":"ed43e0f7.31d9","name":"Unpin 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"2","payloadType":"num","x":90,"y":360,"wires":[["55e710fd.20302"]]},{"id":"d3f18224.5a203","type":"telegram sender","z":"ed43e0f7.31d9","name":"","bot":"fcc25e57.4073a","haserroroutput":false,"outputs":1,"x":430,"y":180,"wires":[["d941af35.b1ebe"]]},{"id":"96833547.618ac8","type":"inject","z":"ed43e0f7.31d9","name":"Pin 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"Pinned 2","payloadType":"str","x":90,"y":180,"wires":[["b9efb76b.987648"]]},{"id":"d941af35.b1ebe","type":"function","z":"ed43e0f7.31d9","name":"pin","func":"var chatId = flow.get(\"chatId\");\n\nvar message_id = msg.payload.sentMessageId;\nflow.set(\"message2\", message_id);\n\nvar payload = {\n type: \"pinChatMessage\",\n chatId: chatId,\n content: message_id\n}\n\nmsg.payload = payload;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":180,"wires":[["14e472e9.7fd11d"]]},{"id":"b9efb76b.987648","type":"function","z":"ed43e0f7.31d9","name":"send message","func":"var chatId = flow.get(\"chatId\");\n\nvar message = msg.payload;\n\nvar payload = {\n type: \"message\",\n chatId: chatId,\n content: message\n}\n\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":180,"wires":[["d3f18224.5a203"]]},{"id":"14e472e9.7fd11d","type":"telegram sender","z":"ed43e0f7.31d9","name":"","bot":"fcc25e57.4073a","haserroroutput":false,"outputs":1,"x":790,"y":240,"wires":[[]]},{"id":"55e710fd.20302","type":"function","z":"ed43e0f7.31d9","name":"unpin","func":"var chatId = flow.get(\"chatId\");\n\nvar message_id = flow.get(\"message2\");\nvar options = {};\noptions = {\n message_id : message_id,\n chat_id : chatId\n};\n\nvar payload = {\n type: \"unpinChatMessage\",\n chatId: chatId,\n content: options\n}\n\nmsg.payload = payload;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":360,"wires":[["14e472e9.7fd11d"]]},{"id":"e25b5de9.7e1ca","type":"inject","z":"ed43e0f7.31d9","name":"once","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"-1001456177533","payloadType":"num","x":100,"y":40,"wires":[["fe6d2966.bcc568"]]},{"id":"fe6d2966.bcc568","type":"function","z":"ed43e0f7.31d9","name":"set chatId","func":"flow.set(\"chatId\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":40,"wires":[[]]},{"id":"fcc25e57.4073a","type":"telegram bot","botname":"TestBot","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}] -------------------------------------------------------------------------------- /examples/editinlinekeyboard.json: -------------------------------------------------------------------------------- 1 | [{"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}] -------------------------------------------------------------------------------- /examples/livelocation.json: -------------------------------------------------------------------------------- 1 | [{"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":""}] -------------------------------------------------------------------------------- /telegrambot/nodes/reply-node.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | 3 | const converter = require("../lib/converter.js"); 4 | 5 | // -------------------------------------------------------------------------------------------- 6 | // The output node receices the reply for a specified message and passes the msg through. 7 | // The payload needs three fields 8 | // chatId : string destination chat 9 | // sentMessageId : string the id of the message the reply coresponds to. 10 | // content : message content 11 | function TelegramReplyNode(config) { 12 | RED.nodes.createNode(this, config); 13 | let node = this; 14 | this.bot = config.bot; 15 | 16 | this.start = function () { 17 | let telegramBot = this.config.getTelegramBot(); 18 | if (telegramBot) { 19 | if (telegramBot._polling !== null || telegramBot._webHook !== null) { 20 | node.status({ 21 | fill: 'green', 22 | shape: 'ring', 23 | text: 'connected', 24 | }); 25 | } else { 26 | node.status({ 27 | fill: 'grey', 28 | shape: 'ring', 29 | text: 'send only mode', 30 | }); 31 | } 32 | } else { 33 | node.warn('bot not initialized.'); 34 | node.status({ 35 | fill: 'red', 36 | shape: 'ring', 37 | text: 'bot not initialized', 38 | }); 39 | } 40 | }; 41 | 42 | this.stop = function () { 43 | node.status({ 44 | fill: 'red', 45 | shape: 'ring', 46 | text: 'disconnected', 47 | }); 48 | }; 49 | 50 | this.config = RED.nodes.getNode(this.bot); 51 | if (this.config) { 52 | node.status({ fill: 'red', shape: 'ring', text: 'not connected' }); 53 | node.onStatusChanged = function (status, nodeStatus) { 54 | node.status(nodeStatus); 55 | switch (status) { 56 | case 'started': 57 | node.start(); 58 | break; 59 | case 'stopped': 60 | node.stop(); 61 | break; 62 | default: 63 | break; 64 | } 65 | }; 66 | node.config.addListener('status', node.onStatusChanged); 67 | 68 | node.start(); 69 | } else { 70 | node.warn('config node failed to initialize.'); 71 | node.status({ 72 | fill: 'red', 73 | shape: 'ring', 74 | text: 'config node failed to initialize', 75 | }); 76 | } 77 | 78 | this.on('input', function (msg, nodeSend, nodeDone) { 79 | node.status({ fill: 'green', shape: 'ring', text: 'connected' }); 80 | 81 | if (msg.payload) { 82 | let telegramBot = this.config.getTelegramBot(); 83 | if (telegramBot) { 84 | if (msg.payload.chatId) { 85 | if (msg.payload.sentMessageId) { 86 | let chatId = msg.payload.chatId; 87 | let messageId = msg.payload.sentMessageId; 88 | 89 | telegramBot.onReplyToMessage(chatId, messageId, function (botMsg) { 90 | let messageDetails = converter.getMessageDetails(botMsg); 91 | if (messageDetails) { 92 | msg.payload = messageDetails; 93 | msg.originalMessage = botMsg; 94 | nodeSend(msg); 95 | if (nodeDone) { 96 | nodeDone(); 97 | } 98 | } 99 | }); 100 | } else { 101 | node.warn('msg.payload.sentMessageId is empty'); 102 | } 103 | } else { 104 | node.warn('msg.payload.chatId is empty'); 105 | } 106 | } else { 107 | node.warn('bot not initialized.'); 108 | node.status({ 109 | fill: 'red', 110 | shape: 'ring', 111 | text: 'bot not initialized', 112 | }); 113 | } 114 | } else { 115 | node.warn('msg.payload is empty'); 116 | } 117 | }); 118 | 119 | this.on('close', function (removed, done) { 120 | node.stop(); 121 | 122 | if (node.onStatusChanged) { 123 | node.config.removeListener('status', node.onStatusChanged); 124 | } 125 | 126 | node.status({}); 127 | done(); 128 | }); 129 | } 130 | 131 | return TelegramReplyNode; 132 | }; -------------------------------------------------------------------------------- /WEBHOOK.md: -------------------------------------------------------------------------------- 1 | # Webhook examples 2 | As setting up a webhook can be very error prone the following chapter may help you in this quest. 3 | 4 | 5 | 6 | ## Example 1: Webhook with certificate 7 | As a prerequisite you have to create your own certificate as described there: 8 | - https://core.telegram.org/bots/webhooks 9 | - https://stackoverflow.com/questions/42713926/what-is-easy-way-to-create-and-use-a-self-signed-certification-for-a-telegram-we 10 | 11 | One of many pitfalls when creating certificates (that don't work) is, that the value CN you provided to openssl must match the bots domain name: see *Bot Host* below. 12 | Create our pair of private and public keys using the following command: 13 | ``` 14 | openssl req -newkey rsa:2048 -sha256 -nodes -keyout PRIVATE.key -x509 -days 365 -out PUBLIC.pem -subj "/C=DE/ST=Bavaria/L=Munich/O=YOUR_NAME_OR_COMPANY_NAME/CN=SERVER_NAME_OR_IP" 15 | ``` 16 | Important: 17 | Replace *SERVER_NAME_OR_IP* with the name you entered in the configuration node under ***Bot Host*** in the *Webhook Options*. Both names must be equal, otherwise the telegram server won't send updates to your bot. 18 | You should also replace *YOUR_NAME_OR_COMPANY_NAME* with some value. 19 | 20 | Note that the certificate will expire after 365 days and needs to be renewed (e.g. see [there](https://securitywing.com/how-renew-self-signed-ssl-certificate-openssl-tool-linux/)). 21 | 22 | [**example bat file for creating a certificate can be found here**](examples/makecert.bat) 23 | 24 | 25 | 26 | **Fig. 1:** Example configuration for webhook mode 27 | 28 | Instead of using self signed certificates you can use officially signed ones. This can be very expensive, but note that for example Windows 10 29 | automatically deletes self signed certificates from time to time (during the windows update) to protect the system from any software that tries to build up tunnels using self signed and thus easy to create certificates. 30 | 31 | 32 | ## Example 2: Without certificates in Unraid/Docker with SWAG/NGINX/REVERSE-PROXY 33 | Webhook can also be used without certificate but then the bot host must be behind a tunnel see https://github.com/windkh/node-red-contrib-telegrambot/pull/93. Thanks to daredoes for proving the following description. 34 | 35 | 36 | 37 | ### Node Red 38 | 39 | Set the Bot Settings to the following: 40 | 41 | ![image](https://user-images.githubusercontent.com/6538753/131450588-b2995151-b98c-4427-b3f0-9a7e92604ab0.png) 42 | 43 | **Fig. 2:** Example configuration for webhook mode without SSL 44 | 45 | `Update Mode - Webhook` - Setting this value to `Webhook` will be necessary for receiving our updates via webhook. 46 | 47 | `Bot Host - telebot.yourdomain.com` - Obviously, hopefully, `yourdomain.com` is a filler that you should replace with *your domain*. We're going to use `telebot` in this example though. 48 | 49 | `Bot Path - blank` - We're going to leave this blank, best not to break anything. 50 | 51 | `Public Bot Port - 443` - We're setting this to 443, the SSL public port for a website, because we're assuming we have setup a reverse-proxy with certs through something like DuckDNS and SWAG 52 | 53 | `Local Bot Port - 8443` - This is the default value, but take note of it as we'll be using it soon. Don't set this to 1880 or whatever port Node-Red is running on, or you're gonna have a bad time. Like everything crashes, restart node red in safe mode and change the port bad time. 54 | 55 | ` Certificate is Self-Signed - Unchecked` - I'm pretty sure it's not self-signed through DuckDNS, so... 56 | 57 | `SSL Terminated By Reverse Proxy - Checked` - By enabling this, we skip the need to do all that complex stuff involving certificate signing and whatever. Woo! 58 | 59 | 60 | 61 | ### Node Red + Docker/Unraid 62 | 63 | If you're like me, you're running this on something like HomeAssistant or Unraid. I'm running it on Unraid. Well, to make sure Telegram can send webhooks to our bot, we need to make sure our bot, running at port `8443` can be reached from our reverse-proxy. 64 | 65 | Let's edit our node-red docker instance, and `Add another Path, Port, Variable, Label, or Device`, then fill in the modal with the following values: 66 | 67 | ![image](https://user-images.githubusercontent.com/6538753/131451461-74647265-5056-4843-a6ac-320ef9f8d9c7.png) 68 | 69 | **Fig. 3:** Example docker configuration 70 | 71 | Apply the changes, and you should see the following on your docker status page. 72 | 73 | ![image](https://user-images.githubusercontent.com/6538753/131451391-248cdda3-5c1f-4843-8587-ec4f65287ca5.png) 74 | 75 | **Fig. 4:** Example docker status page 76 | 77 | 78 | 79 | ### SWAG Proxy Conf 80 | 81 | If you're also like me, you're running SWAG to do a reverse-proxy. Create a new subdomain proxy for `telebot`, our previously noted subdomain. 82 | 83 | My configuration looks like this. 84 | 85 | ![image](https://user-images.githubusercontent.com/6538753/131451336-cdbd22bf-422a-4a8d-ab7c-d1efd9762472.png) 86 | 87 | **Fig. 5:** Example SWAG configuration 88 | 89 | ```text 90 | server { 91 | listen 443 ssl; 92 | listen [::]:443 ssl; 93 | 94 | server_name telebot.*; 95 | 96 | include /config/nginx/ssl.conf; 97 | 98 | client_max_body_size 0; 99 | 100 | # enable for ldap auth, fill in ldap details in ldap.conf 101 | #include /config/nginx/ldap.conf; 102 | 103 | # enable for Authelia 104 | #include /config/nginx/authelia-server.conf; 105 | 106 | location / { 107 | # enable the next two lines for http auth 108 | #auth_basic "Restricted"; 109 | #auth_basic_user_file /config/nginx/.htpasswd; 110 | 111 | # enable the next two lines for ldap auth 112 | #auth_request /auth; 113 | #error_page 401 =200 /ldaplogin; 114 | 115 | # enable for Authelia 116 | #include /config/nginx/authelia-location.conf; 117 | 118 | include /config/nginx/proxy.conf; 119 | resolver 127.0.0.11 valid=30s; 120 | set $upstream_app 192.168.1.55; 121 | set $upstream_port 8443; 122 | set $upstream_proto http; 123 | proxy_pass $upstream_proto://$upstream_app:$upstream_port; 124 | 125 | } 126 | } 127 | ``` 128 | 129 | 130 | 131 | ### Last But Not Least 132 | 133 | Add your domain to your SWAG instance subdomains so it gets certified. Add the subdomain to your DNS records as a CNAME, or however you handle that stuff. 134 | 135 | Once all of this is done, messages should come back from nodes pretty rapidly! 136 | 137 | Hope this helps. 138 | -------------------------------------------------------------------------------- /telegrambot/nodes/event-node.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | 3 | const converter = require("../lib/converter.js"); 4 | 5 | // -------------------------------------------------------------------------------------------- 6 | // The input node receives an event from the chat. See https://core.telegram.org/bots/api#update 7 | // The type of event can be configured: 8 | // - edited_message 9 | // - channel_post 10 | // - edited_channel_post 11 | // - business_connection 12 | // - business_message 13 | // - edited_business_message 14 | // - deleted_business_messages 15 | // - message_reaction 16 | // - message_reaction_count 17 | // - inline_query 18 | // - chosen_inline_result 19 | // - callback_query 20 | // - shipping_query 21 | // - pre_checkout_query 22 | // - purchased_paid_media (not available) 23 | // - poll 24 | // - poll_answer 25 | // - my_chat_member 26 | // - chat_member 27 | // - chat_join_request 28 | // - chat_boost 29 | // - removed_chat_boost 30 | 31 | // Only the following are supported by see telegram.js processUpdate 32 | // - message 33 | // - edited_message 34 | // - channel_post; 35 | // - edited_channel_post; 36 | // - business_connection; 37 | // - business_message; 38 | // - edited_business_message; 39 | // - update.deleted_business_messages; 40 | // - message_reaction; 41 | // - message_reaction_count; 42 | // - inline_query; 43 | // - chosen_inline_result; 44 | // - callback_query; 45 | // - shipping_query; 46 | // - pre_checkout_query; 47 | // - poll; 48 | // - poll_answer; 49 | // - my_chat_member; 50 | // - chat_member; 51 | // - chat_join_request; 52 | // - chat_boost; 53 | // - removed_chat_boost; 54 | 55 | // - edited_message_text 56 | // - edited_message_caption 57 | // - edited_channel_post_text 58 | // - edited_channel_post_caption 59 | // The message details are stored in the payload 60 | // chatId 61 | // messageId 62 | // type 63 | // content 64 | // depending on type from and date is part of the output, too. 65 | // The original message is stored next to payload. 66 | // callback_query : content string 67 | function TelegramEventNode(config) { 68 | RED.nodes.createNode(this, config); 69 | let node = this; 70 | this.bot = config.bot; 71 | this.event = config.event; 72 | this.autoAnswerCallback = config.autoanswer; 73 | 74 | this.processError = function (exception, msg) { 75 | let errorMessage = 'Caught exception in event node:\r\n' + exception + '\r\nwhen processing message: \r\n' + JSON.stringify(msg); 76 | node.error(errorMessage, msg); 77 | 78 | node.status({ 79 | fill: 'red', 80 | shape: 'ring', 81 | text: exception.message, 82 | }); 83 | }; 84 | 85 | this.start = function () { 86 | let telegramBot = this.config.getTelegramBot(); 87 | if (telegramBot) { 88 | if (telegramBot._polling !== null || telegramBot._webHook !== null) { 89 | node.status({ 90 | fill: 'green', 91 | shape: 'ring', 92 | text: 'connected', 93 | }); 94 | 95 | telegramBot.on(this.event, (botMsg) => this.processMessage(botMsg)); 96 | } else { 97 | node.status({ 98 | fill: 'grey', 99 | shape: 'ring', 100 | text: 'send only mode', 101 | }); 102 | } 103 | } else { 104 | node.warn('bot not initialized.'); 105 | node.status({ 106 | fill: 'red', 107 | shape: 'ring', 108 | text: 'bot not initialized', 109 | }); 110 | } 111 | }; 112 | 113 | this.stop = function () { 114 | let telegramBot = this.config.getTelegramBot(); 115 | if (telegramBot) { 116 | telegramBot.off(this.event); 117 | } 118 | 119 | node.status({ 120 | fill: 'red', 121 | shape: 'ring', 122 | text: 'disconnected', 123 | }); 124 | }; 125 | 126 | this.processMessage = function (botMsg) { 127 | let telegramBot = this.config.getTelegramBot(); 128 | 129 | node.status({ 130 | fill: 'green', 131 | shape: 'ring', 132 | text: 'connected', 133 | }); 134 | 135 | node.status({ 136 | fill: 'green', 137 | shape: 'ring', 138 | text: 'connected', 139 | }); 140 | 141 | let userInfo = converter.getUserInfo(botMsg); 142 | let username = userInfo.username; 143 | let isAnonymous = userInfo.isAnonymous; 144 | let chatid = userInfo.chatid; 145 | let userid = userInfo.userid; 146 | 147 | if (isAnonymous || node.config.isAuthorized(node, chatid, userid, username)) { 148 | let msg; 149 | let botDetails = { 150 | botname: this.config.botname, 151 | testEnvironment: this.config.testEnvironment, 152 | baseApiUrl: this.config.telegramBot.options.baseApiUrl, 153 | }; 154 | 155 | let messageDetails = converter.convertMessage(this.event, chatid, botMsg); 156 | if (messageDetails) { 157 | 158 | // sepcial callback query handling. 159 | if(this.event === 'callback_query') { 160 | if (node.autoAnswerCallback) { 161 | telegramBot 162 | .answerCallbackQuery(botMsg.id) 163 | .catch(function (ex) { 164 | node.processError(ex, msg); 165 | }) 166 | .then(function () { 167 | // nothing to do here 168 | // node.processResult(result); 169 | }); 170 | } 171 | } 172 | 173 | msg = { 174 | payload: messageDetails, 175 | originalMessage: botMsg, 176 | telegramBot: botDetails, 177 | }; 178 | node.send(msg); 179 | } 180 | } else { 181 | // ignoring unauthorized calls 182 | if (node.config.verbose) { 183 | node.warn('Unauthorized incoming call from ' + username); 184 | } 185 | } 186 | }; 187 | 188 | this.config = RED.nodes.getNode(this.bot); 189 | if (this.config) { 190 | node.status({ fill: 'red', shape: 'ring', text: 'not connected' }); 191 | node.onStatusChanged = function (status, nodeStatus) { 192 | node.status(nodeStatus); 193 | switch (status) { 194 | case 'started': 195 | node.start(); 196 | break; 197 | case 'stopped': 198 | node.stop(); 199 | break; 200 | default: 201 | break; 202 | } 203 | }; 204 | node.config.addListener('status', node.onStatusChanged); 205 | 206 | node.botname = this.config.botname; 207 | 208 | node.start(); 209 | } else { 210 | node.warn('config node failed to initialize.'); 211 | node.status({ 212 | fill: 'red', 213 | shape: 'ring', 214 | text: 'config node failed to initialize', 215 | }); 216 | } 217 | 218 | this.on('close', function (removed, done) { 219 | node.stop(); 220 | 221 | if (node.onStatusChanged) { 222 | node.config.removeListener('status', node.onStatusChanged); 223 | } 224 | 225 | node.status({}); 226 | done(); 227 | }); 228 | } 229 | 230 | return TelegramEventNode; 231 | }; -------------------------------------------------------------------------------- /telegrambot/nodes/control-node.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = function(RED) { 3 | 4 | // -------------------------------------------------------------------------------------------- 5 | // The control node can start stop a bot. 6 | // The payload needs these fields 7 | // command : string 'start' 'stop' 'restart' 8 | // delay : optional time in milliseconds for restart. 9 | function TelegramControlNode(config) { 10 | RED.nodes.createNode(this, config); 11 | let node = this; 12 | this.bot = config.bot; 13 | 14 | let checkconnection = config.checkconnection; 15 | if (checkconnection === undefined) { 16 | checkconnection = false; 17 | } 18 | let hostname = config.hostname; 19 | let interval = (config.interval || 10) * 1000; 20 | let connectionTimeout = (config.timeout || 10) * 1000; 21 | 22 | this.start = function () { 23 | let telegramBot = node.config.getTelegramBot(); 24 | if (telegramBot) { 25 | telegramBot.on('getUpdates_start', function (cycle) { 26 | node.status({ 27 | fill: 'green', 28 | shape: 'ring', 29 | text: 'polling cycle ' + cycle, 30 | }); 31 | }); 32 | telegramBot.on('getUpdates_end', function (cycle, duration, updates) { 33 | let durationMs = Math.round(duration); 34 | 35 | node.status({ 36 | fill: 'green', 37 | shape: 'ring', 38 | text: 'polling cycle ' + cycle + ': ' + durationMs + 'ms', 39 | }); 40 | 41 | let msg = { 42 | payload: { 43 | cycle: cycle, 44 | duration: duration, 45 | updates: updates, 46 | }, 47 | }; 48 | node.send(msg); 49 | }); 50 | 51 | node.status({ 52 | fill: 'green', 53 | shape: 'ring', 54 | text: 'connected', 55 | }); 56 | } else { 57 | node.warn('bot not initialized.'); 58 | node.status({ 59 | fill: 'red', 60 | shape: 'ring', 61 | text: 'bot not initialized', 62 | }); 63 | } 64 | }; 65 | 66 | this.stop = function () { 67 | let telegramBot = node.config.getTelegramBot(); 68 | if (telegramBot) { 69 | telegramBot.off('getUpdates_start'); 70 | telegramBot.off('getUpdates_end'); 71 | } 72 | 73 | node.status({ 74 | fill: 'red', 75 | shape: 'ring', 76 | text: 'disconnected', 77 | }); 78 | }; 79 | 80 | this.checkConnection = function () { 81 | let effectiveUrl = node.config.baseApiUrl || 'https://api.telegram.org'; 82 | if (hostname !== '') { 83 | effectiveUrl = hostname; 84 | } 85 | let url = new URL(effectiveUrl); 86 | let host = url.hostname; 87 | let port = url.port || 80; 88 | let timeout = connectionTimeout; 89 | node.isHostReachable(host, port, timeout).then( 90 | function () { 91 | let msg = { 92 | payload: { 93 | isOnline: true, 94 | }, 95 | }; 96 | node.send([null, msg]); 97 | }, 98 | function (err) { 99 | let msg = { 100 | payload: { 101 | isOnline: false, 102 | error: err, 103 | }, 104 | }; 105 | node.send([null, msg]); 106 | } 107 | ); 108 | }; 109 | 110 | this.isHostReachable = function (host, port, timeout) { 111 | return new Promise(function (resolve, reject) { 112 | let timer = setTimeout(function () { 113 | reject('timeout'); 114 | socket.end(); 115 | }, timeout); 116 | let socket = net.createConnection(port, host, function () { 117 | clearTimeout(timer); 118 | resolve(); 119 | socket.end(); 120 | }); 121 | socket.on('error', function (err) { 122 | clearTimeout(timer); 123 | reject(err); 124 | }); 125 | }); 126 | }; 127 | 128 | this.config = RED.nodes.getNode(this.bot); 129 | if (this.config) { 130 | node.status({ fill: 'red', shape: 'ring', text: 'not connected' }); 131 | node.onStatusChanged = function (status, nodeStatus) { 132 | node.status(nodeStatus); 133 | switch (status) { 134 | case 'started': 135 | node.start(); 136 | break; 137 | case 'stopped': 138 | node.stop(); 139 | break; 140 | default: 141 | break; 142 | } 143 | }; 144 | node.config.addListener('status', node.onStatusChanged); 145 | 146 | node.start(); 147 | 148 | // start supervisor 149 | if (checkconnection) { 150 | node.checkConnectionTimer = setInterval(function () { 151 | node.checkConnection(); 152 | }, interval); 153 | } 154 | } else { 155 | node.warn('config node failed to initialize.'); 156 | node.status({ 157 | fill: 'red', 158 | shape: 'ring', 159 | text: 'config node failed to initialize', 160 | }); 161 | } 162 | 163 | this.on('input', function (msg) { 164 | node.status({ fill: 'green', shape: 'ring', text: 'connected' }); 165 | 166 | if (msg.payload) { 167 | let command = msg.payload.command; 168 | switch (command) { 169 | case 'stop': { 170 | node.config.stop('by control node', function () { 171 | node.send(msg); 172 | }); 173 | break; 174 | } 175 | case 'start': { 176 | node.config.start('by control node', function () { 177 | node.send(msg); 178 | }); 179 | break; 180 | } 181 | case 'restart': { 182 | node.config.stop('by control node', function () { 183 | let delay = msg.payload.delay; 184 | if (delay !== undefined && delay > 0) { 185 | setTimeout(function () { 186 | node.config.start('by control node', function () { 187 | node.send(msg); 188 | }); 189 | }, delay); 190 | } else { 191 | node.config.start('by control node', function () { 192 | node.send(msg); 193 | }); 194 | } 195 | node.send(msg); 196 | }); 197 | break; 198 | } 199 | case 'command': { 200 | let message = msg.payload.message; 201 | if (message.from === undefined) { 202 | message.from = { 203 | id: 0, 204 | username: 'unknown', 205 | }; 206 | } 207 | 208 | if (message.chat === undefined) { 209 | message.chat = { 210 | id: 0, 211 | }; 212 | } 213 | 214 | node.config.sendToAllCommandNodes(message, function () { 215 | node.send(msg); 216 | }); 217 | break; 218 | } 219 | default: 220 | break; 221 | } 222 | } else { 223 | node.warn('msg.payload is empty'); 224 | } 225 | }); 226 | 227 | this.on('close', function (removed, done) { 228 | // Stop supervisor 229 | if (node.checkConnectionTimer) { 230 | clearTimeout(node.checkConnectionTimer); 231 | node.checkConnectionTimer = null; 232 | } 233 | 234 | node.stop(); 235 | 236 | if (node.onStatusChanged) { 237 | node.config.removeListener('status', node.onStatusChanged); 238 | } 239 | 240 | node.status({}); 241 | done(); 242 | }); 243 | } 244 | 245 | return TelegramControlNode; 246 | }; -------------------------------------------------------------------------------- /telegrambot/nodes/command-node.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | 3 | // -------------------------------------------------------------------------------------------- 4 | // The input node receives a command from the chat. 5 | // The message details are stored in the payload 6 | // chatId 7 | // type 8 | // content 9 | // depending on type caption and date is part of the output, too. 10 | // The original message is stored next to payload. 11 | // 12 | // message : content string 13 | function TelegramCommandNode(config) { 14 | RED.nodes.createNode(this, config); 15 | let node = this; 16 | let command = config.command; 17 | 18 | let registerCommand = config.registercommand; 19 | let description = config.description || ''; 20 | let language = config.language || ''; 21 | let scope = config.scope || 'default'; 22 | 23 | let useRegex = config.useregex || false; 24 | let removeRegexCommand = config.removeregexcommand || false; 25 | 26 | let regEx; 27 | if (useRegex) { 28 | try { 29 | regEx = new RegExp(command); 30 | } catch (ex) { 31 | node.status({ fill: 'red', shape: 'ring', text: ex.message }); 32 | node.warn(ex.message); 33 | return; 34 | } 35 | } 36 | 37 | let strict = config.strict; 38 | let hasresponse = config.hasresponse; 39 | if (hasresponse === undefined) { 40 | hasresponse = true; 41 | } 42 | 43 | this.bot = config.bot; 44 | 45 | // If the command should not be registered, then we invalidate the language. 46 | if (!registerCommand) { 47 | language = undefined; 48 | } 49 | 50 | this.start = function () { 51 | let telegramBot = this.config.getTelegramBot(); 52 | if (telegramBot) { 53 | this.config.registerCommand(node.id, command, description, language, scope, registerCommand); 54 | 55 | node.botname = this.config.botname; 56 | 57 | if (telegramBot._polling !== null || telegramBot._webHook !== null) { 58 | node.status({ 59 | fill: 'green', 60 | shape: 'ring', 61 | text: 'connected', 62 | }); 63 | 64 | telegramBot.on('message', (botMsg) => this.processMessage(botMsg)); 65 | } else { 66 | node.status({ 67 | fill: 'grey', 68 | shape: 'ring', 69 | text: 'send only mode', 70 | }); 71 | } 72 | } else { 73 | node.warn('bot not initialized.'); 74 | node.status({ 75 | fill: 'red', 76 | shape: 'ring', 77 | text: 'bot not initialized', 78 | }); 79 | } 80 | }; 81 | 82 | this.stop = function () { 83 | let telegramBot = this.config.getTelegramBot(); 84 | if (telegramBot) { 85 | telegramBot.off('message'); 86 | } 87 | 88 | node.status({ 89 | fill: 'red', 90 | shape: 'ring', 91 | text: 'disconnected', 92 | }); 93 | }; 94 | 95 | this.processMessage = function (botMsg) { 96 | node.status({ 97 | fill: 'green', 98 | shape: 'ring', 99 | text: 'connected', 100 | }); 101 | 102 | let username = botMsg.from.username; 103 | let chatid = botMsg.chat.id; 104 | let userid = botMsg.from.id; 105 | if (node.config.isAuthorized(node, chatid, userid, username)) { 106 | let msg; 107 | let messageDetails; 108 | let botDetails = { 109 | botname: this.config.botname, 110 | testEnvironment: this.config.testEnvironment, 111 | baseApiUrl: this.config.telegramBot.options.baseApiUrl, 112 | }; 113 | 114 | if (botMsg.text) { 115 | let message = botMsg.text; 116 | let tokens = message.split(' '); 117 | 118 | // check if this is a command at all first 119 | let commandToken = tokens[0]; 120 | let isCommandMessage = commandToken.startsWith('/'); 121 | let isGroupChat = chatid < 0; 122 | let toBot = '@' + node.botname; 123 | 124 | // preprocess regex 125 | let command1 = command; 126 | let command2; 127 | 128 | let isRegExMatch; 129 | let isChatCommand = false; 130 | let isDirectCommand = false; 131 | if (useRegex) { 132 | let match = regEx.exec(commandToken); 133 | if (match !== null) { 134 | isRegExMatch = true; 135 | isChatCommand = true; 136 | isDirectCommand = commandToken.endsWith(toBot); 137 | 138 | if (removeRegexCommand) { 139 | command1 = match[0]; 140 | } 141 | 142 | if (!command1.endsWith(toBot)) { 143 | command2 = command1 + toBot; 144 | } else { 145 | command2 = command1; 146 | } 147 | } 148 | } else { 149 | isRegExMatch = false; 150 | 151 | isChatCommand = commandToken === command1; 152 | command2 = command1 + toBot; 153 | isDirectCommand = commandToken === command2; 154 | } 155 | 156 | // then if this command is meant for this node 157 | 158 | if (isDirectCommand || (isChatCommand && !isGroupChat) || (isChatCommand && isGroupChat && !strict) || (useRegex && isRegExMatch)) { 159 | let remainingText; 160 | if (isDirectCommand) { 161 | remainingText = message.replace(command2, ''); 162 | } else { 163 | remainingText = message.replace(command1, ''); 164 | } 165 | 166 | messageDetails = { 167 | chatId: botMsg.chat.id, 168 | messageId: botMsg.message_id, 169 | type: 'message', 170 | content: remainingText, 171 | }; 172 | 173 | msg = { 174 | payload: messageDetails, 175 | originalMessage: botMsg, 176 | telegramBot: botDetails, 177 | }; 178 | 179 | if (hasresponse) { 180 | node.send([msg, null]); 181 | node.config.setCommandPending(command1, username, chatid); 182 | } else { 183 | node.send(msg); 184 | } 185 | } else { 186 | // Here we check if the received message is probably a resonse to a pending command. 187 | if (!isCommandMessage) { 188 | if (hasresponse) { 189 | let isPending = node.config.isCommandPending(command1, username, chatid); 190 | if (isPending) { 191 | messageDetails = { 192 | chatId: botMsg.chat.id, 193 | messageId: botMsg.message_id, 194 | type: 'message', 195 | content: botMsg.text, 196 | }; 197 | msg = { 198 | payload: messageDetails, 199 | originalMessage: botMsg, 200 | telegramBot: botDetails, 201 | }; 202 | node.send([null, msg]); 203 | node.config.resetCommandPending(command1, username, chatid); 204 | } 205 | } 206 | } else { 207 | // Here we just ignore what happened as we do not know if another node is registered for that command. 208 | } 209 | } 210 | } else { 211 | // unknown type --> no output 212 | } 213 | } else { 214 | // ignoring unauthorized calls 215 | if (node.config.verbose) { 216 | node.warn('Unauthorized incoming call from ' + username); 217 | } 218 | } 219 | }; 220 | 221 | this.config = RED.nodes.getNode(this.bot); 222 | if (this.config) { 223 | node.status({ fill: 'red', shape: 'ring', text: 'not connected' }); 224 | node.onStatusChanged = function (status, nodeStatus) { 225 | node.status(nodeStatus); 226 | switch (status) { 227 | case 'started': 228 | node.start(); 229 | break; 230 | case 'stopped': 231 | node.stop(); 232 | break; 233 | default: 234 | break; 235 | } 236 | }; 237 | node.config.addListener('status', node.onStatusChanged); 238 | 239 | node.start(); 240 | } else { 241 | node.warn('config node failed to initialize.'); 242 | node.status({ 243 | fill: 'red', 244 | shape: 'ring', 245 | text: 'config node failed to initialize', 246 | }); 247 | } 248 | 249 | this.on('close', function (removed, done) { 250 | node.stop(); 251 | 252 | if (node.onStatusChanged) { 253 | node.config.removeListener('status', node.onStatusChanged); 254 | } 255 | 256 | node.config.unregisterCommand(node.id); 257 | node.status({}); 258 | done(); 259 | }); 260 | } 261 | 262 | return TelegramCommandNode; 263 | }; -------------------------------------------------------------------------------- /telegrambot/nodes/in-node.js: -------------------------------------------------------------------------------- 1 | module.exports = function(RED) { 2 | 3 | const fs = require('fs'); 4 | const converter = require("../lib/converter.js"); 5 | 6 | // -------------------------------------------------------------------------------------------- 7 | // The input node receives messages from the chat. 8 | // the message details are stored in the payload 9 | // chatId 10 | // type 11 | // content 12 | // depending on type caption and date is part of the output, too. 13 | // The original message is stored next to payload. 14 | // 15 | // The message ist send to output 1 if the message is from an authorized user 16 | // and to output2 if the message is not from an authorized user. 17 | // 18 | // Messages can be injected via the input if an external receiver is used. 19 | // 20 | // message : content string 21 | // photo : content file_id of first image in array 22 | // audio : content file_id 23 | // document: content file_id of document 24 | // sticker : content file_id 25 | // video : content file_id 26 | // voice : content file_id 27 | // location: content is object with latitude and longitude 28 | // contact : content is full contact object 29 | function TelegramInNode(config) { 30 | RED.nodes.createNode(this, config); 31 | let node = this; 32 | this.bot = config.bot; 33 | node.filterCommands = config.filterCommands || false; 34 | 35 | let hasInput = config.hasinput || false; 36 | let handleAllUpdates = config.handleallupdates || false; 37 | 38 | const events = [ 39 | "edited_message", 40 | "channel_post", 41 | "edited_channel_post", 42 | "business_connection", 43 | "business_message", 44 | "edited_business_message", 45 | "deleted_business_messages", 46 | "message_reaction", 47 | "message_reaction_count", 48 | "inline_query", 49 | "chosen_inline_result", 50 | "callback_query", 51 | "shipping_query", 52 | "pre_checkout_query", 53 | "poll", 54 | "poll_answer", 55 | "my_chat_member", 56 | "chat_member", 57 | "chat_join_request", 58 | "chat_boost", 59 | "removed_chat_boost", 60 | ]; 61 | 62 | this.start = function () { 63 | let telegramBot = this.config.getTelegramBot(); 64 | if (telegramBot) { 65 | // Before starting we check if the download dir really exists. 66 | if (config.saveDataDir && !fs.existsSync(config.saveDataDir)) { 67 | node.warn('The configured download directory does not exist: ' + config.saveDataDir); 68 | node.status({ 69 | fill: 'red', 70 | shape: 'ring', 71 | text: 'download dir not accessible', 72 | }); 73 | } else { 74 | if (telegramBot._polling !== null || telegramBot._webHook !== null) { 75 | node.status({ 76 | fill: 'green', 77 | shape: 'ring', 78 | text: 'connected', 79 | }); 80 | } else { 81 | node.status({ 82 | fill: 'grey', 83 | shape: 'ring', 84 | text: 'send only mode', 85 | }); 86 | } 87 | 88 | telegramBot.on('message', (botMsg) => this.processMessage('message',botMsg)); 89 | 90 | if (handleAllUpdates) { 91 | events.forEach(event => { 92 | telegramBot.on(event, (botMsg) => this.processMessage(event, botMsg)); 93 | }); 94 | } 95 | } 96 | } else { 97 | node.warn('bot not initialized.'); 98 | node.status({ 99 | fill: 'red', 100 | shape: 'ring', 101 | text: 'bot not initialized', 102 | }); 103 | } 104 | }; 105 | 106 | this.stop = function () { 107 | let telegramBot = this.config.getTelegramBot(); 108 | if (telegramBot) { 109 | telegramBot.off('message'); 110 | 111 | if (handleAllUpdates) { 112 | events.forEach(event => { 113 | telegramBot.off(event); 114 | }); 115 | } 116 | } 117 | 118 | node.status({ 119 | fill: 'red', 120 | shape: 'ring', 121 | text: 'disconnected', 122 | }); 123 | }; 124 | 125 | this.processMessage = function (type, botMsg) { 126 | node.status({ 127 | fill: 'green', 128 | shape: 'ring', 129 | text: 'connected', 130 | }); 131 | 132 | let userInfo = converter.getUserInfo(botMsg); 133 | let username = userInfo.username; 134 | let isAnonymous = userInfo.isAnonymous; 135 | let chatid = userInfo.chatid; 136 | let userid = userInfo.userid; 137 | 138 | let messageDetails = converter.convertMessage(type, chatid, botMsg); 139 | if (messageDetails) { 140 | let botDetails = { 141 | botname: this.config.botname, 142 | testEnvironment: this.config.testEnvironment, 143 | baseApiUrl: this.config.telegramBot.options.baseApiUrl, 144 | }; 145 | 146 | let msg = { 147 | payload: messageDetails, 148 | originalMessage: botMsg, 149 | telegramBot: botDetails, 150 | }; 151 | 152 | let telegramBot = this.config.getTelegramBot(); 153 | 154 | if (isAnonymous || node.config.isAuthorized(node, chatid, userid, username)) { 155 | // downloadable "blob" message? 156 | if (messageDetails.blob) { 157 | let fileId = msg.payload.content; 158 | telegramBot.getFileLink(fileId).then(function (weblink) { 159 | msg.payload.weblink = weblink; 160 | 161 | // download and provide with path 162 | if (config.saveDataDir) { 163 | telegramBot.downloadFile(fileId, config.saveDataDir).then(function (path) { 164 | msg.payload.path = path; 165 | node.send([msg, null]); 166 | }); 167 | } else { 168 | node.send([msg, null]); 169 | } 170 | }); 171 | // vanilla message 172 | } else if (node.filterCommands && node.config.isCommandRegistered(messageDetails.content)) { 173 | // Do nothing 174 | } else { 175 | node.send([msg, null]); 176 | } 177 | } else { 178 | if (node.config.verbose) { 179 | node.warn('Unauthorized incoming call from ' + username); 180 | } 181 | node.send([null, msg]); 182 | } 183 | } 184 | }; 185 | 186 | // Initializes a new instance of the node: 187 | this.config = RED.nodes.getNode(this.bot); 188 | if (this.config) { 189 | node.status({ fill: 'red', shape: 'ring', text: 'not connected' }); 190 | node.onStatusChanged = function (status, nodeStatus) { 191 | node.status(nodeStatus); 192 | switch (status) { 193 | case 'started': 194 | node.start(); 195 | break; 196 | case 'stopped': 197 | node.stop(); 198 | break; 199 | default: 200 | break; 201 | } 202 | }; 203 | node.config.addListener('status', node.onStatusChanged); 204 | 205 | node.start(); 206 | } else { 207 | node.warn('config node failed to initialize.'); 208 | node.status({ 209 | fill: 'red', 210 | shape: 'ring', 211 | text: 'config node failed to initialize', 212 | }); 213 | } 214 | 215 | if (hasInput) { 216 | // Receives messages from external input like external webhooks. 217 | this.on('input', function (msg, nodeSend, nodeDone) { 218 | 219 | if (msg.payload) { 220 | let telegramBot = this.config.getTelegramBot(); 221 | if (telegramBot) { 222 | 223 | let updates; 224 | // Check if the result comes from a http node otherwise msg.payload is directly used. 225 | if (msg.payload.ok ) { 226 | if (msg.payload.ok === true) { 227 | updates = msg.payload.result; 228 | } 229 | } 230 | else 231 | { 232 | updates = msg.payload; 233 | } 234 | 235 | if (updates) { 236 | if(Array.isArray(updates)) { 237 | updates.forEach(update => { 238 | telegramBot.processUpdate(update); 239 | }); 240 | } 241 | else { 242 | telegramBot.processUpdate(updates); 243 | } 244 | } 245 | else { 246 | node.warn('msg.payload is invalid'); 247 | } 248 | 249 | } else { 250 | node.warn('bot not initialized.'); 251 | node.status({ 252 | fill: 'red', 253 | shape: 'ring', 254 | text: 'bot not initialized', 255 | }); 256 | } 257 | } else { 258 | node.warn('msg.payload is empty'); 259 | } 260 | }); 261 | } 262 | 263 | this.on('close', function (removed, done) { 264 | node.stop(); 265 | 266 | if (node.onStatusChanged) { 267 | node.config.removeListener('status', node.onStatusChanged); 268 | } 269 | 270 | node.status({}); 271 | 272 | done(); 273 | }); 274 | } 275 | 276 | return TelegramInNode; 277 | }; -------------------------------------------------------------------------------- /examples/supergroupadmin.json: -------------------------------------------------------------------------------- 1 | [{"id":"bb54e2526165fae9","type":"telegram receiver","z":"89e16d21b4d07ec8","name":"","bot":"3b6bfbc0.423a04","saveDataDir":"","filterCommands":false,"x":190,"y":260,"wires":[["032a80f0b8a612c8","eb918922af9be44b"],[]]},{"id":"032a80f0b8a612c8","type":"function","z":"89e16d21b4d07ec8","name":"filter reply command","func":"var allowedChatId = -1001179754637;\nvar allowedUserIds = [138708568];\n\n// 1. Find out if we are in the correct chat and if the message was from admin\nvar fromChat = msg.payload.chatId;\nif(fromChat === allowedChatId && msg.originalMessage.from !== undefined) {\n\n var fromUser = msg.originalMessage.from.id;\n if(allowedUserIds.indexOf(fromUser) > -1) {\n \n // 2. Check if admin replied to a message\n var replyToMessage = msg.originalMessage.reply_to_message;\n var replyMessage = msg.originalMessage.text;\n if(replyToMessage !== undefined){\n\n // 3. take some action for user\n var userToHandle = replyToMessage.from.id;\n \n switch(replyMessage){\n case '/h':\n node.send([msg, null, null, null, null]);\n break;\n \n case '/d':\n node.send([null, msg, null, null, null]);\n break;\n \n case '/p':\n node.send([null, null, msg, null, null]);\n break;\n \n case '/r':\n node.send([null, null, null, msg, null]);\n break;\n \n default:\n node.send([null, null, null, null, msg]);\n break;\n }\n }\n }\n}","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":260,"wires":[["6a2ed5e1f29765b7"],["d6461c4d70cafd39"],["5494e1452bbf7bed"],["6c7f8a0a02dd99e5"],["321bb3180279417f"]],"icon":"node-red/switch.svg"},{"id":"6a2ed5e1f29765b7","type":"function","z":"89e16d21b4d07ec8","name":"/h hello","func":"// see also https://core.telegram.org/bots/api#sendmessage\n\nvar user = msg.originalMessage.reply_to_message.from.username;\nvar messageId = msg.originalMessage.reply_to_message.message_id;\nmsg.payload.type = 'message';\nmsg.payload.content = \"hello \" + user;\nmsg.payload.options = {\n reply_to_message_id : messageId\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":240,"wires":[["a65f7c544195fe5f"]],"icon":"font-awesome/fa-info"},{"id":"c701baf734debe32","type":"telegram sender","z":"89e16d21b4d07ec8","name":"","bot":"3b6bfbc0.423a04","haserroroutput":false,"outputs":1,"x":1470,"y":260,"wires":[[]]},{"id":"d6461c4d70cafd39","type":"function","z":"89e16d21b4d07ec8","name":"/d delete message","func":"// see also https://core.telegram.org/bots/api#deletemessage\n\nvar messageId = msg.originalMessage.reply_to_message.message_id;\nmsg.payload.type = 'deleteMessage';\nmsg.payload.content = messageId;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":280,"wires":[["a65f7c544195fe5f"]],"icon":"font-awesome/fa-trash-o"},{"id":"a65f7c544195fe5f","type":"telegram sender","z":"89e16d21b4d07ec8","name":"","bot":"3b6bfbc0.423a04","haserroroutput":false,"outputs":1,"x":1010,"y":260,"wires":[["64b4c132328952aa"]]},{"id":"64b4c132328952aa","type":"function","z":"89e16d21b4d07ec8","name":"delete command message","func":"// this lets vanish the command issued by the admin\n// if you do not need it you can remove this function node \n// and the following call to the sender node, too.\n\nvar messageId = msg.originalMessage.message_id;\nmsg.payload.type = 'deleteMessage';\nmsg.payload.content = messageId;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":260,"wires":[["c701baf734debe32"]],"icon":"font-awesome/fa-trash"},{"id":"9ff372dc9a121061","type":"comment","z":"89e16d21b4d07ec8","name":"SuperGroup Admin Example","info":"Example flow for demonstration how to handle replies to messages sent by user to issue admin actions.\n\nRight click on a message of a user and reply to that message using one of the predefined example command:\n- /h for hello echo\n- /d for deleting a message\n- /p to make user admin\n- /r to make admin a normal user\n- \nNote that the allowed users and super groups are right now hard coded in the \"filter replay command\" node. This can be changed or removed.","x":200,"y":180,"wires":[]},{"id":"5494e1452bbf7bed","type":"function","z":"89e16d21b4d07ec8","name":"/p promote user","func":"// see also https://core.telegram.org/bots/api#promotechatmember\n\n// Note that it makes adifference if you are in a channel or group or super group.\n// whenever you get an exception saying RIGHT_FORBIDDEN, then make sure that only valid fields are set.\n// This example is tested with super group and hence can_post_messages and can_edit_messages are not set.\n\nvar user = msg.originalMessage.reply_to_message.from.id;\nmsg.payload.type = 'promoteChatMember';\nmsg.payload.content = user;\nmsg.payload.options = {\n is_anonymous : false, // Pass True, if the administrator's presence in the chat is hidden\n can_manage_chat\t: true, //\tPass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege\n // can_post_messages : true, // Pass True, if the administrator can create channel posts, channels only\n // can_edit_messages : true, // Pass True, if the administrator can edit messages of other users and can pin messages, channels only\n can_delete_messages\t: true, // Pass True, if the administrator can delete messages of other users\n can_manage_voice_chats : true,// Pass True, if the administrator can manage voice chats\n can_restrict_members : true, // Pass True, if the administrator can restrict, ban or unban chat members\n can_promote_members\t: true, // Pass True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)\n can_change_info\t: true, // Pass True, if the administrator can change chat title, photo and other settings\n can_invite_users : true, // Pass True, if the administrator can invite new users to the chat\n can_pin_messages : true, // Pass True, if the administrator can pin messages, supergroups only \n};\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":340,"wires":[["a65f7c544195fe5f"]]},{"id":"6c7f8a0a02dd99e5","type":"function","z":"89e16d21b4d07ec8","name":"/r restrict user","func":"var user = msg.originalMessage.reply_to_message.from.id;\nmsg.payload.type = 'restrictChatMember';\nmsg.payload.content = user;\nmsg.payload.options = {\n can_send_messages : false, // Optional. True, if the user is allowed to send text messages, contacts, locations and venues\n can_send_media_messages : false, // Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages\n can_send_polls : false, // Optional. True, if the user is allowed to send polls, implies can_send_messages\n can_send_other_messages\t: false, // Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages\n can_add_web_page_previews : false, // Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages\n can_change_info : false, // Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups\n can_invite_users : false, // Optional. True, if the user is allowed to invite new users to the chat\n can_pin_messages : false, // Optional. True, if the user is allowed to pin messages. Ignored in public supergroups \n};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":380,"wires":[["a65f7c544195fe5f"]]},{"id":"321bb3180279417f","type":"debug","z":"89e16d21b4d07ec8","name":"unknown command","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":440,"wires":[]},{"id":"fc8a634a58030601","type":"telegram event","z":"89e16d21b4d07ec8","name":"","bot":"3b6bfbc0.423a04","event":"my_chat_member","autoanswer":false,"x":430,"y":740,"wires":[["7cb1c5d5dd2e463e"]]},{"id":"0d429424f9a6204a","type":"comment","z":"89e16d21b4d07ec8","name":"Bot Status Changed","info":"Optional. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.\n\nsee https://core.telegram.org/bots/api#update","x":430,"y":700,"wires":[]},{"id":"eb918922af9be44b","type":"function","z":"89e16d21b4d07ec8","name":"filter for specific events","func":"var type = msg.payload.type;\nswitch(type){\n case 'new_chat_members':\n node.send([msg, null, null]);\n break;\n \n case 'left_chat_member':\n node.send([null, msg, null]);\n break;\n \n default:\n node.send([null, null, msg]);\n break;\n}","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":600,"wires":[["18f1f7b38fc29892"],["1f6715997fbf0d59"],[]],"icon":"node-red/switch.svg"},{"id":"18f1f7b38fc29892","type":"function","z":"89e16d21b4d07ec8","name":"new chat members","func":"// see also https://core.telegram.org/bots/api#user\n\nvar users = msg.payload.content;\n\nfor (const user of users) {\n var name = user.first_name;\n msg.payload.type = 'message';\n msg.payload.content = \"hello \" + name;\n node.send([msg]);\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":580,"wires":[["7cb1c5d5dd2e463e","bfda6a4b2b3f555e"]],"icon":"font-awesome/fa-info"},{"id":"1f6715997fbf0d59","type":"function","z":"89e16d21b4d07ec8","name":"left chat members","func":"// see also https://core.telegram.org/bots/api#user\n\nvar user = msg.payload.user;\n\nvar name = user.first_name;\nmsg.payload.type = 'message';\nmsg.payload.content = \"bye \" + name;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":620,"wires":[["7cb1c5d5dd2e463e","bfda6a4b2b3f555e"]],"icon":"font-awesome/fa-info"},{"id":"5e5990d5ba0f143c","type":"debug","z":"89e16d21b4d07ec8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1150,"y":700,"wires":[]},{"id":"7cb1c5d5dd2e463e","type":"function","z":"89e16d21b4d07ec8","name":"optional log here","func":"// Here you could log your events.\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":700,"wires":[["5e5990d5ba0f143c"]],"icon":"font-awesome/fa-file-text-o"},{"id":"bfda6a4b2b3f555e","type":"telegram sender","z":"89e16d21b4d07ec8","name":"","bot":"3b6bfbc0.423a04","haserroroutput":false,"outputs":1,"x":1010,"y":580,"wires":[[]]},{"id":"3b6bfbc0.423a04","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}] --------------------------------------------------------------------------------