I will try it later this day, thanks for the option.
I moved the script over from os.execute to dz.openurl
Than it was possible to use the https api without issues
Made this script. This is the start to use it for:
- Doorbell is pushed, camera image is send to telegram and a question (telegram keyboard) is posted undernead it, if you would like to get a new (extra) camera image
- After X time (for me 30 seconds) the keyboard is removed again. Because i couldn't send a remove without text. I will take a callback on the remove keyboard to get the message-id out of it. Then remove the message which is send for the remove-keyboard. This also with no notification.
Code: Select all
return {
on = {
customEvents = { 'myCustomEvent',},
--devices = {'Trigger device'}, -- De switch die dit scripts triggerd
httpResponses = { "Telegram_Callback"} -- Niet aanpassen
},
--[[
Custom event trigger json:
192.168.XXX.XXX:8080/json.htm?type=command¶m=customevent&event=myCustomEvent&data=myData
]]--
execute = function(dz, item)
local teleTok = 'xxxxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -- Jouw telegram token
local chatId = 'xxxxxxxxx' -- Jouw telegram ChatId
local tekstpost = 'Kies een optie.' -- De tekst voor het telegram tekst bericht
local tekstremove = 'KeuzeMenuWeg'
local disable_notify = 'true' -- Als het telegram bericht geen geluid mag maken, dan 'true'
-- Anders op 'false' zetten
local KeuzeMenuWeg = 30 -- Aantal seconden, waarna het keuzemenu verwijdert dient te worden.
debug = false -- Als debug nodig is, deze op true zetten, anders false
if item.isHTTPResponse then
if (item.ok) then
local id_message = item.json.result.message_id
if debug then
print (id_message)
end
os.execute('curl -s -X POST "https://api.telegram.org/bot'..teleTok..'/deleteMessage?chat_id='..chatId..'&message_id='..id_message..'"')
else
if debug then
print ('niet goed')
end
end
else
local myurl1 = 'https://api.telegram.org/bot'..teleTok..'/sendMessage?chat_id='..chatId..'&text='..tekstpost..'&reply_markup={"keyboard":[["Yes"],["No"]],"one_time_keyboard":true,"resize_keyboard":true}'
if debug then
print (myurl1)
end
dz.openURL(
{
url = myurl1,
method = "POST",
})
local myurl2 = 'https://api.telegram.org/bot'..teleTok..'/sendMessage?chat_id='..chatId..'&text='..tekstremove..'&reply_markup={"remove_keyboard":true}&disable_notification='..disable_notify..''
if debug then
print (myurl2)
end
dz.openURL(
{
url = myurl2,
method = "GET",
callback = "Telegram_Callback",
}).afterSec(KeuzeMenuWeg)
end
end
}