Merge pull request #319 from msylgj/serverchan3

feat: Support ServerChan3
This commit is contained in:
tty228 2024-10-24 01:07:38 +08:00 committed by GitHub
commit 892735db62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 68 additions and 2 deletions

View File

@ -136,6 +136,8 @@ return view.extend({
_('Do not use push notifications, only use other features.'));
o.value('/usr/share/wechatpush/api/serverchan.json', _('WeChat serverchan'),
_('Using serverchan API, simple configuration, supports multiple push methods'));
o.value('/usr/share/wechatpush/api/serverchan3.json', _('Serverchan3 APP'),
_('Using serverchan3 API, simple configuration, support push to ServerChan App'));
o.value('/usr/share/wechatpush/api/qywx_mpnews.json', _('WeChat Work Image Message'),
_('Using WeChat Work application message, more complex configuration, and starting from June 20, 2022, additional configuration for trusted IP is required. Trusted IP cannot be shared. This channel is no longer recommended.'));
o.value('/usr/share/wechatpush/api/qywx_markdown.json', _('WeChat Work Markdown Version'),
@ -154,6 +156,20 @@ return view.extend({
o.rmempty = false;
o.depends('jsonpath', '/usr/share/wechatpush/api/serverchan.json');
o = s.taboption('basic', form.Value, 'sc3key', _('「Serverchan3」sendkey'));
o.description = _('Get Instructions') + ' <a href="https://sc3.ft07.com/" target="_blank">' + _('Click here') + '</a>';
o.rmempty = false;
o.depends('jsonpath', '/usr/share/wechatpush/api/serverchan3.json');
o = s.taboption('basic', form.Value, 'sc3uid', _('「Serverchan3」uid'));
o.description = _('ServerChan3 uid');
o.rmempty = false;
o.depends('jsonpath', '/usr/share/wechatpush/api/serverchan3.json');
o = s.taboption('basic', form.Value, 'sc3tags', _('「Serverchan3」tags'));
o.description = _('ServerChan3 message tags, split with |');
o.depends('jsonpath', '/usr/share/wechatpush/api/serverchan3.json');
o = s.taboption('basic', form.Value, 'corpid', _('corpid'));
o.description = _('Get Instructions') + ' <a href="https://work.weixin.qq.com/api/doc/10013" target="_blank">' + _('Click here') + '</a>';
o.rmempty = false;
@ -234,6 +250,7 @@ return view.extend({
o = s.taboption('basic', form.Value, 'proxy_address', _('Proxy Address'));
o.description = _('When you want to use a proxy to push information, you can use this option.<br/>This may be helpful for scenarios like trusted IPs for WeChat Work.Using special characters may cause sending failure.<br/>Example:<br/>http://username:password@127.0.0.1:1080<br/>socks5://username:password@127.0.0.1:1080');
o.depends('jsonpath', '/usr/share/wechatpush/api/serverchan.json');
o.depends('jsonpath', '/usr/share/wechatpush/api/serverchan3.json');
o.depends('jsonpath', '/usr/share/wechatpush/api/qywx_mpnews.json');
o.depends('jsonpath', '/usr/share/wechatpush/api/wxpusher.json');
o.depends('jsonpath', '/usr/share/wechatpush/api/pushplus.json');
@ -258,6 +275,7 @@ return view.extend({
});
}
o.depends('jsonpath', '/usr/share/wechatpush/api/serverchan.json');
o.depends('jsonpath', '/usr/share/wechatpush/api/serverchan3.json');
o.depends('jsonpath', '/usr/share/wechatpush/api/qywx_mpnews.json');
o.depends('jsonpath', '/usr/share/wechatpush/api/wxpusher.json');
o.depends('jsonpath', '/usr/share/wechatpush/api/pushplus.json');

View File

@ -68,6 +68,14 @@ msgstr "微信 Server 酱"
msgid "Using serverchan API, simple configuration, supports multiple push methods"
msgstr "使用 Server酱 接口,配置较简单,支持多项推送方式"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js
msgid "Serverchan3 APP"
msgstr "Server 酱 APP"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js
msgid "Using serverchan3 API, simple configuration, support push to ServerChan App"
msgstr "使用 ServerChan3 接口配置较简单支持推送到Server酱 APP"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js:137
msgid "WeChat Work Image Message"
msgstr "企业微信 图文消息"
@ -108,6 +116,26 @@ msgstr "通过修改 JSON 文件,使用自定义接口"
msgid "「wechatpush」sendkey"
msgstr "「Server酱」sendkey"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js
msgid "「Serverchan3」sendkey"
msgstr "「Server酱3」sendkey"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js
msgid "「Serverchan3」uid"
msgstr "「Server酱3」uid"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js
msgid "ServerChan3 uid"
msgstr "Server酱3 用户独立uid"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js
msgid "「Serverchan3」tags"
msgstr "「Server酱3」消息标签"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js
msgid "ServerChan3 message tags, split with |"
msgstr "Server酱3 使用标签来标记消息类型,支持多个使用|分隔"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js:151
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js:156
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js:184

View File

@ -0,0 +1,20 @@
{
"_api": "这是 serverchan3 api 文件",
"_api": "【serverchan3】",
"url": "\"https://${sc3uid}.push.ft07.com/send/${sc3key}.send\"",
"data": "@${tempjsonpath}",
"content_type": "Content-Type: application/json",
"str_title_start": "##### ",
"str_title_end": "",
"str_linefeed": "\\n",
"str_splitline": "\\n----\\n",
"str_space": " ",
"str_tab": " ",
"type":
{
"title": "\"${1}\"",
"desp": "\"${nowtime}${str_linefeed}${2}\"",
"tags": "\"${sc3tags}\""
}
}

View File

@ -37,7 +37,7 @@ wait_and_cat() {
read_config() {
get_config \
"enable" "lite_enable" "device_name" "proxy_address" "sleeptime" "oui_data" "reset_regularly" "debuglevel" \
"jsonpath" "sckey" "corpid" "userid" "agentid" "corpsecret" "mediapath" "wxpusher_apptoken" "wxpusher_uids" "wxpusher_topicIds" "pushplus_token" "tg_token" "chat_id" \
"jsonpath" "sckey" "sc3key" "sc3uid" "sc3tags" "corpid" "userid" "agentid" "corpsecret" "mediapath" "wxpusher_apptoken" "wxpusher_uids" "wxpusher_topicIds" "pushplus_token" "tg_token" "chat_id" \
"get_ipv4_mode" "ipv4_interface" "get_ipv6_mode" "ipv6_interface" \
"device_notification" "cpu_notification" "cpu_load_threshold" "temperature_threshold" \
"client_usage" "client_usage_max" "client_usage_disturb" "client_usage_whitelist" \
@ -121,7 +121,7 @@ init() {
[ ! -f "/usr/sbin/wrtbwmon" ] && log_change "【info】未安装 wrtbwmon ,流量统计不可用"
[ -z "$ip_version" ] && log_change "【!!!】无法获取依赖项 iputils-arping 版本号,请确认插件是否正常运行"
[ -z "$cu_version" ] && log_change "【!!!】无法获取依赖项 curl 版本号,请确认插件是否正常运行"
[ -n "$jsonpath" ] && [ -z "${sckey}${tg_token}${pushplus_token}${corpid}${wxpusher_apptoken}${wxpusher_uids}${wxpusher_topicIds}" -a "${jsonpath}" != "/usr/share/wechatpush/api/diy.json" ] && log_change "【!!!】请填写正确的 key" && return 1
[ -n "$jsonpath" ] && [ -z "${sckey}${sc3key}${sc3uid}${sc3tags}${tg_token}${pushplus_token}${corpid}${wxpusher_apptoken}${wxpusher_uids}${wxpusher_topicIds}" -a "${jsonpath}" != "/usr/share/wechatpush/api/diy.json" ] && log_change "【!!!】请填写正确的 key" && return 1
local interfacelist=$(getinterfacelist) && [ -z "$interfacelist" ] && log_change "【!!!】存在多个接口或配置错误,可能无法获取接口在线时间等信息,请确认插件是否正常运行"
[ -n "$notification_temp" ] && [ -n "$temperature_threshold" ] && local cpu_temp=$(soc_temp) || local cpu_temp="null"
[ -z "$cpu_temp" ] && log_change "【!!!】无法读取设备温度,请检查命令"