TELEGRAM APP - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: TELEGRAM APP (/showthread.php?tid=2666) Pages:
1
2
|
TELEGRAM APP - Hosutech - 01.06.2020 Good morning, there is the possibility of transmitting events with this application (e.g. tripping protections, exceeded threshold, ..) RE: TELEGRAM APP - Daniel - 01.06.2020 It was explained here https://forum.logicmachine.net/showthread.php?tid=427&pid=2513#pid2513 but lets make a clear version: 1. Install Telegram app 2. Find BotFather or go here https://t.me/botfather 3. Once in BotFather type /newbot and follow instructions. As a result you will get your token and your own bot link like t.me/yourname_bot Click on the link and type any message there 4. Open browser (preferably Firefox as it converts JSON automatically) and go here https://api.telegram.org/bot<token>/getUpdates. Replace <token> with your token. As a result you should have something like that. Save your chat ID 5. Create a user library called telegram. paste this code and replace your token and chat ID Code: require('ssl.https') 6. Create an event based script and use this code to send message to Telegram app: Code: require("user.telegram") RE: TELEGRAM APP - JRP - 03.06.2020 Hello First of all thank you for your summary, precisely in the indicated thread I put a comment requesting a clear guide like yours. I have done all the steps indicated and it doesn't work for me. If I manually assemble the url to send messages and paste it in firefox, the message is sent and appears in telegram. If I put the same token and the same chat id in the user script and create the event script, nothing happens when executing it. I have modified the user script with a log, in addition to the one present in the event script. This is the result. This is the user script code Code: require('ssl.https') Code: require("user.telegram") a greeting RE: TELEGRAM APP - Daniel - 03.06.2020 what fw do you use? RE: TELEGRAM APP - JRP - 03.06.2020 (03.06.2020, 18:02)Daniel. Wrote: what fw do you use?Hello Thank you for your interest. I have a wiser with version 2.4.0 a greeting RE: TELEGRAM APP - Daniel - 03.06.2020 It will work in new FW 2.5.0 which should be available in a month time. For older fw it will work like this Code: function request(url) RE: TELEGRAM APP - JRP - 03.06.2020 Hello Thanks for the reply. I'll wait for the update to launch. Out of curiosity, why is it not working? a greeting RE: TELEGRAM APP - Erwin van der Zwart - 03.06.2020 Hi, Because there was a change in the http library that is included in the new FW.. BR, Erwin RE: TELEGRAM APP - admin - 04.06.2020 Older firmware uses SSLv3 for HTTPS requests by default. SSLv3 is disabled on most servers for security reasons so TLSv1.2 or newer must be used instead. HTTPS library in the new FW will use TLSv1.2 by default. The updated code that Daniel posted is perfectly fine and will work on all firmware versions. RE: TELEGRAM APP - JRP - 04.06.2020 Hello Thank you all for answering me. It is interesting to know. a greeting RE: TELEGRAM APP - baggins - 04.06.2020 (04.06.2020, 04:36)admin Wrote: Older firmware uses SSLv3 for HTTPS requests by default. SSLv3 is disabled on most servers for security reasons so TLSv1.2 or newer must be used instead. HTTPS library in the new FW will use TLSv1.2 by default. The updated code that Daniel posted is perfectly fine and will work on all firmware versions. I tried this code on firmware 20160714 and it fails: Code: log("code: " ..tostring(code)) RE: TELEGRAM APP - admin - 04.06.2020 20160714 is too old RE: TELEGRAM APP - JRP - 11.07.2020 (01.06.2020, 14:29)Daniel. Wrote: It was explained here https://forum.logicmachine.net/showthread.php?tid=427&pid=2513#pid2513 but lets make a clear version:Thanks Daniel, with the Wiser 2.5.0 update, this script works perfectly and the instructions are very clear. Thank you all so much for your help. RE: TELEGRAM APP - phongvucba - 04.08.2020 Hi everybody ! I have shortened the following code to send a message! But it didn't work, I used LM5 RIO2E version 20170620, it still started at first, it doesn't work anymore. I have tried the telegram bot on the web browser and it still works. Is there any wrong code in my code? Please everyone help. ! ---------------------------- http= require('ssl.https') socket.http.timeout = 10 noidung = 'Báo%20động%20có%20người%20đột%20nhập%20qua%20cửa%20sổ!' local ip=http.request('https://api.telegram.org/bot.../sendmessage?chat_id=-731524114&text='..noidung..'') log('dfdgdfgdfgdfg=' .. ip) ---------------------- RE: TELEGRAM APP - Daniel - 04.08.2020 Install new fw and use example above. RE: TELEGRAM APP - khalil - 04.03.2021 (01.06.2020, 14:29)Daniel. Wrote: It was explained here https://forum.logicmachine.net/showthread.php?tid=427&pid=2513#pid2513 but lets make a clear version: hello I use SL V2.6.0 I follow the steps but I got this error: User library telegram:6: attempt to index global 'socket' (a nil value) stack traceback: User library telegram:6: in function 'telegram' User script:5: in main chunk RE: TELEGRAM APP - admin - 04.03.2021 You are missing this before function telegram(message): Code: require('ssl.https') RE: TELEGRAM APP - khalil - 04.03.2021 (04.03.2021, 10:38)admin Wrote: You are missing this before function telegram(message): thanks you are rigt I forget this: require('ssl.https') RE: TELEGRAM APP - khalil - 04.03.2021 Hello is it possible to send csv file to telegram? RE: TELEGRAM APP - admin - 04.03.2021 See this example: https://forum.logicmachine.net/showthread.php?tid=2792&pid=17944#pid17944 Replace name/filename as needed, set ctype to text/csv and finally replace /sendPhoto with /sendDocument in the URL. |