-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
使用gotify的http api发送消息推送
notification_helper.lua添加
local function gotify(sender_number, content)
if not config.notification_channel.gotify.enabled then
return
end
if utils.is_empty(config.notification_channel.gotify.host) then
log.warn("notification_helper", "gotify host 未填写,跳过调用gotify")
return
end
log.info("notification_helper", "正在发送gotify通知")
local request_body = {
title = sender_number,
priority = config.notification_channel.gotify.priority,
message = content
}
local schema = "http"
if config.notification_channel.gotify.ssl then
schema = "https"
end
local code, headers, response_body = http.request(
"POST",
schema .. "://" .. config.notification_channel.gotify.host .. ":" .. config.notification_channel.gotify.port .. "/message?token=" .. config.notification_channel.gotify.app_token,
{ ["Content-Type"] = "application/json" },
json.encode(request_body)
).wait()
if code ~= 200 then
log.warn("notification_helper", "gotify发送消息失败,HTTP状态码:" .. code .. ",响应内容:" .. (response_body or ""))
end
log.info("notification_helper", "gotify通知发送完成")
end
local notification_channels = {
bark = bark,
luatos_notification = luatos_notification,
server_chan = server_chan,
ding_talk_bot = ding_talk_bot,
pushplus = pushplus,
telegram_bot = telegram_bot,
feishu_bot = feishu_bot,
wecom_bot = wecom_bot,
gotify = gotify,
}
config.lua添加
config.notification_channel = {
// ...
gotify = {
enabled = false,
ssl = false,
app_token = "",
host = "",
port = 80,
priority = 5
}
}
Metadata
Metadata
Assignees
Labels
No labels