11.07.2020, 18:47
(01.06.2020, 14:29)Daniel. Wrote: It was explained here https://forum.logicmachine.net/showthrea...13#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.
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')
local token = 'token' -- your token
local chat_id = '1234567' -- your chat id
function telegram(message)
local telegram_url = 'https://api.telegram.org/bot' .. token .. '/sendMessage?'
message=socket.url.escape(message)
local data_str = 'chat_id=' .. chat_id .. '&text=' .. message..''
local res, code, headers, status = ssl.https.request(telegram_url, data_str)
end
6. Create an event based script and use this code to send message to Telegram app:
Code:require("user.telegram")
message = 'test message'
res, err = telegram(message)
log(res, err)
Thank you all so much for your help.