Reformat and translate
This commit is contained in:
parent
beadf36b51
commit
3390e6f093
@ -1 +1,3 @@
|
|||||||
Node-red and telegram (gramjs) integration
|
Node-red and telegram (gramjs) integration
|
||||||
|
|
||||||
|
Fork of `https://github.com/borovlioff/node-red-telegram-account`
|
||||||
|
144
package-lock.json
generated
144
package-lock.json
generated
@ -45,9 +45,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/big-integer": {
|
"node_modules/big-integer": {
|
||||||
"version": "1.6.51",
|
"version": "1.6.52",
|
||||||
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz",
|
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz",
|
||||||
"integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==",
|
"integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.6"
|
"node": ">=0.6"
|
||||||
}
|
}
|
||||||
@ -76,9 +76,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/bufferutil": {
|
"node_modules/bufferutil": {
|
||||||
"version": "4.0.7",
|
"version": "4.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.9.tgz",
|
||||||
"integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==",
|
"integrity": "sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-gyp-build": "^4.3.0"
|
"node-gyp-build": "^4.3.0"
|
||||||
@ -88,12 +88,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/d": {
|
"node_modules/d": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/d/-/d-1.0.2.tgz",
|
||||||
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
"integrity": "sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es5-ext": "^0.10.50",
|
"es5-ext": "^0.10.64",
|
||||||
"type": "^1.0.1"
|
"type": "^2.7.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
@ -164,13 +167,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es5-ext": {
|
"node_modules/es5-ext": {
|
||||||
"version": "0.10.62",
|
"version": "0.10.64",
|
||||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz",
|
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz",
|
||||||
"integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==",
|
"integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es6-iterator": "^2.0.3",
|
"es6-iterator": "^2.0.3",
|
||||||
"es6-symbol": "^3.1.3",
|
"es6-symbol": "^3.1.3",
|
||||||
|
"esniff": "^2.0.1",
|
||||||
"next-tick": "^1.1.0"
|
"next-tick": "^1.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -188,12 +192,38 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es6-symbol": {
|
"node_modules/es6-symbol": {
|
||||||
"version": "3.1.3",
|
"version": "3.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.4.tgz",
|
||||||
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
|
"integrity": "sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==",
|
||||||
|
"dependencies": {
|
||||||
|
"d": "^1.0.2",
|
||||||
|
"ext": "^1.7.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/esniff": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"d": "^1.0.1",
|
"d": "^1.0.1",
|
||||||
"ext": "^1.1.2"
|
"es5-ext": "^0.10.62",
|
||||||
|
"event-emitter": "^0.3.5",
|
||||||
|
"type": "^2.7.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/event-emitter": {
|
||||||
|
"version": "0.3.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
|
||||||
|
"integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==",
|
||||||
|
"dependencies": {
|
||||||
|
"d": "1",
|
||||||
|
"es5-ext": "~0.10.14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ext": {
|
"node_modules/ext": {
|
||||||
@ -204,11 +234,6 @@
|
|||||||
"type": "^2.7.2"
|
"type": "^2.7.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ext/node_modules/type": {
|
|
||||||
"version": "2.7.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz",
|
|
||||||
"integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw=="
|
|
||||||
},
|
|
||||||
"node_modules/graceful-fs": {
|
"node_modules/graceful-fs": {
|
||||||
"version": "4.2.11",
|
"version": "4.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||||
@ -259,16 +284,28 @@
|
|||||||
"node": ">=0.8.19"
|
"node": ">=0.8.19"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ip": {
|
"node_modules/ip-address": {
|
||||||
"version": "2.0.0",
|
"version": "9.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz",
|
||||||
"integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ=="
|
"integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==",
|
||||||
|
"dependencies": {
|
||||||
|
"jsbn": "1.1.0",
|
||||||
|
"sprintf-js": "^1.1.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/is-typedarray": {
|
"node_modules/is-typedarray": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
|
||||||
"integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA=="
|
"integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA=="
|
||||||
},
|
},
|
||||||
|
"node_modules/jsbn": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A=="
|
||||||
|
},
|
||||||
"node_modules/mime": {
|
"node_modules/mime": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz",
|
||||||
@ -291,9 +328,9 @@
|
|||||||
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
||||||
},
|
},
|
||||||
"node_modules/node-gyp-build": {
|
"node_modules/node-gyp-build": {
|
||||||
"version": "4.6.0",
|
"version": "4.8.4",
|
||||||
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
|
||||||
"integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==",
|
"integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==",
|
||||||
"bin": {
|
"bin": {
|
||||||
"node-gyp-build": "bin.js",
|
"node-gyp-build": "bin.js",
|
||||||
"node-gyp-build-optional": "optional.js",
|
"node-gyp-build-optional": "optional.js",
|
||||||
@ -344,27 +381,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/socks": {
|
"node_modules/socks": {
|
||||||
"version": "2.7.1",
|
"version": "2.8.3",
|
||||||
"resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz",
|
||||||
"integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==",
|
"integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ip": "^2.0.0",
|
"ip-address": "^9.0.5",
|
||||||
"smart-buffer": "^4.2.0"
|
"smart-buffer": "^4.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10.13.0",
|
"node": ">= 10.0.0",
|
||||||
"npm": ">= 3.0.0"
|
"npm": ">= 3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/sprintf-js": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
|
||||||
|
"integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA=="
|
||||||
|
},
|
||||||
"node_modules/store2": {
|
"node_modules/store2": {
|
||||||
"version": "2.14.2",
|
"version": "2.14.4",
|
||||||
"resolved": "https://registry.npmjs.org/store2/-/store2-2.14.2.tgz",
|
"resolved": "https://registry.npmjs.org/store2/-/store2-2.14.4.tgz",
|
||||||
"integrity": "sha512-siT1RiqlfQnGqgT/YzXVUNsom9S0H1OX+dpdGN1xkyYATo4I6sep5NmsRD/40s3IIOvlCq6akxkqG82urIZW1w=="
|
"integrity": "sha512-srTItn1GOvyvOycgxjAnPA63FZNwy0PTyUBFMHRM+hVFltAeoh0LmNBz9SZqUS9mMqGk8rfyWyXn3GH5ReJ8Zw=="
|
||||||
},
|
},
|
||||||
"node_modules/telegram": {
|
"node_modules/telegram": {
|
||||||
"version": "2.17.10",
|
"version": "2.26.16",
|
||||||
"resolved": "https://registry.npmjs.org/telegram/-/telegram-2.17.10.tgz",
|
"resolved": "https://registry.npmjs.org/telegram/-/telegram-2.26.16.tgz",
|
||||||
"integrity": "sha512-BeWrH6jrTjtmZtGi63mM2UWwciOivqQknhRIysULVRQkDbo+MW4I2jI6d3sPM5m8Ge9mhjeKg1aVZf2qG4vh2Q==",
|
"integrity": "sha512-5tqL9HicCxRqEi+9JjXBteVDnoZ+1ggsBFxLQTO49aXwTI2d7To7xb2vOU/ahLwgKuE+Db9ra5xDJZ76Kk0NEA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cryptography/aes": "^0.1.1",
|
"@cryptography/aes": "^0.1.1",
|
||||||
"async-mutex": "^0.3.0",
|
"async-mutex": "^0.3.0",
|
||||||
@ -395,14 +437,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tslib": {
|
"node_modules/tslib": {
|
||||||
"version": "2.6.0",
|
"version": "2.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||||
"integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA=="
|
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
|
||||||
},
|
},
|
||||||
"node_modules/type": {
|
"node_modules/type": {
|
||||||
"version": "1.2.0",
|
"version": "2.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz",
|
||||||
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
"integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ=="
|
||||||
},
|
},
|
||||||
"node_modules/typedarray-to-buffer": {
|
"node_modules/typedarray-to-buffer": {
|
||||||
"version": "3.1.5",
|
"version": "3.1.5",
|
||||||
@ -425,13 +467,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/websocket": {
|
"node_modules/websocket": {
|
||||||
"version": "1.0.34",
|
"version": "1.0.35",
|
||||||
"resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz",
|
"resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.35.tgz",
|
||||||
"integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==",
|
"integrity": "sha512-/REy6amwPZl44DDzvRCkaI1q1bIiQB0mEFQLUrhz3z2EK91cp3n72rAjUlrTP0zV22HJIUOVHQGPxhFRjxjt+Q==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bufferutil": "^4.0.1",
|
"bufferutil": "^4.0.1",
|
||||||
"debug": "^2.2.0",
|
"debug": "^2.2.0",
|
||||||
"es5-ext": "^0.10.50",
|
"es5-ext": "^0.10.63",
|
||||||
"typedarray-to-buffer": "^3.1.5",
|
"typedarray-to-buffer": "^3.1.5",
|
||||||
"utf-8-validate": "^5.0.2",
|
"utf-8-validate": "^5.0.2",
|
||||||
"yaeti": "^0.0.6"
|
"yaeti": "^0.0.6"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-telegram-account",
|
"name": "@random-mirrors/node-red-telegram-account",
|
||||||
"version": "1.0.4",
|
"version": "2.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
122
sample/auth.html
122
sample/auth.html
@ -1,7 +1,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('auth', {
|
RED.nodes.registerType("auth", {
|
||||||
category: 'telegram-account',
|
category: "telegram-account",
|
||||||
color: '#a6bbcf',
|
color: "#a6bbcf",
|
||||||
defaults: {
|
defaults: {
|
||||||
api_id: { value: "", required: true },
|
api_id: { value: "", required: true },
|
||||||
api_hash: { value: "", required: true },
|
api_hash: { value: "", required: true },
|
||||||
@ -15,14 +15,14 @@
|
|||||||
return this.name || "Telegram Auth";
|
return this.name || "Telegram Auth";
|
||||||
},
|
},
|
||||||
oneditprepare: function () {
|
oneditprepare: function () {
|
||||||
// Инициализация значений
|
// Initializing Values
|
||||||
$("#node-input-api_id").val(this.api_id || "");
|
$("#node-input-api_id").val(this.api_id || "");
|
||||||
$("#node-input-api_hash").val(this.api_hash || "");
|
$("#node-input-api_hash").val(this.api_hash || "");
|
||||||
$("#node-input-phoneNumber").val(this.phoneNumber || "");
|
$("#node-input-phoneNumber").val(this.phoneNumber || "");
|
||||||
$("#node-input-password").val(this.password || "");
|
$("#node-input-password").val(this.password || "");
|
||||||
},
|
},
|
||||||
oneditsave: function () {
|
oneditsave: function () {
|
||||||
// Сохранение значений
|
// Saving values
|
||||||
this.api_id = $("#node-input-api_id").val();
|
this.api_id = $("#node-input-api_id").val();
|
||||||
this.api_hash = $("#node-input-api_hash").val();
|
this.api_hash = $("#node-input-api_hash").val();
|
||||||
this.phoneNumber = $("#node-input-phoneNumber").val();
|
this.phoneNumber = $("#node-input-phoneNumber").val();
|
||||||
@ -32,96 +32,133 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-template-name="auth">
|
<script type="text/html" data-template-name="auth">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-api_id">
|
<label for="node-input-api_id"> <i class="fa fa-key"></i> API ID </label>
|
||||||
<i class="fa fa-key"></i> API ID
|
<input type="text" id="node-input-api_id" placeholder="Enter your API ID" />
|
||||||
</label>
|
</div>
|
||||||
<input type="text" id="node-input-api_id" placeholder="Enter your API ID">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-api_hash">
|
<label for="node-input-api_hash">
|
||||||
<i class="fa fa-lock"></i> API Hash
|
<i class="fa fa-lock"></i> API Hash
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="node-input-api_hash" placeholder="Enter your API Hash">
|
<input
|
||||||
</div>
|
type="text"
|
||||||
|
id="node-input-api_hash"
|
||||||
|
placeholder="Enter your API Hash"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-phoneNumber">
|
<label for="node-input-phoneNumber">
|
||||||
<i class="fa fa-phone"></i> Phone Number
|
<i class="fa fa-phone"></i> Phone Number
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="node-input-phoneNumber" placeholder="Enter your phone number">
|
<input
|
||||||
</div>
|
type="text"
|
||||||
|
id="node-input-phoneNumber"
|
||||||
|
placeholder="Enter your phone number"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-password">
|
<label for="node-input-password">
|
||||||
<i class="fa fa-unlock-alt"></i> Password (optional)
|
<i class="fa fa-unlock-alt"></i> Password (optional)
|
||||||
</label>
|
</label>
|
||||||
<input type="password" id="node-input-password" placeholder="Enter your password (if any)">
|
<input
|
||||||
</div>
|
type="password"
|
||||||
|
id="node-input-password"
|
||||||
|
placeholder="Enter your password (if any)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong>Note:</strong> This configuration is required for connecting to the Telegram API and starting a session.
|
<strong>Note:</strong> This configuration is required for connecting to the
|
||||||
</p>
|
Telegram API and starting a session.
|
||||||
|
</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/html" data-help-name="auth">
|
<script type="text/html" data-help-name="auth">
|
||||||
<p>The <b>auth</b> node facilitates Telegram API authentication using the <code>telegram</code> library. It allows users to authenticate a session and retrieve a stringSession for future use.</p>
|
<p>
|
||||||
|
The <b>auth</b> node facilitates Telegram API authentication using the
|
||||||
|
<code>telegram</code> library. It allows users to authenticate a session and
|
||||||
|
retrieve a stringSession for future use.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.api_id
|
<dt>
|
||||||
|
payload.api_id
|
||||||
<span class="property-type">number | string</span>
|
<span class="property-type">number | string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The Telegram API ID. Required for authentication.</dd>
|
<dd>The Telegram API ID. Required for authentication.</dd>
|
||||||
|
|
||||||
<dt>payload.api_hash
|
<dt>
|
||||||
|
payload.api_hash
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The Telegram API hash. Required for authentication.</dd>
|
<dd>The Telegram API hash. Required for authentication.</dd>
|
||||||
|
|
||||||
<dt>payload.phoneNumber
|
<dt>
|
||||||
|
payload.phoneNumber
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The phone number associated with the Telegram account.</dd>
|
<dd>The phone number associated with the Telegram account.</dd>
|
||||||
|
|
||||||
<dt>payload.password
|
<dt>
|
||||||
|
payload.password
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The password for two-factor authentication (if enabled on the Telegram account).</dd>
|
<dd>
|
||||||
|
The password for two-factor authentication (if enabled on the Telegram
|
||||||
|
account).
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>topic
|
<dt>
|
||||||
|
topic
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
- <b>"auth_success"</b>: Authentication was successful.
|
- <b>"auth_success"</b>: Authentication was successful. -
|
||||||
- <b>"auth_error"</b>: An error occurred during authentication.
|
<b>"auth_error"</b>: An error occurred during authentication.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>payload
|
<dt>
|
||||||
|
payload
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
For <b>"auth_success"</b>:
|
For <b>"auth_success"</b>:
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>payload.stringSession</code>: The generated session string.</li>
|
<li>
|
||||||
|
<code>payload.stringSession</code>: The generated session string.
|
||||||
|
</li>
|
||||||
<li><code>payload.message</code>: Success message.</li>
|
<li><code>payload.message</code>: Success message.</li>
|
||||||
</ul>
|
</ul>
|
||||||
For <b>"auth_error"</b>:
|
For <b>"auth_error"</b>:
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>payload.error</code>: The error message describing the issue.</li>
|
<li>
|
||||||
|
<code>payload.error</code>: The error message describing the issue.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>To use the <b>auth</b> node, pass the required API credentials and phone number as part of the input message payload. The node will initiate the Telegram authentication flow. If a two-factor password is required, include it in the <code>payload.password</code>.</p>
|
<p>
|
||||||
|
To use the <b>auth</b> node, pass the required API credentials and phone
|
||||||
|
number as part of the input message payload. The node will initiate the
|
||||||
|
Telegram authentication flow. If a two-factor password is required, include
|
||||||
|
it in the <code>payload.password</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>The node temporarily stores the phone code resolver in the flow context under the key <code>phoneCode</code>. This allows subsequent nodes to resolve the phone code using a separate input mechanism, such as user interaction.</p>
|
<p>
|
||||||
|
The node temporarily stores the phone code resolver in the flow context
|
||||||
|
under the key <code>phoneCode</code>. This allows subsequent nodes to
|
||||||
|
resolve the phone code using a separate input mechanism, such as user
|
||||||
|
interaction.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -133,6 +170,11 @@
|
|||||||
"password": "your_password"
|
"password": "your_password"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>This example input payload initiates the authentication process. Upon receiving the phone code, it should be resolved using a dedicated node or interface.</p>
|
>
|
||||||
|
<p>
|
||||||
|
This example input payload initiates the authentication process. Upon
|
||||||
|
receiving the phone code, it should be resolved using a dedicated node or
|
||||||
|
interface.
|
||||||
|
</p>
|
||||||
</script>
|
</script>
|
||||||
|
@ -18,7 +18,6 @@ module.exports = function (RED) {
|
|||||||
connectionRetries: 5,
|
connectionRetries: 5,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let resolvePhoneCode;
|
let resolvePhoneCode;
|
||||||
const context = node.context().flow;
|
const context = node.context().flow;
|
||||||
|
|
||||||
@ -26,26 +25,25 @@ module.exports = function (RED) {
|
|||||||
await client.start({
|
await client.start({
|
||||||
phoneNumber: () => phoneNumber,
|
phoneNumber: () => phoneNumber,
|
||||||
password: () => password,
|
password: () => password,
|
||||||
phoneCode: async () =>{
|
phoneCode: async () => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
resolvePhoneCode = resolve;
|
resolvePhoneCode = resolve;
|
||||||
context.set("phoneCode", resolvePhoneCode);
|
context.set("phoneCode", resolvePhoneCode);
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
onError: (err) => node.error(`Ошибка: ${err.message}`),
|
onError: (err) => node.error(`Error: ${err.message}`),
|
||||||
});
|
});
|
||||||
|
|
||||||
const stringSession = client.session.save(); // Сохраняем сессию
|
const stringSession = client.session.save(); // Save the session
|
||||||
node.send({
|
node.send({
|
||||||
topic: "auth_success",
|
topic: "auth_success",
|
||||||
payload: {
|
payload: {
|
||||||
stringSession,
|
stringSession,
|
||||||
message: "Авторизация прошла успешно!",
|
message: "Authorization was successful!",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
node.error(`Ошибка авторизации: ${error.message}`);
|
node.error(`Authorization error: ${error.message}`);
|
||||||
node.send({
|
node.send({
|
||||||
topic: "auth_error",
|
topic: "auth_error",
|
||||||
payload: {
|
payload: {
|
||||||
|
@ -1,29 +1,26 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('command', {
|
RED.nodes.registerType("command", {
|
||||||
category: 'telegram-account',
|
category: "telegram-account",
|
||||||
color: '#229ED9',
|
color: "#229ED9",
|
||||||
icon: 'tg.png',
|
icon: "tg.png",
|
||||||
align:"right",
|
align: "right",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
config: { type: 'config', required: false },
|
config: { type: "config", required: false },
|
||||||
command: { value: "", required:true },
|
command: { value: "", required: true },
|
||||||
regex:{ value:false }
|
regex: { value: false },
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || 'Command';
|
return this.name || "Command";
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-template-name="command">
|
<script type="text/html" data-template-name="command">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name">
|
<label for="node-input-name"> <i class="fa fa-tag"></i> Name </label>
|
||||||
<i class="fa fa-tag"></i> Name
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-name"
|
id="node-input-name"
|
||||||
@ -32,9 +29,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-config">
|
<label for="node-input-config"> <i class="fa fa-tag"></i> Config </label>
|
||||||
<i class="fa fa-tag"></i> Config
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-config"
|
id="node-input-config"
|
||||||
@ -44,54 +39,85 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-command">
|
<label for="node-input-command"> <i class="fa fa-tag"></i> Message </label>
|
||||||
<i class="fa fa-tag"></i> Message
|
<input type="text" id="node-input-command" placeholder="Message" />
|
||||||
</label>
|
|
||||||
<input type="text" id="node-input-command" placeholder="Message">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="regex">
|
<label for="regex">
|
||||||
<i class="fa fa-cog"></i><span>Regular expression</span>
|
<i class="fa fa-cog"></i><span>Regular expression</span>
|
||||||
</label>
|
</label>
|
||||||
<input type="checkbox" style="display: inline; width: 22px;vertical-align: top;" id="node-input-regex">
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
style="display: inline; width: 22px;vertical-align: top;"
|
||||||
|
id="node-input-regex"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="command">
|
<script type="text/html" data-help-name="command">
|
||||||
<p>The <b>command</b> node listens for specific commands or patterns in Telegram messages and triggers further processing when a match is found. It supports both exact matches and regex-based pattern matching.</p>
|
<p>
|
||||||
|
The <b>command</b> node listens for specific commands or patterns in
|
||||||
|
Telegram messages and triggers further processing when a match is found. It
|
||||||
|
supports both exact matches and regex-based pattern matching.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<p>This node does not take any direct inputs. Instead, it listens for incoming messages from the Telegram bot or user.</p>
|
<p>
|
||||||
|
This node does not take any direct inputs. Instead, it listens for incoming
|
||||||
|
messages from the Telegram bot or user.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.update
|
<dt>
|
||||||
|
payload.update
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The raw Telegram update object, containing the details of the matched message, including text, sender, chat ID, and other metadata.</dd>
|
<dd>
|
||||||
|
The raw Telegram update object, containing the details of the matched
|
||||||
|
message, including text, sender, chat ID, and other metadata.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
<h3>Configuration</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>Command
|
<dt>
|
||||||
|
Command
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The text or pattern to match against incoming messages. For example, <code>/start</code> or <code>/help</code>.</dd>
|
<dd>
|
||||||
|
The text or pattern to match against incoming messages. For example,
|
||||||
|
<code>/start</code> or <code>/help</code>.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>Regex
|
<dt>
|
||||||
|
Regex
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If checked, treats the <b>Command</b> field as a regular expression. This allows for advanced pattern matching (e.g., <code>^/command\\s*</code>).</dd>
|
<dd>
|
||||||
|
If checked, treats the <b>Command</b> field as a regular expression. This
|
||||||
|
allows for advanced pattern matching (e.g., <code>^/command\\s*</code>).
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>Telegram Configuration
|
<dt>
|
||||||
|
Telegram Configuration
|
||||||
<span class="property-type">node</span>
|
<span class="property-type">node</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>A configured Telegram client node to listen for messages. Ensure the client has the necessary permissions and is correctly authenticated.</dd>
|
<dd>
|
||||||
|
A configured Telegram client node to listen for messages. Ensure the
|
||||||
|
client has the necessary permissions and is correctly authenticated.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>The <b>command</b> node integrates with the Telegram API to monitor incoming messages in real time. When a message matches the configured command or regex, the node outputs the Telegram update object for further processing. This is particularly useful for creating bots that respond to specific commands.</p>
|
<p>
|
||||||
|
The <b>command</b> node integrates with the Telegram API to monitor incoming
|
||||||
|
messages in real time. When a message matches the configured command or
|
||||||
|
regex, the node outputs the Telegram update object for further processing.
|
||||||
|
This is particularly useful for creating bots that respond to specific
|
||||||
|
commands.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -112,24 +138,49 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>This example output is triggered when the bot receives the <code>/start</code> command. The <code>update</code> object contains metadata about the message, sender, and chat.</p>
|
>
|
||||||
|
<p>
|
||||||
|
This example output is triggered when the bot receives the
|
||||||
|
<code>/start</code> command. The <code>update</code> object contains
|
||||||
|
metadata about the message, sender, and chat.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Error Handling</h3>
|
<h3>Error Handling</h3>
|
||||||
<p>If the Telegram client fails to authenticate or there is an error in the configuration, the node logs an error message and stops functioning.</p>
|
<p>
|
||||||
|
If the Telegram client fails to authenticate or there is an error in the
|
||||||
|
configuration, the node logs an error message and stops functioning.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Advanced Usage</h3>
|
<h3>Advanced Usage</h3>
|
||||||
<p>By enabling the <b>Regex</b> option, you can create dynamic commands or match patterns such as:</p>
|
<p>
|
||||||
|
By enabling the <b>Regex</b> option, you can create dynamic commands or
|
||||||
|
match patterns such as:
|
||||||
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>^/command\\s*</code>: Matches the command followed by optional whitespace.</li>
|
<li>
|
||||||
<li><code>^/start|/help$</code>: Matches either <code>/start</code> or <code>/help</code>.</li>
|
<code>^/command\\s*</code>: Matches the command followed by optional
|
||||||
|
whitespace.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>^/start|/help$</code>: Matches either <code>/start</code> or
|
||||||
|
<code>/help</code>.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>This makes the <b>command</b> node versatile for building complex Telegram bot functionality.</p>
|
<p>
|
||||||
|
This makes the <b>command</b> node versatile for building complex Telegram
|
||||||
|
bot functionality.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Notes</h3>
|
<h3>Notes</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Ensure the Telegram bot has sufficient permissions to receive messages in the configured chat or channel.</li>
|
<li>
|
||||||
<li>Regular expressions should be carefully tested to avoid unintended matches or errors.</li>
|
Ensure the Telegram bot has sufficient permissions to receive messages in
|
||||||
|
the configured chat or channel.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Regular expressions should be carefully tested to avoid unintended matches
|
||||||
|
or errors.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
const { NewMessage } = require("telegram/events");
|
const { NewMessage } = require("telegram/events");
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (RED) {
|
module.exports = function (RED) {
|
||||||
function Command(config) {
|
function Command(config) {
|
||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
@ -9,45 +8,37 @@ module.exports = function (RED) {
|
|||||||
/** @type {TelegramClient} */
|
/** @type {TelegramClient} */
|
||||||
const client = this.config.client;
|
const client = this.config.client;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.addEventHandler((update) => {
|
client.addEventHandler((update) => {
|
||||||
const message = update.message.message
|
const message = update.message.message;
|
||||||
if (message) {
|
if (message) {
|
||||||
if (config.regex) {
|
if (config.regex) {
|
||||||
const regex = new RegExp(config.command);
|
const regex = new RegExp(config.command);
|
||||||
|
|
||||||
if (regex.test(message)) {
|
if (regex.test(message)) {
|
||||||
|
|
||||||
var msg = {
|
var msg = {
|
||||||
payload: {
|
payload: {
|
||||||
update
|
update,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
}
|
}
|
||||||
} else if (message === config.command) {
|
} else if (message === config.command) {
|
||||||
|
|
||||||
var msg = {
|
var msg = {
|
||||||
payload: {
|
payload: {
|
||||||
update
|
update,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new NewMessage());
|
}, new NewMessage());
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Ошибка авторизации: ' + err.message);
|
node.error("Authorization error: " + err.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
RED.nodes.registerType("command", Command);
|
||||||
|
|
||||||
RED.nodes.registerType('command', Command);
|
|
||||||
};
|
};
|
||||||
|
@ -1,131 +1,299 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('config',{
|
RED.nodes.registerType("config", {
|
||||||
category: 'config',
|
category: "config",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
api_id: {value:"", required:true},
|
api_id: { value: "", required: true },
|
||||||
api_hash: {value:"", required:true},
|
api_hash: { value: "", required: true },
|
||||||
session: {value:"", required:true},
|
session: { value: "", required: true },
|
||||||
useIPV6: {value: undefined},
|
useIPV6: { value: undefined },
|
||||||
timeout: {value: undefined},
|
timeout: { value: undefined },
|
||||||
requestRetries: {value: undefined},
|
requestRetries: { value: undefined },
|
||||||
connectionRetries: {value: undefined},
|
connectionRetries: { value: undefined },
|
||||||
proxy: {value: undefined},
|
proxy: { value: undefined },
|
||||||
downloadRetries: {value: undefined},
|
downloadRetries: { value: undefined },
|
||||||
retryDelay: {value: undefined},
|
retryDelay: { value: undefined },
|
||||||
autoReconnect: {value: undefined},
|
autoReconnect: { value: undefined },
|
||||||
sequentialUpdates: {value: undefined},
|
sequentialUpdates: { value: undefined },
|
||||||
floodSleepThreshold: {value: undefined},
|
floodSleepThreshold: { value: undefined },
|
||||||
deviceModel: {value: undefined},
|
deviceModel: { value: undefined },
|
||||||
systemVersion: {value: undefined},
|
systemVersion: { value: undefined },
|
||||||
appVersion: {value: undefined},
|
appVersion: { value: undefined },
|
||||||
langCode: {value: undefined},
|
langCode: { value: undefined },
|
||||||
systemLangCode: {value: undefined},
|
systemLangCode: { value: undefined },
|
||||||
useWSS: {value: undefined},
|
useWSS: { value: undefined },
|
||||||
maxConcurrentDownloads: {value: undefined},
|
maxConcurrentDownloads: { value: undefined },
|
||||||
securityChecks: {value: undefined},
|
securityChecks: { value: undefined },
|
||||||
testServers: {value: undefined}
|
testServers: { value: undefined },
|
||||||
},
|
},
|
||||||
label: function() {
|
label: function () {
|
||||||
return this.name || "Telegram Client Config";
|
return this.name || "Telegram Client Config";
|
||||||
},
|
},
|
||||||
oneditprepare: function() {
|
oneditprepare: function () {},
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-template-name="config">
|
<script type="text/html" data-template-name="config">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-name"><i class="icon-tasks"></i>Name</label>
|
<label for="node-config-input-name"><i class="icon-tasks"></i>Name</label>
|
||||||
<input type="text" id="node-config-input-name" placeholder="Name" style="width:70%" ng-model="node.api_id">
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-name"
|
||||||
|
placeholder="Name"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.api_id"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-api_id"><i class="icon-tasks"></i> API ID</label>
|
<label for="node-config-input-api_id"
|
||||||
<input type="text" id="node-config-input-api_id" placeholder="Enter API ID" style="width:70%" ng-model="node.api_id">
|
><i class="icon-tasks"></i> API ID</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-api_id"
|
||||||
|
placeholder="Enter API ID"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.api_id"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-api_hash"><i class="icon-tasks"></i> API Hash</label>
|
<label for="node-config-input-api_hash"
|
||||||
<input type="text" id="node-config-input-api_hash" placeholder="Enter API Hash" style="width:70%" ng-model="node.api_hash">
|
><i class="icon-tasks"></i> API Hash</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-api_hash"
|
||||||
|
placeholder="Enter API Hash"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.api_hash"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-session"><i class="icon-tasks"></i> Session</label>
|
<label for="node-config-input-session"
|
||||||
<input type="text" id="node-config-input-session" placeholder="Enter Session" style="width:70%" ng-model="node.session">
|
><i class="icon-tasks"></i> Session</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-session"
|
||||||
|
placeholder="Enter Session"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.session"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-useIPV6"><i class="icon-tasks"></i> Use IPV6</label>
|
<label for="node-config-input-useIPV6"
|
||||||
<input type="checkbox" id="node-config-input-useIPV6" ng-model="node.useIPV6">
|
><i class="icon-tasks"></i> Use IPV6</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-config-input-useIPV6"
|
||||||
|
ng-model="node.useIPV6"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-timeout"><i class="icon-tasks"></i> Timeout</label>
|
<label for="node-config-input-timeout"
|
||||||
<input type="number" id="node-config-input-timeout" placeholder="Enter Timeout" style="width:70%" ng-model="node.timeout">
|
><i class="icon-tasks"></i> Timeout</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="node-config-input-timeout"
|
||||||
|
placeholder="Enter Timeout"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.timeout"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-requestRetries"><i class="icon-tasks"></i> Request Retries</label>
|
<label for="node-config-input-requestRetries"
|
||||||
<input type="number" id="node-config-input-requestRetries" placeholder="Enter Request Retries" style="width:70%" ng-model="node.requestRetries">
|
><i class="icon-tasks"></i> Request Retries</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="node-config-input-requestRetries"
|
||||||
|
placeholder="Enter Request Retries"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.requestRetries"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-connectionRetries"><i class="icon-tasks"></i> Connection Retries</label>
|
<label for="node-config-input-connectionRetries"
|
||||||
<input type="number" id="node-config-input-connectionRetries" placeholder="Enter Connection Retries" style="width:70%" ng-model="node.connectionRetries">
|
><i class="icon-tasks"></i> Connection Retries</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="node-config-input-connectionRetries"
|
||||||
|
placeholder="Enter Connection Retries"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.connectionRetries"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-proxy"><i class="icon-tasks"></i> Proxy</label>
|
<label for="node-config-input-proxy"
|
||||||
<input type="text" id="node-config-input-proxy" placeholder="Enter Proxy" style="width:70%" ng-model="node.proxy">
|
><i class="icon-tasks"></i> Proxy</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-proxy"
|
||||||
|
placeholder="Enter Proxy"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.proxy"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-downloadRetries"><i class="icon-tasks"></i> Download Retries</label>
|
<label for="node-config-input-downloadRetries"
|
||||||
<input type="number" id="node-config-input-downloadRetries" placeholder="Enter Download Retries" style="width:70%" ng-model="node.downloadRetries">
|
><i class="icon-tasks"></i> Download Retries</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="node-config-input-downloadRetries"
|
||||||
|
placeholder="Enter Download Retries"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.downloadRetries"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-retryDelay"><i class="icon-tasks"></i> Retry Delay</label>
|
<label for="node-config-input-retryDelay"
|
||||||
<input type="number" id="node-config-input-retryDelay" placeholder="Enter Retry Delay" style="width:70%" ng-model="node.retryDelay">
|
><i class="icon-tasks"></i> Retry Delay</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="node-config-input-retryDelay"
|
||||||
|
placeholder="Enter Retry Delay"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.retryDelay"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-autoReconnect"><i class="icon-tasks"></i> Auto Reconnect</label>
|
<label for="node-config-input-autoReconnect"
|
||||||
<input type="checkbox" id="node-config-input-autoReconnect" ng-model="node.autoReconnect">
|
><i class="icon-tasks"></i> Auto Reconnect</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-config-input-autoReconnect"
|
||||||
|
ng-model="node.autoReconnect"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-sequentialUpdates"><i class="icon-tasks"></i> Sequential Updates</label>
|
<label for="node-config-input-sequentialUpdates"
|
||||||
<input type="checkbox" id="node-config-input-sequentialUpdates" ng-model="node.sequentialUpdates">
|
><i class="icon-tasks"></i> Sequential Updates</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-config-input-sequentialUpdates"
|
||||||
|
ng-model="node.sequentialUpdates"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-floodSleepThreshold"><i class="icon-tasks"></i> Flood Sleep Threshold</label>
|
<label for="node-config-input-floodSleepThreshold"
|
||||||
<input type="number" id="node-config-input-floodSleepThreshold" placeholder="Enter Flood Sleep Threshold" style="width:70%" ng-model="node.floodSleepThreshold">
|
><i class="icon-tasks"></i> Flood Sleep Threshold</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="node-config-input-floodSleepThreshold"
|
||||||
|
placeholder="Enter Flood Sleep Threshold"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.floodSleepThreshold"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-deviceModel"><i class="icon-tasks"></i> Device Model</label>
|
<label for="node-config-input-deviceModel"
|
||||||
<input type="text" id="node-config-input-deviceModel" placeholder="Enter Device Model" style="width:70%" ng-model="node.deviceModel">
|
><i class="icon-tasks"></i> Device Model</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-deviceModel"
|
||||||
|
placeholder="Enter Device Model"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.deviceModel"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-systemVersion"><i class="icon-tasks"></i> System Version</label>
|
<label for="node-config-input-systemVersion"
|
||||||
<input type="text" id="node-config-input-systemVersion" placeholder="Enter System Version" style="width:70%" ng-model="node.systemVersion">
|
><i class="icon-tasks"></i> System Version</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-systemVersion"
|
||||||
|
placeholder="Enter System Version"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.systemVersion"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-appVersion"><i class="icon-tasks"></i> App Version</label>
|
<label for="node-config-input-appVersion"
|
||||||
<input type="text" id="node-config-input-appVersion" placeholder="Enter App Version" style="width:70%" ng-model="node.appVersion">
|
><i class="icon-tasks"></i> App Version</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-appVersion"
|
||||||
|
placeholder="Enter App Version"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.appVersion"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-langCode"><i class="icon-tasks"></i> Language Code</label>
|
<label for="node-config-input-langCode"
|
||||||
<input type="text" id="node-config-input-langCode" placeholder="Enter Language Code" style="width:70%" ng-model="node.langCode">
|
><i class="icon-tasks"></i> Language Code</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-langCode"
|
||||||
|
placeholder="Enter Language Code"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.langCode"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-systemLangCode"><i class="icon-tasks"></i> System Language Code</label>
|
<label for="node-config-input-systemLangCode"
|
||||||
<input type="text" id="node-config-input-systemLangCode" placeholder="Enter System Language Code" style="width:70%" ng-model="node.systemLangCode">
|
><i class="icon-tasks"></i> System Language Code</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="node-config-input-systemLangCode"
|
||||||
|
placeholder="Enter System Language Code"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.systemLangCode"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-useWSS"><i class="icon-tasks"></i> Use WSS</label>
|
<label for="node-config-input-useWSS"
|
||||||
<input type="checkbox" id="node-config-input-useWSS" ng-model="node.useWSS">
|
><i class="icon-tasks"></i> Use WSS</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-config-input-useWSS"
|
||||||
|
ng-model="node.useWSS"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-maxConcurrentDownloads"><i class="icon-tasks"></i> Max Concurrent Downloads</label>
|
<label for="node-config-input-maxConcurrentDownloads"
|
||||||
<input type="number" id="node-config-input-maxConcurrentDownloads" placeholder="Enter Max Concurrent Downloads" style="width:70%" ng-model="node.maxConcurrentDownloads">
|
><i class="icon-tasks"></i> Max Concurrent Downloads</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="node-config-input-maxConcurrentDownloads"
|
||||||
|
placeholder="Enter Max Concurrent Downloads"
|
||||||
|
style="width:70%"
|
||||||
|
ng-model="node.maxConcurrentDownloads"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-securityChecks"><i class="icon-tasks"></i> Security Checks</label>
|
<label for="node-config-input-securityChecks"
|
||||||
<input type="checkbox" id="node-config-input-securityChecks" ng-model="node.securityChecks">
|
><i class="icon-tasks"></i> Security Checks</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-config-input-securityChecks"
|
||||||
|
ng-model="node.securityChecks"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-testServers"><i class="icon-tasks"></i> Test Servers</label>
|
<label for="node-config-input-testServers"
|
||||||
<input type="checkbox" id="node-config-input-testServers" ng-model="node.testServers">
|
><i class="icon-tasks"></i> Test Servers</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-config-input-testServers"
|
||||||
|
ng-model="node.testServers"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
@ -28,11 +28,12 @@ module.exports = function (RED) {
|
|||||||
this.testServers = config.testServers;
|
this.testServers = config.testServers;
|
||||||
const node = this;
|
const node = this;
|
||||||
|
|
||||||
|
this.client = new TelegramClient(
|
||||||
this.client = new TelegramClient(this.session, parseInt(this.apiId), this.apiHash, {
|
this.session,
|
||||||
|
parseInt(this.apiId),
|
||||||
|
this.apiHash,
|
||||||
});
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.client.connect().then(async () => {
|
this.client.connect().then(async () => {
|
||||||
@ -44,7 +45,7 @@ module.exports = function (RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Authorisation error: ' + err.message);
|
node.error("Authorization error: " + err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.on("close", () => {
|
this.on("close", () => {
|
||||||
@ -54,5 +55,5 @@ module.exports = function (RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType('config', TelegramClientConfig);
|
RED.nodes.registerType("config", TelegramClientConfig);
|
||||||
};
|
};
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('delete-message', {
|
RED.nodes.registerType("delete-message", {
|
||||||
category: 'telegram-account',
|
category: "telegram-account",
|
||||||
color: '#FF5733',
|
color: "#FF5733",
|
||||||
icon: 'tg.png',
|
icon: "tg.png",
|
||||||
align: 'right',
|
align: "right",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
config: { type: 'config', required: false },
|
config: { type: "config", required: false },
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || 'Delete Message';
|
return this.name || "Delete Message";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-template-name="delete-message">
|
<script type="text/html" data-template-name="delete-message">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name">
|
<label for="node-input-name"> <i class="fa fa-tag"></i> Name </label>
|
||||||
<i class="fa fa-tag"></i> Name
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-name"
|
id="node-input-name"
|
||||||
@ -29,9 +27,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-config">
|
<label for="node-input-config"> <i class="fa fa-gear"></i> Config </label>
|
||||||
<i class="fa fa-gear"></i> Config
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="hidden"
|
type="hidden"
|
||||||
id="node-input-config"
|
id="node-input-config"
|
||||||
@ -39,30 +35,43 @@
|
|||||||
style="width: 60%"
|
style="width: 60%"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" data-help-name="delete-message">
|
||||||
<script type="text/html" data-help-name="delete-message">
|
<p>
|
||||||
<p>The <b>delete-message</b> node allows you to delete messages from a Telegram chat. It supports deleting multiple messages at once and provides an option to revoke messages for all chat participants.</p>
|
The <b>delete-message</b> node allows you to delete messages from a Telegram
|
||||||
|
chat. It supports deleting multiple messages at once and provides an option
|
||||||
|
to revoke messages for all chat participants.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.chatId
|
<dt>
|
||||||
|
payload.chatId
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The ID or username of the chat from which the messages will be deleted. Use "me" for personal chats.</dd>
|
<dd>
|
||||||
|
The ID or username of the chat from which the messages will be deleted.
|
||||||
|
Use "me" for personal chats.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.messageIds
|
<dt>
|
||||||
|
payload.messageIds
|
||||||
<span class="property-type">number | array</span>
|
<span class="property-type">number | array</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The ID or an array of IDs of the messages to be deleted.</dd>
|
<dd>The ID or an array of IDs of the messages to be deleted.</dd>
|
||||||
|
|
||||||
<dt>payload.revoke
|
<dt>
|
||||||
|
payload.revoke
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If true, the messages will be deleted for all participants in the chat (revoke). Defaults to true.</dd>
|
<dd>
|
||||||
|
If true, the messages will be deleted for all participants in the chat
|
||||||
|
(revoke). Defaults to true.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.client
|
<dt>
|
||||||
|
payload.client
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An optional Telegram client instance if not configured globally.</dd>
|
<dd>An optional Telegram client instance if not configured globally.</dd>
|
||||||
@ -70,14 +79,20 @@
|
|||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload
|
<dt>
|
||||||
|
payload
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The response from the Telegram API, confirming the deletion.</dd>
|
<dd>The response from the Telegram API, confirming the deletion.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>The <b>delete-message</b> node uses the Telegram API to delete messages from a specified chat. It can delete a single message or multiple messages at once. If the <code>revoke</code> parameter is set to true, the messages will be removed for all participants, not just the sender.</p>
|
<p>
|
||||||
|
The <b>delete-message</b> node uses the Telegram API to delete messages from
|
||||||
|
a specified chat. It can delete a single message or multiple messages at
|
||||||
|
once. If the <code>revoke</code> parameter is set to true, the messages will
|
||||||
|
be removed for all participants, not just the sender.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -88,9 +103,17 @@
|
|||||||
"revoke": true
|
"revoke": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>This input deletes the messages with IDs 12345 and 12346 from the chat with the user <code>@example_user</code>, revoking them for all participants.</p>
|
>
|
||||||
|
<p>
|
||||||
|
This input deletes the messages with IDs 12345 and 12346 from the chat with
|
||||||
|
the user <code>@example_user</code>, revoking them for all participants.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
<h3>Configuration</h3>
|
||||||
<p>The node can use a globally configured Telegram client or a client instance provided in the message payload. Ensure that the client has the necessary permissions to delete messages from the specified chat.</p>
|
<p>
|
||||||
|
The node can use a globally configured Telegram client or a client instance
|
||||||
|
provided in the message payload. Ensure that the client has the necessary
|
||||||
|
permissions to delete messages from the specified chat.
|
||||||
|
</p>
|
||||||
</script>
|
</script>
|
||||||
|
@ -4,24 +4,30 @@ module.exports = function (RED) {
|
|||||||
this.config = RED.nodes.getNode(config.config);
|
this.config = RED.nodes.getNode(config.config);
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
this.on('input', async function (msg) {
|
this.on("input", async function (msg) {
|
||||||
const chatId = msg.payload.chatId || config.chatId;
|
const chatId = msg.payload.chatId || config.chatId;
|
||||||
const messageIds = msg.payload.messageIds || config.messageIds;
|
const messageIds = msg.payload.messageIds || config.messageIds;
|
||||||
const revoke = msg.payload.revoke || config.revoke || { revoke: true };
|
const revoke = msg.payload.revoke || config.revoke || { revoke: true };
|
||||||
/** @type {TelegramClient} */
|
/** @type {TelegramClient} */
|
||||||
const client = msg.payload?.client ? msg.payload.client : this.config.client;
|
const client = msg.payload?.client
|
||||||
|
? msg.payload.client
|
||||||
|
: this.config.client;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await client.deleteMessages(chatId, messageIds, revoke);
|
const response = await client.deleteMessages(
|
||||||
|
chatId,
|
||||||
|
messageIds,
|
||||||
|
revoke
|
||||||
|
);
|
||||||
|
|
||||||
node.send({
|
node.send({
|
||||||
payload: response,
|
payload: response,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Error deleting message: ' + err.message);
|
node.error("Error deleting message: " + err.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType('delete-message', DeleteMessage);
|
RED.nodes.registerType("delete-message", DeleteMessage);
|
||||||
};
|
};
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('get-entity', {
|
RED.nodes.registerType("get-entity", {
|
||||||
category: 'telegram-account',
|
category: "telegram-account",
|
||||||
color: '#229ED9',
|
color: "#229ED9",
|
||||||
icon: 'tg.png',
|
icon: "tg.png",
|
||||||
align: "right",
|
align: "right",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
config: { type: 'config', required: false },
|
config: { type: "config", required: false },
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || 'Get Entity';
|
return this.name || "Get Entity";
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-template-name="get-entity">
|
<script type="text/html" data-template-name="get-entity">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name">
|
<label for="node-input-name"> <i class="fa fa-tag"></i> Name </label>
|
||||||
<i class="fa fa-tag"></i> Name
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-name"
|
id="node-input-name"
|
||||||
@ -29,9 +27,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-config">
|
<label for="node-input-config"> <i class="fa fa-tag"></i> Config </label>
|
||||||
<i class="fa fa-tag"></i> Config
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-config"
|
id="node-input-config"
|
||||||
@ -42,16 +38,25 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="get-entity">
|
<script type="text/html" data-help-name="get-entity">
|
||||||
<p>The <b>get-entity</b> node retrieves information about a Telegram entity (e.g., user, chat, or channel) using its identifier or URL.</p>
|
<p>
|
||||||
|
The <b>get-entity</b> node retrieves information about a Telegram entity
|
||||||
|
(e.g., user, chat, or channel) using its identifier or URL.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.input
|
<dt>
|
||||||
|
payload.input
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The identifier (username, user ID, chat ID, or channel ID) or URL of the Telegram entity to retrieve. For example, "123456789", "@example_user", or "https://t.me/example_channel".</dd>
|
<dd>
|
||||||
|
The identifier (username, user ID, chat ID, or channel ID) or URL of the
|
||||||
|
Telegram entity to retrieve. For example, "123456789", "@example_user", or
|
||||||
|
"https://t.me/example_channel".
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.client
|
<dt>
|
||||||
|
payload.client
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An optional Telegram client instance if not configured globally.</dd>
|
<dd>An optional Telegram client instance if not configured globally.</dd>
|
||||||
@ -59,14 +64,24 @@
|
|||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.input
|
<dt>
|
||||||
|
payload.input
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The retrieved entity object containing details about the user, chat, or channel.</dd>
|
<dd>
|
||||||
|
The retrieved entity object containing details about the user, chat, or
|
||||||
|
channel.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>The <b>get-entity</b> node uses the Telegram API to fetch details about a specified entity. If the input is a Telegram URL (e.g., "https://t.me/example_user"), the node extracts the username or channel name and fetches the corresponding entity. For non-URL inputs, it directly retrieves the entity using the provided identifier.</p>
|
<p>
|
||||||
|
The <b>get-entity</b> node uses the Telegram API to fetch details about a
|
||||||
|
specified entity. If the input is a Telegram URL (e.g.,
|
||||||
|
"https://t.me/example_user"), the node extracts the username or channel name
|
||||||
|
and fetches the corresponding entity. For non-URL inputs, it directly
|
||||||
|
retrieves the entity using the provided identifier.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -75,13 +90,24 @@
|
|||||||
"input": "https://t.me/example_user"
|
"input": "https://t.me/example_user"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>This input retrieves the entity information for the Telegram user <code>example_user</code>.</p>
|
>
|
||||||
|
<p>
|
||||||
|
This input retrieves the entity information for the Telegram user
|
||||||
|
<code>example_user</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Error Handling</h3>
|
<h3>Error Handling</h3>
|
||||||
<p>If an error occurs while retrieving the entity (e.g., the identifier is invalid or the entity does not exist), the node logs an error and sends a message with <code>payload.input</code> set to <code>null</code>.</p>
|
<p>
|
||||||
|
If an error occurs while retrieving the entity (e.g., the identifier is
|
||||||
|
invalid or the entity does not exist), the node logs an error and sends a
|
||||||
|
message with <code>payload.input</code> set to <code>null</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
<h3>Configuration</h3>
|
||||||
<p>The node can use a globally configured Telegram client or a client instance provided in the message payload. Ensure the client has the necessary permissions to access the requested entity.</p>
|
<p>
|
||||||
|
The node can use a globally configured Telegram client or a client instance
|
||||||
|
provided in the message payload. Ensure the client has the necessary
|
||||||
|
permissions to access the requested entity.
|
||||||
|
</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -4,33 +4,35 @@ module.exports = function (RED) {
|
|||||||
this.config = RED.nodes.getNode(config.config);
|
this.config = RED.nodes.getNode(config.config);
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
this.on('input', async function (msg) {
|
this.on("input", async function (msg) {
|
||||||
const input = msg.payload.input || config.input;
|
const input = msg.payload.input || config.input;
|
||||||
/** @type {TelegramClient} */
|
/** @type {TelegramClient} */
|
||||||
const client = msg.payload?.client ? msg.payload.client : this.config.client;
|
const client = msg.payload?.client
|
||||||
|
? msg.payload.client
|
||||||
|
: this.config.client;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let entity;
|
let entity;
|
||||||
|
|
||||||
// Check if the input is a URL
|
// Check if the input is a URL
|
||||||
if (input.includes('https://t.me/')) {
|
if (input.includes("https://t.me/")) {
|
||||||
const username = input.split('/').pop();
|
const username = input.split("/").pop();
|
||||||
entity = await client.getEntity(username);
|
entity = await client.getEntity(username);
|
||||||
} else {
|
} else {
|
||||||
entity = await client.getEntity(input);
|
entity = await client.getEntity(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
node.send({
|
node.send({
|
||||||
payload: {input:entity},
|
payload: { input: entity },
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Error getting entity: ' + err.message);
|
node.error("Error getting entity: " + err.message);
|
||||||
node.send({
|
node.send({
|
||||||
payload:{ input: null}
|
payload: { input: null },
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType('get-entity', GetEntity);
|
RED.nodes.registerType("get-entity", GetEntity);
|
||||||
};
|
};
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('iter-dialogs', {
|
RED.nodes.registerType("iter-dialogs", {
|
||||||
category: 'telegram',
|
category: "telegram",
|
||||||
color: '#32a3e0',
|
color: "#32a3e0",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
config: { type: 'config', required: true },
|
config: { type: "config", required: true },
|
||||||
limit: { value: "" },
|
limit: { value: "" },
|
||||||
offsetDate: { value: ""},
|
offsetDate: { value: "" },
|
||||||
offsetId: { value: "" },
|
offsetId: { value: "" },
|
||||||
ignorePinned: { value: false },
|
ignorePinned: { value: false },
|
||||||
ignoreMigrated: { value: false },
|
ignoreMigrated: { value: false },
|
||||||
@ -15,18 +15,16 @@
|
|||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
paletteLabel: 'Iterate Dialogs',
|
paletteLabel: "Iterate Dialogs",
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || 'Iterate Dialogs';
|
return this.name || "Iterate Dialogs";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-template-name="iter-dialogs">
|
<script type="text/html" data-template-name="iter-dialogs">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name">
|
<label for="node-input-name"> <i class="fa fa-tag"></i> Name </label>
|
||||||
<i class="fa fa-tag"></i> Name
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-name"
|
id="node-input-name"
|
||||||
@ -36,9 +34,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-config">
|
<label for="node-input-config"> <i class="fa fa-tag"></i> Config </label>
|
||||||
<i class="fa fa-tag"></i> Config
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-config"
|
id="node-input-config"
|
||||||
@ -48,9 +44,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-limit">
|
<label for="node-input-limit"> <i class="fa fa-tag"></i> Limit </label>
|
||||||
<i class="fa fa-tag"></i> Limit
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-limit"
|
id="node-input-limit"
|
||||||
@ -104,9 +98,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-folder">
|
<label for="node-input-folder"> <i class="fa fa-tag"></i> Folder </label>
|
||||||
<i class="fa fa-tag"></i> Folder
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-folder"
|
id="node-input-folder"
|
||||||
@ -119,77 +111,111 @@
|
|||||||
<label for="node-input-archived">
|
<label for="node-input-archived">
|
||||||
<i class="fa fa-tag"></i> Archived
|
<i class="fa fa-tag"></i> Archived
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input type="checkbox" id="node-input-archived" ng-model="archived" />
|
||||||
type="checkbox"
|
|
||||||
id="node-input-archived"
|
|
||||||
ng-model="archived"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="iter-dialogs">
|
<script type="text/html" data-help-name="iter-dialogs">
|
||||||
<p>The <b>iter-dialogs</b> node retrieves a list of Telegram dialogs (chats, channels, or groups) by iterating through them using the Telegram API.</p>
|
<p>
|
||||||
|
The <b>iter-dialogs</b> node retrieves a list of Telegram dialogs (chats,
|
||||||
|
channels, or groups) by iterating through them using the Telegram API.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.client
|
<dt>
|
||||||
|
payload.client
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An optional Telegram client instance if not configured globally.</dd>
|
<dd>An optional Telegram client instance if not configured globally.</dd>
|
||||||
|
|
||||||
<dt>payload.limit
|
<dt>
|
||||||
|
payload.limit
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Limits the number of dialogs to retrieve. Default is no limit.</dd>
|
<dd>Limits the number of dialogs to retrieve. Default is no limit.</dd>
|
||||||
|
|
||||||
<dt>payload.offsetDate
|
<dt>
|
||||||
|
payload.offsetDate
|
||||||
<span class="property-type">string | number</span>
|
<span class="property-type">string | number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Fetch dialogs starting from this date. Provide a UNIX timestamp or a date string.</dd>
|
<dd>
|
||||||
|
Fetch dialogs starting from this date. Provide a UNIX timestamp or a date
|
||||||
|
string.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.offsetId
|
<dt>
|
||||||
|
payload.offsetId
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Fetch dialogs starting from this message ID.</dd>
|
<dd>Fetch dialogs starting from this message ID.</dd>
|
||||||
|
|
||||||
<dt>payload.offsetPeer
|
<dt>
|
||||||
|
payload.offsetPeer
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The peer object to start retrieving dialogs from.</dd>
|
<dd>The peer object to start retrieving dialogs from.</dd>
|
||||||
|
|
||||||
<dt>payload.ignorePinned
|
<dt>
|
||||||
|
payload.ignorePinned
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Ignores pinned dialogs if set to <code>true</code>. Default is <code>false</code>.</dd>
|
<dd>
|
||||||
|
Ignores pinned dialogs if set to <code>true</code>. Default is
|
||||||
|
<code>false</code>.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.ignoreMigrated
|
<dt>
|
||||||
|
payload.ignoreMigrated
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Ignores migrated chats if set to <code>true</code>. Default is <code>false</code>.</dd>
|
<dd>
|
||||||
|
Ignores migrated chats if set to <code>true</code>. Default is
|
||||||
|
<code>false</code>.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.folder
|
<dt>
|
||||||
|
payload.folder
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Retrieves dialogs from a specific folder by folder ID.</dd>
|
<dd>Retrieves dialogs from a specific folder by folder ID.</dd>
|
||||||
|
|
||||||
<dt>payload.archived
|
<dt>
|
||||||
|
payload.archived
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Includes archived dialogs if set to <code>true</code>. Default is <code>false</code>.</dd>
|
<dd>
|
||||||
|
Includes archived dialogs if set to <code>true</code>. Default is
|
||||||
|
<code>false</code>.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.dialogs
|
<dt>
|
||||||
|
payload.dialogs
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An object containing dialogs, where keys are dialog IDs and values are dialog details.</dd>
|
<dd>
|
||||||
|
An object containing dialogs, where keys are dialog IDs and values are
|
||||||
|
dialog details.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>The <b>iter-dialogs</b> node uses the Telegram API to iterate over all available dialogs. It allows filtering by various parameters, such as the number of dialogs to retrieve (<code>limit</code>), starting date or message (<code>offsetDate</code>, <code>offsetId</code>), and additional flags like <code>ignorePinned</code> or <code>archived</code>.</p>
|
<p>
|
||||||
|
The <b>iter-dialogs</b> node uses the Telegram API to iterate over all
|
||||||
|
available dialogs. It allows filtering by various parameters, such as the
|
||||||
|
number of dialogs to retrieve (<code>limit</code>), starting date or message
|
||||||
|
(<code>offsetDate</code>, <code>offsetId</code>), and additional flags like
|
||||||
|
<code>ignorePinned</code> or <code>archived</code>.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>It supports advanced configurations such as folder-specific retrieval and skipping migrated chats, providing granular control over the dialogs to be processed.</p>
|
<p>
|
||||||
|
It supports advanced configurations such as folder-specific retrieval and
|
||||||
|
skipping migrated chats, providing granular control over the dialogs to be
|
||||||
|
processed.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -200,13 +226,23 @@
|
|||||||
"archived": true
|
"archived": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>This input retrieves up to 10 archived dialogs starting from December 1, 2023.</p>
|
>
|
||||||
|
<p>
|
||||||
|
This input retrieves up to 10 archived dialogs starting from December 1,
|
||||||
|
2023.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Error Handling</h3>
|
<h3>Error Handling</h3>
|
||||||
<p>If an error occurs during dialog retrieval (e.g., invalid parameters or API limitations), the node logs an error message and does not return a payload.</p>
|
<p>
|
||||||
|
If an error occurs during dialog retrieval (e.g., invalid parameters or API
|
||||||
|
limitations), the node logs an error message and does not return a payload.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
<h3>Configuration</h3>
|
||||||
<p>The node can use a globally configured Telegram client or a client instance provided in the message payload. Ensure the client has sufficient permissions to access the dialogs.</p>
|
<p>
|
||||||
|
The node can use a globally configured Telegram client or a client instance
|
||||||
|
provided in the message payload. Ensure the client has sufficient
|
||||||
|
permissions to access the dialogs.
|
||||||
|
</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -6,29 +6,31 @@ module.exports = function (RED) {
|
|||||||
this.config = RED.nodes.getNode(config.config);
|
this.config = RED.nodes.getNode(config.config);
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
this.on('input', async function (msg) {
|
this.on("input", async function (msg) {
|
||||||
|
|
||||||
/** @type {TelegramClient} */
|
/** @type {TelegramClient} */
|
||||||
const client = msg.payload?.client ? msg.payload.client : this.config.client;
|
const client = msg.payload?.client
|
||||||
|
? msg.payload.client
|
||||||
|
: this.config.client;
|
||||||
const limit = msg.payload.limit || config.limit;
|
const limit = msg.payload.limit || config.limit;
|
||||||
const offsetDate = msg.payload.offsetDate || config.offsetDate;
|
const offsetDate = msg.payload.offsetDate || config.offsetDate;
|
||||||
const offsetId = msg.payload.offsetId || config.offsetId;
|
const offsetId = msg.payload.offsetId || config.offsetId;
|
||||||
const offsetPeer = msg.payload?.offsetPeer || undefined;
|
const offsetPeer = msg.payload?.offsetPeer || undefined;
|
||||||
const ignorePinned = msg.payload.ignorePinned || config.ignorePinned;
|
const ignorePinned = msg.payload.ignorePinned || config.ignorePinned;
|
||||||
const ignoreMigrated = msg.payload.ignoreMigrated || config.ignoreMigrated;
|
const ignoreMigrated =
|
||||||
|
msg.payload.ignoreMigrated || config.ignoreMigrated;
|
||||||
const folder = msg.payload.folder || config.folder;
|
const folder = msg.payload.folder || config.folder;
|
||||||
const archived = msg.payload.archived || config.archived;
|
const archived = msg.payload.archived || config.archived;
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
limit: limit !== ""? parseInt(limit) : undefined,
|
limit: limit !== "" ? parseInt(limit) : undefined,
|
||||||
offsetDate: offsetDate !== "" ? offsetDate:undefined,
|
offsetDate: offsetDate !== "" ? offsetDate : undefined,
|
||||||
offsetId: offsetId !== "" ? parseInt(offsetId):undefined,
|
offsetId: offsetId !== "" ? parseInt(offsetId) : undefined,
|
||||||
offsetPeer: offsetPeer,
|
offsetPeer: offsetPeer,
|
||||||
ignorePinned: ignorePinned,
|
ignorePinned: ignorePinned,
|
||||||
ignoreMigrated: ignoreMigrated,
|
ignoreMigrated: ignoreMigrated,
|
||||||
folder: folder !== "" ? parseInt(folder):undefined,
|
folder: folder !== "" ? parseInt(folder) : undefined,
|
||||||
archived: archived,
|
archived: archived,
|
||||||
}
|
};
|
||||||
|
|
||||||
if (offsetDate) {
|
if (offsetDate) {
|
||||||
params.offsetDate = new Date(offsetDate).getTime() / 1000;
|
params.offsetDate = new Date(offsetDate).getTime() / 1000;
|
||||||
@ -36,7 +38,7 @@ module.exports = function (RED) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const dialogs = {};
|
const dialogs = {};
|
||||||
for await (const dialog of client.iterDialogs(params)){
|
for await (const dialog of client.iterDialogs(params)) {
|
||||||
dialogs[dialog.id] = dialog;
|
dialogs[dialog.id] = dialog;
|
||||||
console.log(`${dialog.id}: ${dialog.title}`);
|
console.log(`${dialog.id}: ${dialog.title}`);
|
||||||
}
|
}
|
||||||
@ -44,11 +46,10 @@ module.exports = function (RED) {
|
|||||||
payload: { dialogs },
|
payload: { dialogs },
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Error iter dialogs: ' + err.message);
|
node.error("Error iter dialogs: " + err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType('iter-dialogs', IterDialogs);
|
RED.nodes.registerType("iter-dialogs", IterDialogs);
|
||||||
};
|
};
|
||||||
|
@ -1,41 +1,41 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('iter-messages', {
|
RED.nodes.registerType("iter-messages", {
|
||||||
category: 'telegram',
|
category: "telegram",
|
||||||
color: '#32a3e0',
|
color: "#32a3e0",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
config: { type: 'config', required: true },
|
config: { type: "config", required: true },
|
||||||
chatId: { value: '', required: false },
|
chatId: { value: "", required: false },
|
||||||
limit: { value: '', required: false },
|
limit: { value: "", required: false },
|
||||||
offsetDate: { value: '', required: false },
|
offsetDate: { value: "", required: false },
|
||||||
offsetId: { value: '', required: false },
|
offsetId: { value: "", required: false },
|
||||||
maxId: { value: '', required: false },
|
maxId: { value: "", required: false },
|
||||||
minId: { value: '', required: false },
|
minId: { value: "", required: false },
|
||||||
addOffset: { value: '', required: false },
|
addOffset: { value: "", required: false },
|
||||||
search: { value: '', required: false },
|
search: { value: "", required: false },
|
||||||
filter: { value: '', required: false },
|
filter: { value: "", required: false },
|
||||||
fromUser: { value: '', required: false },
|
fromUser: { value: "", required: false },
|
||||||
waitTime: { value: '', required: false },
|
waitTime: { value: "", required: false },
|
||||||
ids: { value: '', required: false },
|
ids: { value: "", required: false },
|
||||||
reverse: { value: '', required: false },
|
reverse: { value: "", required: false },
|
||||||
replyTo: { value: '', required: false },
|
replyTo: { value: "", required: false },
|
||||||
scheduled: { value: '', required: false }
|
scheduled: { value: "", required: false },
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
paletteLabel: 'Iterate Messages',
|
paletteLabel: "Iterate Messages",
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || 'Iterate Messages';
|
return this.name || "Iterate Messages";
|
||||||
},
|
},
|
||||||
oneditprepare: function(){
|
oneditprepare: function () {
|
||||||
const node = this;
|
const node = this;
|
||||||
$("#node-input-ids").val(node.ids.join(","))
|
$("#node-input-ids").val(node.ids.join(","));
|
||||||
},
|
},
|
||||||
oneditsave:function(){
|
oneditsave: function () {
|
||||||
const node = this;
|
const node = this;
|
||||||
ids = $("#node-input-ids").val();
|
ids = $("#node-input-ids").val();
|
||||||
if(ids){
|
if (ids) {
|
||||||
node.ids = ids.split(",").map(id => parseInt(id))
|
node.ids = ids.split(",").map((id) => parseInt(id));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -43,9 +43,7 @@
|
|||||||
|
|
||||||
<script type="text/html" data-template-name="iter-messages">
|
<script type="text/html" data-template-name="iter-messages">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name">
|
<label for="node-input-name"> <i class="fa fa-tag"></i> Name </label>
|
||||||
<i class="fa fa-tag"></i> Name
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-name"
|
id="node-input-name"
|
||||||
@ -55,9 +53,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-config">
|
<label for="node-input-config"> <i class="fa fa-tag"></i> Config </label>
|
||||||
<i class="fa fa-tag"></i> Config
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-config"
|
id="node-input-config"
|
||||||
@ -67,9 +63,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-chatId">
|
<label for="node-input-chatId"> <i class="fa fa-tag"></i> Chat ID </label>
|
||||||
<i class="fa fa-tag"></i> Chat ID
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-chatId"
|
id="node-input-chatId"
|
||||||
@ -79,9 +73,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-limit">
|
<label for="node-input-limit"> <i class="fa fa-tag"></i> Limit </label>
|
||||||
<i class="fa fa-tag"></i> Limit
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="node-input-limit"
|
id="node-input-limit"
|
||||||
@ -115,9 +107,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-maxId">
|
<label for="node-input-maxId"> <i class="fa fa-tag"></i> Max ID </label>
|
||||||
<i class="fa fa-tag"></i> Max ID
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="node-input-maxId"
|
id="node-input-maxId"
|
||||||
@ -127,9 +117,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-minId">
|
<label for="node-input-minId"> <i class="fa fa-tag"></i> Min ID </label>
|
||||||
<i class="fa fa-tag"></i> Min ID
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="node-input-minId"
|
id="node-input-minId"
|
||||||
@ -151,9 +139,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-search">
|
<label for="node-input-search"> <i class="fa fa-tag"></i> Search </label>
|
||||||
<i class="fa fa-tag"></i> Search
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-search"
|
id="node-input-search"
|
||||||
@ -163,27 +149,92 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-filter">
|
<label for="node-input-filter"> <i class="fa fa-tag"></i> Filter </label>
|
||||||
<i class="fa fa-tag"></i> Filter
|
<input
|
||||||
</label>
|
type="checkbox"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterEmpty">Empty<br>
|
name="filter"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterPhotos">Photos<br>
|
value="InputMessagesFilterEmpty"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterVideo">Video<br>
|
/>Empty<br />
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterPhotoVideo">Photo and Video<br>
|
<input
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterDocument">Document<br>
|
type="checkbox"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterUrl">URL<br>
|
name="filter"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterGif">GIF<br>
|
value="InputMessagesFilterPhotos"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterVoice">Voice<br>
|
/>Photos<br />
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterMusic">Music<br>
|
<input
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterChatPhotos">Chat Photos<br>
|
type="checkbox"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterPhoneCalls">Phone Calls<br>
|
name="filter"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterRoundVoice">Round Voice<br>
|
value="InputMessagesFilterVideo"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterRoundVideo">Round Video<br>
|
/>Video<br />
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterMyMentions">My Mentions<br>
|
<input
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterGeo">Geo<br>
|
type="checkbox"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterContacts">Contacts<br>
|
name="filter"
|
||||||
<input type="checkbox" name="filter" value="InputMessagesFilterPinned">Pinned<br>
|
value="InputMessagesFilterPhotoVideo"
|
||||||
|
/>Photo and Video<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterDocument"
|
||||||
|
/>Document<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterUrl"
|
||||||
|
/>URL<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterGif"
|
||||||
|
/>GIF<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterVoice"
|
||||||
|
/>Voice<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterMusic"
|
||||||
|
/>Music<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterChatPhotos"
|
||||||
|
/>Chat Photos<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterPhoneCalls"
|
||||||
|
/>Phone Calls<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterRoundVoice"
|
||||||
|
/>Round Voice<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterRoundVideo"
|
||||||
|
/>Round Video<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterMyMentions"
|
||||||
|
/>My Mentions<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterGeo"
|
||||||
|
/>Geo<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterContacts"
|
||||||
|
/>Contacts<br />
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="filter"
|
||||||
|
value="InputMessagesFilterPinned"
|
||||||
|
/>Pinned<br />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-fromUser">
|
<label for="node-input-fromUser">
|
||||||
@ -210,9 +261,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-ids">
|
<label for="node-input-ids"> <i class="fa fa-tag"></i> IDs </label>
|
||||||
<i class="fa fa-tag"></i> IDs
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-ids"
|
id="node-input-ids"
|
||||||
@ -222,19 +271,11 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-reverse">
|
<label for="node-input-reverse"> <i class="fa fa-tag"></i> Reverse </label>
|
||||||
<i class="fa fa-tag"></i> Reverse
|
<input type="checkbox" id="node-input-reverse" ng-model="reverse" />
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
id="node-input-reverse"
|
|
||||||
ng-model="reverse"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-replyTo">
|
<label for="node-input-replyTo"> <i class="fa fa-tag"></i> Reply To </label>
|
||||||
<i class="fa fa-tag"></i> Reply To
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="node-input-replyTo"
|
id="node-input-replyTo"
|
||||||
@ -247,85 +288,113 @@
|
|||||||
<label for="node-input-scheduled">
|
<label for="node-input-scheduled">
|
||||||
<i class="fa fa-tag"></i> Scheduled
|
<i class="fa fa-tag"></i> Scheduled
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input type="checkbox" id="node-input-scheduled" ng-model="scheduled" />
|
||||||
type="checkbox"
|
|
||||||
id="node-input-scheduled"
|
|
||||||
ng-model="scheduled"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="iter-messages">
|
<script type="text/html" data-help-name="iter-messages">
|
||||||
<p>The <b>iter-messages</b> node retrieves messages from a specified chat or user using the Telegram API. It supports a wide range of filtering and pagination options, allowing for efficient message iteration.</p>
|
<p>
|
||||||
|
The <b>iter-messages</b> node retrieves messages from a specified chat or
|
||||||
|
user using the Telegram API. It supports a wide range of filtering and
|
||||||
|
pagination options, allowing for efficient message iteration.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.client
|
<dt>
|
||||||
|
payload.client
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An optional Telegram client instance if not configured globally.</dd>
|
<dd>An optional Telegram client instance if not configured globally.</dd>
|
||||||
|
|
||||||
<dt>payload.chatId
|
<dt>
|
||||||
|
payload.chatId
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The ID or username of the chat or user to retrieve messages from. Use "me" for personal messages.</dd>
|
<dd>
|
||||||
|
The ID or username of the chat or user to retrieve messages from. Use "me"
|
||||||
|
for personal messages.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.limit
|
<dt>
|
||||||
|
payload.limit
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Maximum number of messages to retrieve.</dd>
|
<dd>Maximum number of messages to retrieve.</dd>
|
||||||
|
|
||||||
<dt>payload.offsetDate
|
<dt>
|
||||||
|
payload.offsetDate
|
||||||
<span class="property-type">string | number</span>
|
<span class="property-type">string | number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Fetch messages starting from this date. Accepts a UNIX timestamp or a date string.</dd>
|
<dd>
|
||||||
|
Fetch messages starting from this date. Accepts a UNIX timestamp or a date
|
||||||
|
string.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.offsetId
|
<dt>
|
||||||
|
payload.offsetId
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Fetch messages starting from this message ID.</dd>
|
<dd>Fetch messages starting from this message ID.</dd>
|
||||||
|
|
||||||
<dt>payload.maxId
|
<dt>
|
||||||
|
payload.maxId
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Fetch messages with IDs less than or equal to this value.</dd>
|
<dd>Fetch messages with IDs less than or equal to this value.</dd>
|
||||||
|
|
||||||
<dt>payload.minId
|
<dt>
|
||||||
|
payload.minId
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Fetch messages with IDs greater than or equal to this value.</dd>
|
<dd>Fetch messages with IDs greater than or equal to this value.</dd>
|
||||||
|
|
||||||
<dt>payload.addOffset
|
<dt>
|
||||||
|
payload.addOffset
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An additional offset to apply when retrieving messages.</dd>
|
<dd>An additional offset to apply when retrieving messages.</dd>
|
||||||
|
|
||||||
<dt>payload.search
|
<dt>
|
||||||
|
payload.search
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Filters messages containing the specified search term.</dd>
|
<dd>Filters messages containing the specified search term.</dd>
|
||||||
|
|
||||||
<dt>payload.filter
|
<dt>
|
||||||
|
payload.filter
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Applies a specific message filter (e.g., photos, videos, documents).</dd>
|
<dd>
|
||||||
|
Applies a specific message filter (e.g., photos, videos, documents).
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.filters
|
<dt>
|
||||||
|
payload.filters
|
||||||
<span class="property-type">array</span>
|
<span class="property-type">array</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Applies multiple message filters using Telegram API filter classes (e.g., <code>Api.InputMessagesFilterPhotos</code>).</dd>
|
<dd>
|
||||||
|
Applies multiple message filters using Telegram API filter classes (e.g.,
|
||||||
|
<code>Api.InputMessagesFilterPhotos</code>).
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.reverse
|
<dt>
|
||||||
|
payload.reverse
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Retrieves messages in reverse order if set to <code>true</code>. Default is <code>false</code>.</dd>
|
<dd>
|
||||||
|
Retrieves messages in reverse order if set to <code>true</code>. Default
|
||||||
|
is <code>false</code>.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.replyTo
|
<dt>
|
||||||
|
payload.replyTo
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Fetches messages replying to the specified message ID.</dd>
|
<dd>Fetches messages replying to the specified message ID.</dd>
|
||||||
|
|
||||||
<dt>payload.scheduled
|
<dt>
|
||||||
|
payload.scheduled
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Includes scheduled messages if set to <code>true</code>.</dd>
|
<dd>Includes scheduled messages if set to <code>true</code>.</dd>
|
||||||
@ -333,16 +402,29 @@
|
|||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.messages
|
<dt>
|
||||||
|
payload.messages
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An object containing messages, where keys are message IDs and values are message details.</dd>
|
<dd>
|
||||||
|
An object containing messages, where keys are message IDs and values are
|
||||||
|
message details.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>The <b>iter-messages</b> node provides a flexible way to retrieve messages from a Telegram chat or user. It allows advanced configurations such as filtering messages by type, searching for specific terms, and paginating results using offsets and IDs.</p>
|
<p>
|
||||||
|
The <b>iter-messages</b> node provides a flexible way to retrieve messages
|
||||||
|
from a Telegram chat or user. It allows advanced configurations such as
|
||||||
|
filtering messages by type, searching for specific terms, and paginating
|
||||||
|
results using offsets and IDs.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>The node also handles cases where a chat username needs to be resolved into an entity or peer ID. It supports using multiple filters in conjunction, enabling precise control over the messages to process.</p>
|
<p>
|
||||||
|
The node also handles cases where a chat username needs to be resolved into
|
||||||
|
an entity or peer ID. It supports using multiple filters in conjunction,
|
||||||
|
enabling precise control over the messages to process.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -354,12 +436,23 @@
|
|||||||
"filters": ["InputMessagesFilterPhotos"]
|
"filters": ["InputMessagesFilterPhotos"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>This input retrieves up to 50 messages containing the term "announcement" and filters them to include only photos from the specified channel.</p>
|
>
|
||||||
|
<p>
|
||||||
|
This input retrieves up to 50 messages containing the term "announcement"
|
||||||
|
and filters them to include only photos from the specified channel.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Error Handling</h3>
|
<h3>Error Handling</h3>
|
||||||
<p>If an error occurs during message retrieval (e.g., invalid chat ID or API errors), the node logs an error message and does not return a payload.</p>
|
<p>
|
||||||
|
If an error occurs during message retrieval (e.g., invalid chat ID or API
|
||||||
|
errors), the node logs an error message and does not return a payload.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
<h3>Configuration</h3>
|
||||||
<p>The node can use a globally configured Telegram client or a client instance provided in the message payload. Ensure the client has access to the specified chat or user.</p>
|
<p>
|
||||||
|
The node can use a globally configured Telegram client or a client instance
|
||||||
|
provided in the message payload. Ensure the client has access to the
|
||||||
|
specified chat or user.
|
||||||
|
</p>
|
||||||
</script>
|
</script>
|
||||||
|
@ -6,14 +6,15 @@ module.exports = function (RED) {
|
|||||||
this.config = RED.nodes.getNode(config.config);
|
this.config = RED.nodes.getNode(config.config);
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
this.on('input', async function (msg) {
|
this.on("input", async function (msg) {
|
||||||
|
|
||||||
/** @type {TelegramClient} */
|
/** @type {TelegramClient} */
|
||||||
const client = msg.payload?.client ? msg.payload.client : this.config.client;
|
const client = msg.payload?.client
|
||||||
|
? msg.payload.client
|
||||||
|
: this.config.client;
|
||||||
const chatId = msg.payload?.chatId ? msg.payload.chatId : config.chatId;
|
const chatId = msg.payload?.chatId ? msg.payload.chatId : config.chatId;
|
||||||
let peerId = chatId === "me" ? chatId : utils.parseID(chatId);
|
let peerId = chatId === "me" ? chatId : utils.parseID(chatId);
|
||||||
|
|
||||||
// Получаем параметры из входного сообщения или из конфигурации узла
|
// We receive parameters from the input message or from the node configuration
|
||||||
const limit = msg.payload?.limit || config.limit;
|
const limit = msg.payload?.limit || config.limit;
|
||||||
const offsetDate = msg.payload?.offsetDate || config.offsetDate;
|
const offsetDate = msg.payload?.offsetDate || config.offsetDate;
|
||||||
const offsetId = msg.payload?.offsetId || config.offsetId;
|
const offsetId = msg.payload?.offsetId || config.offsetId;
|
||||||
@ -30,11 +31,10 @@ module.exports = function (RED) {
|
|||||||
const scheduled = msg.payload?.scheduled || config.scheduled;
|
const scheduled = msg.payload?.scheduled || config.scheduled;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
limit: limit !== ""? parseInt(limit) : undefined,
|
limit: limit !== "" ? parseInt(limit) : undefined,
|
||||||
offsetDate: offsetDate !== "" ? offsetDate:undefined,
|
offsetDate: offsetDate !== "" ? offsetDate : undefined,
|
||||||
offsetId: offsetId !== "" ? parseInt(offsetId):undefined,
|
offsetId: offsetId !== "" ? parseInt(offsetId) : undefined,
|
||||||
maxId: maxId,
|
maxId: maxId,
|
||||||
minId: minId,
|
minId: minId,
|
||||||
addOffset: addOffset,
|
addOffset: addOffset,
|
||||||
@ -59,22 +59,22 @@ module.exports = function (RED) {
|
|||||||
|
|
||||||
const filters = msg.payload?.filters || config.filters || [];
|
const filters = msg.payload?.filters || config.filters || [];
|
||||||
|
|
||||||
// Обработка выбранных фильтров
|
// Processing selected filters
|
||||||
if (filters.length > 0) {
|
if (filters.length > 0) {
|
||||||
params.filter = [];
|
params.filter = [];
|
||||||
filters.forEach((filter) => {
|
filters.forEach((filter) => {
|
||||||
params.filter.push( Api[filter]);
|
params.filter.push(Api[filter]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for await (const message of client.iterMessages(peerId, params)){
|
for await (const message of client.iterMessages(peerId, params)) {
|
||||||
messages[message.id] = message;
|
messages[message.id] = message;
|
||||||
console.log(message.id, message.text);
|
console.log(message.id, message.text);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const entity = await client.getInputEntity(peerId)
|
const entity = await client.getInputEntity(peerId);
|
||||||
for await (const message of client.iterMessages(entity, params)){
|
for await (const message of client.iterMessages(entity, params)) {
|
||||||
messages[message.id] = message;
|
messages[message.id] = message;
|
||||||
console.log(message.id, message.text);
|
console.log(message.id, message.text);
|
||||||
}
|
}
|
||||||
@ -84,11 +84,10 @@ module.exports = function (RED) {
|
|||||||
payload: { messages },
|
payload: { messages },
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Error iter messages: ' + err.message);
|
node.error("Error iter messages: " + err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType('iter-messages', IterMessages);
|
RED.nodes.registerType("iter-messages", IterMessages);
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,25 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('receiver', {
|
RED.nodes.registerType("receiver", {
|
||||||
category: 'telegram-account',
|
category: "telegram-account",
|
||||||
color: '#229ED9',
|
color: "#229ED9",
|
||||||
icon: 'tg.png',
|
icon: "tg.png",
|
||||||
align:"right",
|
align: "right",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
config: { type: 'config', required: false },
|
config: { type: "config", required: false },
|
||||||
ignore: { value:""}
|
ignore: { value: "" },
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || 'Receiver';
|
return this.name || "Receiver";
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-template-name="receiver">
|
<script type="text/html" data-template-name="receiver">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name">
|
<label for="node-input-name"> <i class="fa fa-tag"></i> Name </label>
|
||||||
<i class="fa fa-tag"></i> Name
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-name"
|
id="node-input-name"
|
||||||
@ -31,9 +28,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-config">
|
<label for="node-input-config"> <i class="fa fa-tag"></i> Config </label>
|
||||||
<i class="fa fa-tag"></i> Config
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-config"
|
id="node-input-config"
|
||||||
@ -42,9 +37,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-ignore">
|
<label for="node-input-ignore"> <i class="fa fa-tag"></i> Config </label>
|
||||||
<i class="fa fa-tag"></i> Config
|
|
||||||
</label>
|
|
||||||
<textarea
|
<textarea
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-ignore"
|
id="node-input-ignore"
|
||||||
@ -52,37 +45,61 @@
|
|||||||
style="width: 60%"
|
style="width: 60%"
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="receiver">
|
<script type="text/html" data-help-name="receiver">
|
||||||
<p>The <b>receiver</b> node listens for incoming Telegram messages and forwards them as output messages in Node-RED. It supports filtering messages based on sender IDs to ignore specific users.</p>
|
<p>
|
||||||
|
The <b>receiver</b> node listens for incoming Telegram messages and forwards
|
||||||
|
them as output messages in Node-RED. It supports filtering messages based on
|
||||||
|
sender IDs to ignore specific users.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<p>This node does not take any direct inputs. It listens to all incoming messages from the configured Telegram client.</p>
|
<p>
|
||||||
|
This node does not take any direct inputs. It listens to all incoming
|
||||||
|
messages from the configured Telegram client.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.update
|
<dt>
|
||||||
|
payload.update
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The raw Telegram update object containing details about the incoming message, sender, chat, and metadata.</dd>
|
<dd>
|
||||||
|
The raw Telegram update object containing details about the incoming
|
||||||
|
message, sender, chat, and metadata.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
<h3>Configuration</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>Telegram Configuration
|
<dt>
|
||||||
|
Telegram Configuration
|
||||||
<span class="property-type">node</span>
|
<span class="property-type">node</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>A configured Telegram client node to receive messages. Ensure the client is authenticated and has necessary permissions.</dd>
|
<dd>
|
||||||
|
A configured Telegram client node to receive messages. Ensure the client
|
||||||
|
is authenticated and has necessary permissions.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>Ignore List
|
<dt>
|
||||||
|
Ignore List
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>A newline-separated list of user IDs to ignore. Messages from these users will not trigger the output.</dd>
|
<dd>
|
||||||
|
A newline-separated list of user IDs to ignore. Messages from these users
|
||||||
|
will not trigger the output.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>The <b>receiver</b> node uses the Telegram client to listen for all new messages in real-time. It emits a message to the next connected Node-RED node whenever a new Telegram message is received, provided the sender's user ID is not in the ignore list.</p>
|
<p>
|
||||||
|
The <b>receiver</b> node uses the Telegram client to listen for all new
|
||||||
|
messages in real-time. It emits a message to the next connected Node-RED
|
||||||
|
node whenever a new Telegram message is received, provided the sender's user
|
||||||
|
ID is not in the ignore list.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -103,26 +120,47 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>In this example, the node outputs the raw Telegram update object when a user sends the message "Hello, bot!" to the Telegram bot.</p>
|
>
|
||||||
|
<p>
|
||||||
|
In this example, the node outputs the raw Telegram update object when a user
|
||||||
|
sends the message "Hello, bot!" to the Telegram bot.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Error Handling</h3>
|
<h3>Error Handling</h3>
|
||||||
<p>If the Telegram client encounters an authentication issue or configuration error, the node logs an error message and stops listening for messages.</p>
|
<p>
|
||||||
|
If the Telegram client encounters an authentication issue or configuration
|
||||||
|
error, the node logs an error message and stops listening for messages.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Advanced Usage</h3>
|
<h3>Advanced Usage</h3>
|
||||||
<p>By configuring the <b>Ignore List</b>, you can filter out messages from specific users. For example:</p>
|
<p>
|
||||||
|
By configuring the <b>Ignore List</b>, you can filter out messages from
|
||||||
|
specific users. For example:
|
||||||
|
</p>
|
||||||
<pre>
|
<pre>
|
||||||
123456789
|
123456789
|
||||||
987654321
|
987654321
|
||||||
</pre>
|
</pre
|
||||||
<p>In this case, messages from user IDs <code>123456789</code> and <code>987654321</code> will be ignored.</p>
|
>
|
||||||
|
<p>
|
||||||
|
In this case, messages from user IDs <code>123456789</code> and
|
||||||
|
<code>987654321</code> will be ignored.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Notes</h3>
|
<h3>Notes</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Ensure the Telegram bot has sufficient permissions to receive messages in the configured chat or channel.</li>
|
<li>
|
||||||
<li>The <b>Ignore List</b> only filters messages based on the sender's user ID.</li>
|
Ensure the Telegram bot has sufficient permissions to receive messages in
|
||||||
<li>For advanced filtering based on message content, consider chaining this node with additional processing nodes in Node-RED.</li>
|
the configured chat or channel.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
The <b>Ignore List</b> only filters messages based on the sender's user
|
||||||
|
ID.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
For advanced filtering based on message content, consider chaining this
|
||||||
|
node with additional processing nodes in Node-RED.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,25 +8,23 @@ module.exports = function (RED) {
|
|||||||
const client = this.config.client;
|
const client = this.config.client;
|
||||||
const ignore = config.ignore.split(/\n/);
|
const ignore = config.ignore.split(/\n/);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.addEventHandler((update) => {
|
client.addEventHandler((update) => {
|
||||||
if(update.message.fromId != null && !ignore.includes(update.message.fromId.userId.toString())){
|
if (
|
||||||
|
update.message.fromId != null &&
|
||||||
|
!ignore.includes(update.message.fromId.userId.toString())
|
||||||
|
) {
|
||||||
node.send({
|
node.send({
|
||||||
payload:{
|
payload: {
|
||||||
update
|
update,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} )
|
|
||||||
}
|
|
||||||
|
|
||||||
}, new NewMessage());
|
}, new NewMessage());
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Ошибка авторизации: ' + err.message);
|
node.error("Authorization error: " + err.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
RED.nodes.registerType("receiver", Receiver);
|
||||||
|
|
||||||
RED.nodes.registerType('receiver', Receiver);
|
|
||||||
};
|
};
|
||||||
|
@ -1,48 +1,46 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('send-files', {
|
RED.nodes.registerType("send-files", {
|
||||||
category: 'telegram',
|
category: "telegram",
|
||||||
color: '#32a3e0',
|
color: "#32a3e0",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
config: { type: 'config', required: true },
|
config: { type: "config", required: true },
|
||||||
chatId: { value: '', required: true },
|
chatId: { value: "", required: true },
|
||||||
files: { value: '', required: true },
|
files: { value: "", required: true },
|
||||||
caption: { value: '' },
|
caption: { value: "" },
|
||||||
forceDocument: { value: false },
|
forceDocument: { value: false },
|
||||||
fileSize: { value: 0 },
|
fileSize: { value: 0 },
|
||||||
clearDraft: { value: false },
|
clearDraft: { value: false },
|
||||||
progressCallback: { value: '' },
|
progressCallback: { value: "" },
|
||||||
replyTo: { value: '' },
|
replyTo: { value: "" },
|
||||||
attributes: { value: '' },
|
attributes: { value: "" },
|
||||||
thumb: { value: '' },
|
thumb: { value: "" },
|
||||||
voiceNote: { value: false },
|
voiceNote: { value: false },
|
||||||
videoNote: { value: false },
|
videoNote: { value: false },
|
||||||
supportsStreaming: { value: false },
|
supportsStreaming: { value: false },
|
||||||
parseMode: { value: '' },
|
parseMode: { value: "" },
|
||||||
formattingEntities: { value: '' },
|
formattingEntities: { value: "" },
|
||||||
silent: { value: false },
|
silent: { value: false },
|
||||||
scheduleDate: { value: 0 },
|
scheduleDate: { value: 0 },
|
||||||
buttons: { value: '' },
|
buttons: { value: "" },
|
||||||
workers: { value: 0 },
|
workers: { value: 0 },
|
||||||
noforwards: { value: false },
|
noforwards: { value: false },
|
||||||
commentTo: { value: '' },
|
commentTo: { value: "" },
|
||||||
topMsgId: { value: '' },
|
topMsgId: { value: "" },
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
icon: 'file.png',
|
icon: "file.png",
|
||||||
paletteLabel: 'Send Files',
|
paletteLabel: "Send Files",
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || 'Send Files';
|
return this.name || "Send Files";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-template-name="send-files">
|
<script type="text/html" data-template-name="send-files">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name">
|
<label for="node-input-name"> <i class="fa fa-tag"></i> Name </label>
|
||||||
<i class="fa fa-tag"></i> Name
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-name"
|
id="node-input-name"
|
||||||
@ -52,9 +50,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-config">
|
<label for="node-input-config"> <i class="fa fa-tag"></i> Config </label>
|
||||||
<i class="fa fa-tag"></i> Config
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-config"
|
id="node-input-config"
|
||||||
@ -64,9 +60,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-chatId">
|
<label for="node-input-chatId"> <i class="fa fa-tag"></i> Chat ID </label>
|
||||||
<i class="fa fa-tag"></i> Chat ID
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-chatId"
|
id="node-input-chatId"
|
||||||
@ -88,9 +82,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-caption">
|
<label for="node-input-caption"> <i class="fa fa-tag"></i> Caption </label>
|
||||||
<i class="fa fa-tag"></i> Caption
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-caption"
|
id="node-input-caption"
|
||||||
@ -125,11 +117,7 @@
|
|||||||
<label for="node-input-clearDraft">
|
<label for="node-input-clearDraft">
|
||||||
<i class="fa fa-tag"></i> Clear Draft
|
<i class="fa fa-tag"></i> Clear Draft
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input type="checkbox" id="node-input-clearDraft" ng-model="clearDraft" />
|
||||||
type="checkbox"
|
|
||||||
id="node-input-clearDraft"
|
|
||||||
ng-model="clearDraft"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-progressCallback">
|
<label for="node-input-progressCallback">
|
||||||
@ -144,9 +132,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-replyTo">
|
<label for="node-input-replyTo"> <i class="fa fa-tag"></i> Reply To </label>
|
||||||
<i class="fa fa-tag"></i> Reply To
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-replyTo"
|
id="node-input-replyTo"
|
||||||
@ -168,9 +154,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-thumb">
|
<label for="node-input-thumb"> <i class="fa fa-tag"></i> Thumbnail </label>
|
||||||
<i class="fa fa-tag"></i> Thumbnail
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-thumb"
|
id="node-input-thumb"
|
||||||
@ -183,21 +167,13 @@
|
|||||||
<label for="node-input-voiceNote">
|
<label for="node-input-voiceNote">
|
||||||
<i class="fa fa-tag"></i> Voice Note
|
<i class="fa fa-tag"></i> Voice Note
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input type="checkbox" id="node-input-voiceNote" ng-model="voiceNote" />
|
||||||
type="checkbox"
|
|
||||||
id="node-input-voiceNote"
|
|
||||||
ng-model="voiceNote"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-videoNote">
|
<label for="node-input-videoNote">
|
||||||
<i class="fa fa-tag"></i> Video Note
|
<i class="fa fa-tag"></i> Video Note
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input type="checkbox" id="node-input-videoNote" ng-model="videoNote" />
|
||||||
type="checkbox"
|
|
||||||
id="node-input-videoNote"
|
|
||||||
ng-model="videoNote"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-supportsStreaming">
|
<label for="node-input-supportsStreaming">
|
||||||
@ -234,14 +210,8 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-silent">
|
<label for="node-input-silent"> <i class="fa fa-tag"></i> Silent </label>
|
||||||
<i class="fa fa-tag"></i> Silent
|
<input type="checkbox" id="node-input-silent" ng-model="silent" />
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
id="node-input-silent"
|
|
||||||
ng-model="silent"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-scheduleDate">
|
<label for="node-input-scheduleDate">
|
||||||
@ -256,9 +226,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-buttons">
|
<label for="node-input-buttons"> <i class="fa fa-tag"></i> Buttons </label>
|
||||||
<i class="fa fa-tag"></i> Buttons
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="node-input-buttons"
|
id="node-input-buttons"
|
||||||
@ -268,9 +236,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-workers">
|
<label for="node-input-workers"> <i class="fa fa-tag"></i> Workers </label>
|
||||||
<i class="fa fa-tag"></i> Workers
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="node-input-workers"
|
id="node-input-workers"
|
||||||
@ -283,11 +249,7 @@
|
|||||||
<label for="node-input-noforwards">
|
<label for="node-input-noforwards">
|
||||||
<i class="fa fa-tag"></i> No Forwards
|
<i class="fa fa-tag"></i> No Forwards
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input type="checkbox" id="node-input-noforwards" ng-model="noforwards" />
|
||||||
type="checkbox"
|
|
||||||
id="node-input-noforwards"
|
|
||||||
ng-model="noforwards"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-commentTo">
|
<label for="node-input-commentTo">
|
||||||
@ -316,111 +278,155 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="send-files">
|
<script type="text/html" data-help-name="send-files">
|
||||||
<p>The <b>send-files</b> node allows you to send files to a Telegram chat or user using the Telegram API. It supports a wide range of parameters, including file attributes, captions, buttons, and scheduling options.</p>
|
<p>
|
||||||
|
The <b>send-files</b> node allows you to send files to a Telegram chat or
|
||||||
|
user using the Telegram API. It supports a wide range of parameters,
|
||||||
|
including file attributes, captions, buttons, and scheduling options.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.chatId
|
<dt>
|
||||||
|
payload.chatId
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The ID or username of the chat or user to send files to.</dd>
|
<dd>The ID or username of the chat or user to send files to.</dd>
|
||||||
|
|
||||||
<dt>payload.files
|
<dt>
|
||||||
|
payload.files
|
||||||
<span class="property-type">array</span>
|
<span class="property-type">array</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>A list of file paths or URLs to be sent. Multiple files can be specified.</dd>
|
<dd>
|
||||||
|
A list of file paths or URLs to be sent. Multiple files can be specified.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.caption
|
<dt>
|
||||||
|
payload.caption
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The caption text to include with the file. Supports Markdown or HTML formatting.</dd>
|
<dd>
|
||||||
|
The caption text to include with the file. Supports Markdown or HTML
|
||||||
|
formatting.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.forceDocument
|
<dt>
|
||||||
|
payload.forceDocument
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If <code>true</code>, forces the file to be sent as a document instead of its native media type.</dd>
|
<dd>
|
||||||
|
If <code>true</code>, forces the file to be sent as a document instead of
|
||||||
|
its native media type.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.fileSize
|
<dt>
|
||||||
|
payload.fileSize
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Specifies the file size, if known. Useful for optimization.</dd>
|
<dd>Specifies the file size, if known. Useful for optimization.</dd>
|
||||||
|
|
||||||
<dt>payload.clearDraft
|
<dt>
|
||||||
|
payload.clearDraft
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If <code>true</code>, clears the draft in the chat before sending the file.</dd>
|
<dd>
|
||||||
|
If <code>true</code>, clears the draft in the chat before sending the
|
||||||
|
file.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.progressCallback
|
<dt>
|
||||||
|
payload.progressCallback
|
||||||
<span class="property-type">function</span>
|
<span class="property-type">function</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>A function to monitor the progress of file uploads.</dd>
|
<dd>A function to monitor the progress of file uploads.</dd>
|
||||||
|
|
||||||
<dt>payload.replyTo
|
<dt>
|
||||||
|
payload.replyTo
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The ID of the message to reply to with the file.</dd>
|
<dd>The ID of the message to reply to with the file.</dd>
|
||||||
|
|
||||||
<dt>payload.attributes
|
<dt>
|
||||||
|
payload.attributes
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Additional attributes for the file, such as file type or metadata.</dd>
|
<dd>Additional attributes for the file, such as file type or metadata.</dd>
|
||||||
|
|
||||||
<dt>payload.thumb
|
<dt>
|
||||||
|
payload.thumb
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>A path or URL to a thumbnail image for the file.</dd>
|
<dd>A path or URL to a thumbnail image for the file.</dd>
|
||||||
|
|
||||||
<dt>payload.voiceNote
|
<dt>
|
||||||
|
payload.voiceNote
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If <code>true</code>, marks the file as a voice note.</dd>
|
<dd>If <code>true</code>, marks the file as a voice note.</dd>
|
||||||
|
|
||||||
<dt>payload.videoNote
|
<dt>
|
||||||
|
payload.videoNote
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If <code>true</code>, marks the file as a video note.</dd>
|
<dd>If <code>true</code>, marks the file as a video note.</dd>
|
||||||
|
|
||||||
<dt>payload.supportsStreaming
|
<dt>
|
||||||
|
payload.supportsStreaming
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If <code>true</code>, enables streaming support for video files.</dd>
|
<dd>If <code>true</code>, enables streaming support for video files.</dd>
|
||||||
|
|
||||||
<dt>payload.parseMode
|
<dt>
|
||||||
|
payload.parseMode
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Specifies the parse mode for captions (<code>Markdown</code> or <code>HTML</code>).</dd>
|
<dd>
|
||||||
|
Specifies the parse mode for captions (<code>Markdown</code> or
|
||||||
|
<code>HTML</code>).
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.silent
|
<dt>
|
||||||
|
payload.silent
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If <code>true</code>, sends the message silently without a notification.</dd>
|
<dd>
|
||||||
|
If <code>true</code>, sends the message silently without a notification.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.scheduleDate
|
<dt>
|
||||||
|
payload.scheduleDate
|
||||||
<span class="property-type">string | number</span>
|
<span class="property-type">string | number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Schedules the message to be sent at a specific time. Accepts a UNIX timestamp or date string.</dd>
|
<dd>
|
||||||
|
Schedules the message to be sent at a specific time. Accepts a UNIX
|
||||||
|
timestamp or date string.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.buttons
|
<dt>
|
||||||
|
payload.buttons
|
||||||
<span class="property-type">array</span>
|
<span class="property-type">array</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An array of buttons to include with the file message.</dd>
|
<dd>An array of buttons to include with the file message.</dd>
|
||||||
|
|
||||||
<dt>payload.workers
|
<dt>
|
||||||
|
payload.workers
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The number of workers for parallel uploads.</dd>
|
<dd>The number of workers for parallel uploads.</dd>
|
||||||
|
|
||||||
<dt>payload.noforwards
|
<dt>
|
||||||
|
payload.noforwards
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If <code>true</code>, prevents the message from being forwarded.</dd>
|
<dd>If <code>true</code>, prevents the message from being forwarded.</dd>
|
||||||
|
|
||||||
<dt>payload.commentTo
|
<dt>
|
||||||
|
payload.commentTo
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The ID of the message to comment on in a channel.</dd>
|
<dd>The ID of the message to comment on in a channel.</dd>
|
||||||
|
|
||||||
<dt>payload.topMsgId
|
<dt>
|
||||||
|
payload.topMsgId
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The ID of the pinned message to associate with the file.</dd>
|
<dd>The ID of the pinned message to associate with the file.</dd>
|
||||||
@ -428,14 +434,23 @@
|
|||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload
|
<dt>
|
||||||
|
payload
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Contains the response from the Telegram API, including details of the sent message or file.</dd>
|
<dd>
|
||||||
|
Contains the response from the Telegram API, including details of the sent
|
||||||
|
message or file.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>The <b>send-files</b> node allows advanced file-sending capabilities with full customization. It supports various Telegram features such as captions with rich text formatting, scheduled messages, silent delivery, and progress tracking.</p>
|
<p>
|
||||||
|
The <b>send-files</b> node allows advanced file-sending capabilities with
|
||||||
|
full customization. It supports various Telegram features such as captions
|
||||||
|
with rich text formatting, scheduled messages, silent delivery, and progress
|
||||||
|
tracking.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -451,13 +466,23 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>This example sends two files with a caption, using Markdown for formatting, and includes a button linking to a website. The message is sent silently.</p>
|
>
|
||||||
|
<p>
|
||||||
|
This example sends two files with a caption, using Markdown for formatting,
|
||||||
|
and includes a button linking to a website. The message is sent silently.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Error Handling</h3>
|
<h3>Error Handling</h3>
|
||||||
<p>If an error occurs (e.g., invalid file path or chat ID), the node logs an error message and does not send the file.</p>
|
<p>
|
||||||
|
If an error occurs (e.g., invalid file path or chat ID), the node logs an
|
||||||
|
error message and does not send the file.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Configuration</h3>
|
<h3>Configuration</h3>
|
||||||
<p>The node can use a globally configured Telegram client or a client instance provided in the message payload. Ensure the client has permissions to send messages in the specified chat.</p>
|
<p>
|
||||||
|
The node can use a globally configured Telegram client or a client instance
|
||||||
|
provided in the message payload. Ensure the client has permissions to send
|
||||||
|
messages in the specified chat.
|
||||||
|
</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -4,22 +4,26 @@ module.exports = function (RED) {
|
|||||||
this.config = RED.nodes.getNode(config.config);
|
this.config = RED.nodes.getNode(config.config);
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
this.on('input', async function (msg) {
|
this.on("input", async function (msg) {
|
||||||
const chatId = msg.payload.chatId || config.chatId;
|
const chatId = msg.payload.chatId || config.chatId;
|
||||||
const files = msg.payload.files || config.files.split(',').map(file => file.trim());
|
const files =
|
||||||
|
msg.payload.files || config.files.split(",").map((file) => file.trim());
|
||||||
const caption = msg.payload.caption || config.caption;
|
const caption = msg.payload.caption || config.caption;
|
||||||
const forceDocument = msg.payload.forceDocument || config.forceDocument;
|
const forceDocument = msg.payload.forceDocument || config.forceDocument;
|
||||||
const fileSize = msg.payload.fileSize || config.fileSize;
|
const fileSize = msg.payload.fileSize || config.fileSize;
|
||||||
const clearDraft = msg.payload.clearDraft || config.clearDraft;
|
const clearDraft = msg.payload.clearDraft || config.clearDraft;
|
||||||
const progressCallback = msg.payload.progressCallback || config.progressCallback;
|
const progressCallback =
|
||||||
|
msg.payload.progressCallback || config.progressCallback;
|
||||||
const replyTo = msg.payload.replyTo || config.replyTo;
|
const replyTo = msg.payload.replyTo || config.replyTo;
|
||||||
const attributes = msg.payload.attributes || config.attributes;
|
const attributes = msg.payload.attributes || config.attributes;
|
||||||
const thumb = msg.payload.thumb || config.thumb;
|
const thumb = msg.payload.thumb || config.thumb;
|
||||||
const voiceNote = msg.payload.voiceNote || config.voiceNote;
|
const voiceNote = msg.payload.voiceNote || config.voiceNote;
|
||||||
const videoNote = msg.payload.videoNote || config.videoNote;
|
const videoNote = msg.payload.videoNote || config.videoNote;
|
||||||
const supportsStreaming = msg.payload.supportsStreaming || config.supportsStreaming;
|
const supportsStreaming =
|
||||||
|
msg.payload.supportsStreaming || config.supportsStreaming;
|
||||||
const parseMode = msg.payload.parseMode || config.parseMode;
|
const parseMode = msg.payload.parseMode || config.parseMode;
|
||||||
const formattingEntities = msg.payload.formattingEntities || config.formattingEntities;
|
const formattingEntities =
|
||||||
|
msg.payload.formattingEntities || config.formattingEntities;
|
||||||
const silent = msg.payload.silent || config.silent;
|
const silent = msg.payload.silent || config.silent;
|
||||||
const scheduleDate = msg.payload.scheduleDate || config.scheduleDate;
|
const scheduleDate = msg.payload.scheduleDate || config.scheduleDate;
|
||||||
const buttons = msg.payload.buttons || config.buttons;
|
const buttons = msg.payload.buttons || config.buttons;
|
||||||
@ -29,7 +33,9 @@ module.exports = function (RED) {
|
|||||||
const topMsgId = msg.payload.topMsgId || config.topMsgId;
|
const topMsgId = msg.payload.topMsgId || config.topMsgId;
|
||||||
|
|
||||||
/** @type {TelegramClient} */
|
/** @type {TelegramClient} */
|
||||||
const client = msg.payload?.client ? msg.payload.client : this.config.client;
|
const client = msg.payload?.client
|
||||||
|
? msg.payload.client
|
||||||
|
: this.config.client;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
@ -56,17 +62,16 @@ module.exports = function (RED) {
|
|||||||
topMsgId: topMsgId,
|
topMsgId: topMsgId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Sending files
|
||||||
// Отправка файлов
|
|
||||||
const response = await client.sendFile(chatId, params);
|
const response = await client.sendFile(chatId, params);
|
||||||
node.send({
|
node.send({
|
||||||
payload: response,
|
payload: response,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Error sending files: ' + err.message);
|
node.error("Error sending files: " + err.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType('send-files', SendFile);
|
RED.nodes.registerType("send-files", SendFile);
|
||||||
};
|
};
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('send-message', {
|
RED.nodes.registerType("send-message", {
|
||||||
category: 'telegram-account',
|
category: "telegram-account",
|
||||||
color: '#229ED9',
|
color: "#229ED9",
|
||||||
icon: 'tg.png',
|
icon: "tg.png",
|
||||||
align: "right",
|
align: "right",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: '' },
|
name: { value: "" },
|
||||||
chatId: { value: '' },
|
chatId: { value: "" },
|
||||||
message: { value: '' },
|
message: { value: "" },
|
||||||
config: { type: 'config', required: false },
|
config: { type: "config", required: false },
|
||||||
parseMode: { value: 'md' }, // Default parse mode is Markdown
|
parseMode: { value: "md" }, // Default parse mode is Markdown
|
||||||
schedule: { value: '' }, // Default schedule is empty
|
schedule: { value: "" }, // Default schedule is empty
|
||||||
replyTo: { value: '' }, // Reply to a message
|
replyTo: { value: "" }, // Reply to a message
|
||||||
attributes: { value: '' }, // Message attributes
|
attributes: { value: "" }, // Message attributes
|
||||||
formattingEntities: { value: '' }, // Message formatting entities
|
formattingEntities: { value: "" }, // Message formatting entities
|
||||||
linkPreview: { value: false }, // Show link preview
|
linkPreview: { value: false }, // Show link preview
|
||||||
file: { value: [] }, // File to be sent
|
file: { value: [] }, // File to be sent
|
||||||
thumb: { value: '' }, // Thumbnail for the file
|
thumb: { value: "" }, // Thumbnail for the file
|
||||||
forceDocument: { value: false }, // Send the file as a document
|
forceDocument: { value: false }, // Send the file as a document
|
||||||
clearDraft: { value: false }, // Clear existing draft
|
clearDraft: { value: false }, // Clear existing draft
|
||||||
buttons: { value: '' }, // Buttons to be shown after sending
|
buttons: { value: "" }, // Buttons to be shown after sending
|
||||||
silent: { value: false }, // Whether to notify in a broadcast channel
|
silent: { value: false }, // Whether to notify in a broadcast channel
|
||||||
supportStreaming: { value: false }, // Whether the sent video supports streaming
|
supportStreaming: { value: false }, // Whether the sent video supports streaming
|
||||||
noforwards: { value: false }, // Disable forwarding
|
noforwards: { value: false }, // Disable forwarding
|
||||||
commentTo: { value: '' }, // Comment to a message in a broadcast channel
|
commentTo: { value: "" }, // Comment to a message in a broadcast channel
|
||||||
topMsgId: { value: '' }, // Reply to a specific thread
|
topMsgId: { value: "" }, // Reply to a specific thread
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
label: function () {
|
label: function () {
|
||||||
return this.name || 'Send Message';
|
return this.name || "Send Message";
|
||||||
},
|
},
|
||||||
oneditprepare: function () {
|
oneditprepare: function () {
|
||||||
const node = this;
|
const node = this;
|
||||||
@ -42,7 +42,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// const filesContainer = $("#node-input-files-container");
|
// const filesContainer = $("#node-input-files-container");
|
||||||
// if (Array.isArray(node.file)) {
|
// if (Array.isArray(node.file)) {
|
||||||
// node.file.forEach(file => {
|
// node.file.forEach(file => {
|
||||||
@ -85,33 +84,30 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/html" data-template-name="send-message">
|
<script type="text/html" data-template-name="send-message">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name">
|
<label for="node-input-name"> <i class="fa fa-tag"></i> Name </label>
|
||||||
<i class="fa fa-tag"></i> Name
|
<input type="text" id="node-input-name" placeholder="Name" />
|
||||||
</label>
|
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-config">
|
<label for="node-input-config"> <i class="fa fa-gear"></i> Config </label>
|
||||||
<i class="fa fa-gear"></i> Config
|
<input type="hidden" id="node-input-config" />
|
||||||
</label>
|
|
||||||
<input type="hidden" id="node-input-config">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-chat_id">
|
<label for="node-input-chat_id"> <i class="fa fa-user"></i> Chat ID </label>
|
||||||
<i class="fa fa-user"></i> Chat ID
|
<input type="text" id="node-input-chatId" placeholder="Peer ID" />
|
||||||
</label>
|
|
||||||
<input type="text" id="node-input-chatId" placeholder="Peer ID">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-message">
|
<label for="node-input-message">
|
||||||
<i class="fa fa-pencil"></i> Message
|
<i class="fa fa-pencil"></i> Message
|
||||||
</label>
|
</label>
|
||||||
<textarea type="text" id="node-input-message" placeholder="Message"></textarea>
|
<textarea
|
||||||
|
type="text"
|
||||||
|
id="node-input-message"
|
||||||
|
placeholder="Message"
|
||||||
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -128,145 +124,178 @@
|
|||||||
<label for="node-input-schedule">
|
<label for="node-input-schedule">
|
||||||
<i class="fa fa-clock"></i> Schedule
|
<i class="fa fa-clock"></i> Schedule
|
||||||
</label>
|
</label>
|
||||||
<input type="datetime-local" id="node-input-schedule" placeholder="Schedule">
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
id="node-input-schedule"
|
||||||
|
placeholder="Schedule"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row" id="node-linkPreview-row">
|
<div class="form-row" id="node-linkPreview-row">
|
||||||
<label for="node-input-linkPreview">
|
<label for="node-input-linkPreview">
|
||||||
<i class="fa fa-link"></i> Show Link Preview
|
<i class="fa fa-link"></i> Show Link Preview
|
||||||
</label>
|
</label>
|
||||||
<input type="checkbox" id="node-input-linkPreview">
|
<input type="checkbox" id="node-input-linkPreview" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label>
|
<label> <i class="fa fa-file"></i> Files </label>
|
||||||
<i class="fa fa-file"></i> Files
|
<div id="node-input-files-container"></div>
|
||||||
</label>
|
<button
|
||||||
<div id="node-input-files-container">
|
id="node-input-add-file"
|
||||||
|
class="editor-button editor-button-large editor-button-add"
|
||||||
|
style="margin-top: 1rem;"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Add File
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button id="node-input-add-file" class="editor-button editor-button-large editor-button-add" style="margin-top: 1rem;" type="button">Add File</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row" id="node-thumb-row">
|
<div class="form-row" id="node-thumb-row">
|
||||||
<label for="node-input-thumb">
|
<label for="node-input-thumb">
|
||||||
<i class="fa fa-file-image"></i> Thumbnail (Optional)
|
<i class="fa fa-file-image"></i> Thumbnail (Optional)
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="node-input-thumb">
|
<input type="text" id="node-input-thumb" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-forceDocument">
|
<label for="node-input-forceDocument">
|
||||||
<i class="fa fa-file"></i> Force Send as Document
|
<i class="fa fa-file"></i> Force Send as Document
|
||||||
</label>
|
</label>
|
||||||
<input type="checkbox" id="node-input-forceDocument">
|
<input type="checkbox" id="node-input-forceDocument" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-clearDraft">
|
<label for="node-input-clearDraft">
|
||||||
<i class="fa fa-trash"></i> Clear Existing Draft
|
<i class="fa fa-trash"></i> Clear Existing Draft
|
||||||
</label>
|
</label>
|
||||||
<input type="checkbox" id="node-input-clearDraft">
|
<input type="checkbox" id="node-input-clearDraft" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-buttons">
|
<label for="node-input-buttons"> <i class="fa fa-th"></i> Buttons </label>
|
||||||
<i class="fa fa-th"></i> Buttons
|
<textarea
|
||||||
</label>
|
type="text"
|
||||||
<textarea type="text" id="node-input-buttons" placeholder="Buttons"></textarea>
|
id="node-input-buttons"
|
||||||
|
placeholder="Buttons"
|
||||||
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-silent">
|
<label for="node-input-silent">
|
||||||
<i class="fa fa-bell-slash"></i> Silent Notification
|
<i class="fa fa-bell-slash"></i> Silent Notification
|
||||||
</label>
|
</label>
|
||||||
<input type="checkbox" id="node-input-silent">
|
<input type="checkbox" id="node-input-silent" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-supportStreaming">
|
<label for="node-input-supportStreaming">
|
||||||
<i class="fa fa-video"></i> Support Streaming
|
<i class="fa fa-video"></i> Support Streaming
|
||||||
</label>
|
</label>
|
||||||
<input type="checkbox" id="node-input-supportStreaming">
|
<input type="checkbox" id="node-input-supportStreaming" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-noforwards">
|
<label for="node-input-noforwards">
|
||||||
<i class="fa fa-forward"></i> Disable Forwarding
|
<i class="fa fa-forward"></i> Disable Forwarding
|
||||||
</label>
|
</label>
|
||||||
<input type="checkbox" id="node-input-noforwards">
|
<input type="checkbox" id="node-input-noforwards" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-commentTo">
|
<label for="node-input-commentTo">
|
||||||
<i class="fa fa-comments"></i> Comment To Message
|
<i class="fa fa-comments"></i> Comment To Message
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="node-input-commentTo" placeholder="Comment To">
|
<input type="text" id="node-input-commentTo" placeholder="Comment To" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-topMsgId">
|
<label for="node-input-topMsgId">
|
||||||
<i class="fa fa-reply"></i> Reply To Thread
|
<i class="fa fa-reply"></i> Reply To Thread
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="node-input-topMsgId" placeholder="Top Msg ID">
|
<input type="text" id="node-input-topMsgId" placeholder="Top Msg ID" />
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="send-message">
|
<script type="text/html" data-help-name="send-message">
|
||||||
<p>The <b>send-message</b> node allows sending messages via Telegram using the <code>telegram</code> library. It supports various message types, formatting options, and additional features like scheduling and silent messages.</p>
|
<p>
|
||||||
|
The <b>send-message</b> node allows sending messages via Telegram using the
|
||||||
|
<code>telegram</code> library. It supports various message types, formatting
|
||||||
|
options, and additional features like scheduling and silent messages.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.chatId
|
<dt>
|
||||||
|
payload.chatId
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The recipient's chat ID, username (prefixed with <code>@</code>), or "me" for personal chats.</dd>
|
<dd>
|
||||||
|
The recipient's chat ID, username (prefixed with <code>@</code>), or "me"
|
||||||
|
for personal chats.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.message
|
<dt>
|
||||||
|
payload.message
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The message text to send.</dd>
|
<dd>The message text to send.</dd>
|
||||||
|
|
||||||
<dt>payload.parseMode
|
<dt>
|
||||||
|
payload.parseMode
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Specifies the formatting mode, such as <code>markdown</code> or <code>html</code>.</dd>
|
<dd>
|
||||||
|
Specifies the formatting mode, such as <code>markdown</code> or
|
||||||
|
<code>html</code>.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.schedule
|
<dt>
|
||||||
|
payload.schedule
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The timestamp (or ISO date string) to schedule the message for later sending.</dd>
|
<dd>
|
||||||
|
The timestamp (or ISO date string) to schedule the message for later
|
||||||
|
sending.
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>payload.replyTo
|
<dt>
|
||||||
|
payload.replyTo
|
||||||
<span class="property-type">number</span>
|
<span class="property-type">number</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The ID of the message to reply to, if applicable.</dd>
|
<dd>The ID of the message to reply to, if applicable.</dd>
|
||||||
|
|
||||||
<dt>payload.attributes
|
<dt>
|
||||||
|
payload.attributes
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Additional attributes for the message.</dd>
|
<dd>Additional attributes for the message.</dd>
|
||||||
|
|
||||||
<dt>payload.linkPreview
|
<dt>
|
||||||
|
payload.linkPreview
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>Determines whether to show link previews in the message.</dd>
|
<dd>Determines whether to show link previews in the message.</dd>
|
||||||
|
|
||||||
<dt>payload.file
|
<dt>
|
||||||
|
payload.file
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The path to a file to send (e.g., images, videos, documents).</dd>
|
<dd>The path to a file to send (e.g., images, videos, documents).</dd>
|
||||||
|
|
||||||
<dt>payload.thumb
|
<dt>
|
||||||
|
payload.thumb
|
||||||
<span class="property-type">string</span>
|
<span class="property-type">string</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The path to a thumbnail for the file, if applicable.</dd>
|
<dd>The path to a thumbnail for the file, if applicable.</dd>
|
||||||
|
|
||||||
<dt>payload.buttons
|
<dt>
|
||||||
|
payload.buttons
|
||||||
<span class="property-type">array</span>
|
<span class="property-type">array</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>An array of button configurations for inline or reply keyboards.</dd>
|
<dd>An array of button configurations for inline or reply keyboards.</dd>
|
||||||
|
|
||||||
<dt>payload.silent
|
<dt>
|
||||||
|
payload.silent
|
||||||
<span class="property-type">boolean</span>
|
<span class="property-type">boolean</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>If true, sends the message silently (no notification sound).</dd>
|
<dd>If true, sends the message silently (no notification sound).</dd>
|
||||||
@ -274,16 +303,30 @@
|
|||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
<dt>payload.response
|
<dt>
|
||||||
|
payload.response
|
||||||
<span class="property-type">object</span>
|
<span class="property-type">object</span>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>The response from the Telegram API, containing details of the sent message.</dd>
|
<dd>
|
||||||
|
The response from the Telegram API, containing details of the sent
|
||||||
|
message.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<p>To use the <b>send-message</b> node, you must provide the recipient's chat ID and the message content. Additional parameters like <code>file</code>, <code>thumb</code>, and <code>buttons</code> enable sending multimedia messages or interactive content. The node automatically resolves usernames prefixed with <code>@</code> to their corresponding chat entities.</p>
|
<p>
|
||||||
|
To use the <b>send-message</b> node, you must provide the recipient's chat
|
||||||
|
ID and the message content. Additional parameters like <code>file</code>,
|
||||||
|
<code>thumb</code>, and <code>buttons</code> enable sending multimedia
|
||||||
|
messages or interactive content. The node automatically resolves usernames
|
||||||
|
prefixed with <code>@</code> to their corresponding chat entities.
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>If scheduling is enabled, the <code>schedule</code> parameter should contain a valid timestamp or ISO date string. When sending files, ensure the <code>file</code> parameter specifies the correct path or URL.</p>
|
<p>
|
||||||
|
If scheduling is enabled, the <code>schedule</code> parameter should contain
|
||||||
|
a valid timestamp or ISO date string. When sending files, ensure the
|
||||||
|
<code>file</code> parameter specifies the correct path or URL.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre>
|
<pre>
|
||||||
@ -295,6 +338,10 @@
|
|||||||
"silent": true
|
"silent": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</pre>
|
</pre
|
||||||
<p>This input sends a silent message in Markdown format to the user <code>@example_user</code>.</p>
|
>
|
||||||
|
<p>
|
||||||
|
This input sends a silent message in Markdown format to the user
|
||||||
|
<code>@example_user</code>.
|
||||||
|
</p>
|
||||||
</script>
|
</script>
|
||||||
|
@ -7,14 +7,15 @@ module.exports = function (RED) {
|
|||||||
this.config = RED.nodes.getNode(config.config);
|
this.config = RED.nodes.getNode(config.config);
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
this.on('input', async function (msg) {
|
this.on("input", async function (msg) {
|
||||||
let chatId = msg.payload.chatId || config.chatId;
|
let chatId = msg.payload.chatId || config.chatId;
|
||||||
const message = msg.payload.message || config.message;
|
const message = msg.payload.message || config.message;
|
||||||
const parseMode = msg.payload.parseMode || config.parseMode;
|
const parseMode = msg.payload.parseMode || config.parseMode;
|
||||||
const schedule = msg.payload.schedule || config.schedule;
|
const schedule = msg.payload.schedule || config.schedule;
|
||||||
const replyTo = msg.payload.replyTo || config.replyTo;
|
const replyTo = msg.payload.replyTo || config.replyTo;
|
||||||
const attributes = msg.payload.attributes || config.attributes;
|
const attributes = msg.payload.attributes || config.attributes;
|
||||||
const formattingEntities = msg.payload.formattingEntities || config.formattingEntities;
|
const formattingEntities =
|
||||||
|
msg.payload.formattingEntities || config.formattingEntities;
|
||||||
const linkPreview = msg.payload.linkPreview || config.linkPreview;
|
const linkPreview = msg.payload.linkPreview || config.linkPreview;
|
||||||
const file = msg.payload.file || config.file;
|
const file = msg.payload.file || config.file;
|
||||||
const thumb = msg.payload.thumb || config.thumb;
|
const thumb = msg.payload.thumb || config.thumb;
|
||||||
@ -22,24 +23,28 @@ module.exports = function (RED) {
|
|||||||
const clearDraft = msg.payload.clearDraft || config.clearDraft;
|
const clearDraft = msg.payload.clearDraft || config.clearDraft;
|
||||||
const buttons = msg.payload.buttons || config.buttons;
|
const buttons = msg.payload.buttons || config.buttons;
|
||||||
const silent = msg.payload.silent || config.silent;
|
const silent = msg.payload.silent || config.silent;
|
||||||
const supportStreaming = msg.payload.supportStreaming || config.supportStreaming;
|
const supportStreaming =
|
||||||
|
msg.payload.supportStreaming || config.supportStreaming;
|
||||||
const noforwards = msg.payload.noforwards || config.noforwards;
|
const noforwards = msg.payload.noforwards || config.noforwards;
|
||||||
const commentTo = msg.payload.commentTo || config.commentTo;
|
const commentTo = msg.payload.commentTo || config.commentTo;
|
||||||
const topMsgId = msg.payload.topMsgId || config.topMsgId;
|
const topMsgId = msg.payload.topMsgId || config.topMsgId;
|
||||||
|
|
||||||
/** @type {TelegramClient} */
|
/** @type {TelegramClient} */
|
||||||
const client = msg.payload?.client ? msg.payload.client : this.config.client;
|
const client = msg.payload?.client
|
||||||
|
? msg.payload.client
|
||||||
|
: this.config.client;
|
||||||
let peerId = chatId === "me" ? chatId : parseID(chatId);
|
let peerId = chatId === "me" ? chatId : parseID(chatId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
message: message,
|
message: message,
|
||||||
parseMode: parseMode,
|
parseMode: parseMode,
|
||||||
replyTo: replyTo !== ""? replyTo:undefined,
|
replyTo: replyTo !== "" ? replyTo : undefined,
|
||||||
attributes: attributes,
|
attributes: attributes,
|
||||||
formattingEntities: formattingEntities !== ""? formattingEntities:undefined,
|
formattingEntities:
|
||||||
|
formattingEntities !== "" ? formattingEntities : undefined,
|
||||||
linkPreview: linkPreview,
|
linkPreview: linkPreview,
|
||||||
file: file !== "" && file.length > 1? file:undefined,
|
file: file !== "" && file.length > 1 ? file : undefined,
|
||||||
thumb: thumb,
|
thumb: thumb,
|
||||||
forceDocument: forceDocument,
|
forceDocument: forceDocument,
|
||||||
clearDraft: clearDraft,
|
clearDraft: clearDraft,
|
||||||
@ -60,11 +65,10 @@ module.exports = function (RED) {
|
|||||||
peerId = await client.getEntity(chatId);
|
peerId = await client.getEntity(chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await client.sendMessage(peerId, params);
|
response = await client.sendMessage(peerId, params);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const entity = await client.getInputEntity(peerId)
|
const entity = await client.getInputEntity(peerId);
|
||||||
await client.sendMessage(entity, params);
|
await client.sendMessage(entity, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,12 +76,10 @@ module.exports = function (RED) {
|
|||||||
payload: { response },
|
payload: { response },
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error('Error send message: ' + err.message);
|
node.error("Error send message: " + err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType('send-message', SendMessage);
|
RED.nodes.registerType("send-message", SendMessage);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user