kpcyrd/notify-telegram
function run(arg)
local bot_token = getopt('bot_token')
if not bot_token then return '-o bot_token= missing' end
local chat_id = intval(getopt('chat_id'))
if not chat_id then return '-o chat_id= missing' end
local url = 'https://api.telegram.org/bot' .. bot_token .. '/sendMessage'
local text = arg['subject']
if arg['body'] then
text = '**' .. text .. '**\n\n' .. arg['body']
end
local session = http_mksession()
local req = http_request(session, 'POST', url, {
json={
text=text,
chat_id=chat_id,
},
})
local r = http_fetch_json(req)
debug(r)
end