Skip to content

添加gotify自建推送服务支持 #19

@GunVeda

Description

@GunVeda

使用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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions