Notification Support Pushover (#9)

* Notification Support Pushover

* fix header

* update README.md
This commit is contained in:
TinK 2023-02-16 13:41:04 +08:00 committed by GitHub
parent 9cf38d402a
commit 011e1928e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 1 deletions

View File

@ -9,6 +9,7 @@
- [x] [钉钉群机器人 DingTalk](https://open.dingtalk.com/document/robots/custom-robot-access)
- [x] [飞书群机器人 Feishu](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN)
- [x] [企业微信群机器人 WeCom](https://developer.work.weixin.qq.com/document/path/91770)
- [x] [Pushover](https://pushover.net/api)
- [x] [邮件 next-smtp-proxy](https://github.com/0wQ/next-smtp-proxy)
- [x] 通过短信控制设备
- [x] 发短信, 格式: `SMS,10010,余额查询`

View File

@ -1,5 +1,5 @@
return {
-- 通知类型 telegram, pushdeer, bark, dingtalk, feishu, wecom, next-smtp-proxy
-- 通知类型 telegram, pushdeer, bark, dingtalk, feishu, wecom, pushover, next-smtp-proxy
NOTIFY_TYPE = "pushdeer",
--
-- telegram 通知配置, https://github.com/0wQ/telegram-notify
@ -24,6 +24,10 @@ return {
-- wecom 通知配置, https://developer.work.weixin.qq.com/document/path/91770
WECOM_WEBHOOK = "",
--
-- pushover 通知配置, https://pushover.net/api
PUSHOVER_API_TOKEN = "",
PUSHOVER_USER_KEY = "",
--
-- next-smtp-proxy 通知配置, https://github.com/0wQ/next-smtp-proxy
NEXT_SMTP_PROXY_API = "",
NEXT_SMTP_PROXY_USER = "",

View File

@ -150,6 +150,38 @@ local function notifyToWeCom(msg)
return util_http.fetch(nil, "POST", config.WECOM_WEBHOOK, header, json_data)
end
-- 发送到 pushover
local function notifyToPushover(msg)
if config.PUSHOVER_API_TOKEN == nil or config.PUSHOVER_API_TOKEN == "" then
log.error("util_notify.notifyToPushover", "未配置 `config.PUSHOVER_API_TOKEN`")
return
end
if config.PUSHOVER_USER_KEY == nil or config.PUSHOVER_USER_KEY== "" then
log.error("util_notify.notifyToPushover", "未配置 `config.PUSHOVER_USER_KEY`")
return
end
local header = {
["Content-Type"] = "application/json; charset=utf-8"
}
local body = {
token = config.PUSHOVER_API_TOKEN,
user = config.PUSHOVER_USER_KEY,
message = msg
}
local json_data = json.encode(body)
-- LuatOS Bug, json.encode 会将 \n 转换为 \b
json_data = string.gsub(json_data, "\\b", "\\n")
local url = "https://api.pushover.net/1/messages.json"
log.info("util_notify.notifyToPushover", "POST", config.PUSHOVER_API_TOKEN)
return util_http.fetch(nil, "POST", url, header, json_data)
end
-- 发送到 next-smtp-proxy
local function notifyToNextSmtpProxy(msg)
if config.NEXT_SMTP_PROXY_API == nil or config.NEXT_SMTP_PROXY_API == "" then
@ -279,6 +311,8 @@ function util_notify.send(msg)
notify = notifyToFeishu
elseif config.NOTIFY_TYPE == "wecom" then
notify = notifyToWeCom
elseif config.NOTIFY_TYPE == "pushover" then
notify = notifyToPushover
elseif config.NOTIFY_TYPE == "next-smtp-proxy" then
notify = notifyToNextSmtpProxy
else