Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions luasrc/model/cbi/pushbot/setting.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ a.default="/usr/bin/pushbot/api/dingding.json"
a.rmempty = true
a:value("/usr/bin/pushbot/api/dingding.json",translate("钉钉"))
a:value("/usr/bin/pushbot/api/ent_wechat.json",translate("企业微信"))
a:value("/usr/bin/pushbot/api/ent_wechat_app_text.json",translate("企业微信应用text"))
a:value("/usr/bin/pushbot/api/telegram.json", translate("Telegram"))
a:value("/usr/bin/pushbot/api/feishu.json",translate("飞书"))
a:value("/usr/bin/pushbot/api/bark.json",translate("Bark"))
a:value("/usr/bin/pushbot/api/pushplus.json",translate("PushPlus"))
Expand All @@ -53,6 +55,49 @@ a=s:taboption("basic", Value,"dd_webhook",translate('Webhook'), translate("钉
a.rmempty = true
a:depends("jsonpath","/usr/bin/pushbot/api/dingding.json")

a = s:taboption("basic", Value, "corpid", translate('企业ID(corpid)'), translate("").."获取说明 <a href='https://work.weixin.qq.com/api/doc/10013' target='_blank'>点击这里</a>")
a.rmempty = true
a:depends("jsonpath", "/usr/bin/pushbot/api/ent_wechat_app_text.json")

a = s:taboption("basic", Value, "userid", translate('帐号(userid)'))
a.rmempty = true
a.description = translate("群发到应用请填入 @all ")
a:depends("jsonpath", "/usr/bin/pushbot/api/ent_wechat_app_text.json")

a = s:taboption("basic", Value, "agentid", translate('应用id(agentid)'))
a.rmempty = true
a:depends("jsonpath", "/usr/bin/pushbot/api/ent_wechat_app_text.json")

a = s:taboption("basic", Value, "corpsecret", translate('应用密钥(Secret)'))
a.rmempty = true
a:depends("jsonpath", "/usr/bin/pushbot/api/ent_wechat_app_text.json")

a = s:taboption("basic", ListValue,"push_mode",translate("推送模式"))
a.default="0"
a.rmempty = true
a:value("0",translate("本机推送"))
a:value("1",translate("ssh推送"))
a:value("2",translate("代理服务器推送"))
a.description = translate("2022年6月之后的应用限制IP,需要设置可信IP")
a:depends("jsonpath", "/usr/bin/pushbot/api/ent_wechat_app_text.json")

a=s:taboption("basic", Value, "push_ip",translate("服务器IP"))
a.rmempty = true
a:depends("push_mode", "1")

a = s:taboption("basic", Value, "push_proxy", translate('代理服务器'))
a.rmempty = true
a:depends("push_mode", "2")
a.description = translate("http代理:http://user:passwd@ip:port")

a = s:taboption("basic", Value, "tg_token", translate("TG_token"), translate("").."获取机器人<a href='https://t.me/BotFather' target='_blank'>点击这里</a><br>与创建的机器人发一条消息,开启对话<br>")
a.rmempty = true
a:depends("jsonpath", "/usr/bin/pushbot/api/telegram.json")

a = s:taboption("basic", Value, "chat_id", translate('TG_chatid'), translate("").."获取 chat_id <a href='https://t.me/getuserIDbot' target='_blank'>点击这里</a>")
a.rmempty = true
a:depends("jsonpath", "/usr/bin/pushbot/api/telegram.json")

a=s:taboption("basic", Value, "we_webhook", translate("Webhook"),translate("企业微信机器人 Webhook")..",只输入key=后面的即可<br>调用代码获取<a href='https://work.weixin.qq.com/api/doc/90000/90136/91770' target='_blank'>点击这里</a><br><br>")
a.rmempty = true
a:depends("jsonpath","/usr/bin/pushbot/api/ent_wechat.json")
Expand Down
33 changes: 33 additions & 0 deletions root/usr/bin/pushbot/api/ent_wechat_app_text.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"_api": "这是企业微信 text 模板信息 api 文件",
"_api": "【企业微信】",

"url": "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$(curl -s \"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=${corpid}&corpsecret=${corpsecret}\"|/usr/bin/jq '.access_token' | sed 's/\"//g')",
"data": "@${tempjsonpath}",
"content_type": "Content-Type: application/json",
"str_title_start": "• ",
"str_title_end": "",
"str_linefeed": "\\n",
"str_splitline": "\\n------\\n",
"table_tab": "",
"font_green": "",
"font_green2": "",
"font_red": "",
"font_blue": "",
"font_purple": "",
"font_end": "",
"font_end2": "",
"percentsym": "",
"boldstar": "**",
"str_space": " ",
"str_tab": "> ",
"type":
{
"touser": "\"${userid}\"",
"msgtype": "\"text\"",
"agentid": "\"${agentid}\"",
"text": {
"content": "\"${1}${str_linefeed}${nowtime}${2}\""
}
}
}
30 changes: 30 additions & 0 deletions root/usr/bin/pushbot/api/telegram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"_api": "这是 telegram api 文件",
"_api": "【telegram】",

"url": "https://api.telegram.org/bot${tg_token}/sendMessage",
"data": "@${tempjsonpath}",
"content_type": "Content-Type: application/json",
"str_title_start": "<b>",
"str_title_end": "</b>",
"str_linefeed": "\\n",
"str_splitline": "\\n----\\n",
"table_tab": "",
"font_green": "",
"font_green2": "",
"font_red": "",
"font_blue": "",
"font_purple": "",
"font_end": "",
"font_end2": "",
"percentsym": "",
"boldstar": "**",
"str_space": " ",
"str_tab": " ",
"type":
{
"text":"\"${str_title_start}${1}${str_title_end}${str_splitline}${nowtime}${2}\"",
"chat_id":"\"${chat_id}\"",
"parse_mode":"\"HTML\""
}
}
16 changes: 12 additions & 4 deletions root/usr/bin/pushbot/pushbot
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function read_config(){
"pushbot_sheep" "starttime" "endtime" "pushbot_whitelist" "pushbot_blacklist" "pushbot_interface" "MAC_online_list" "MAC_offline_list" \
"up_timeout" "down_timeout" "timeout_retry_count" "thread_num" "soc_code" "pve_host" "pve_port"\
"err_enable" "err_sheep_enable" "err_device_aliases" "network_err_event" "system_time_event" "autoreboot_time" "network_restart_time" "public_ip_event" "public_ip_retry_count" \
"jsonpath" "dd_webhook" "we_webhook" "pp_token" "pp_channel" "pp_webhook" "pp_topic_enable" "pp_topic" "fs_webhook" "pushdeer_key" "pushdeer_srv_enable" "pushdeer_srv" "bark_srv_enable" "bark_srv" "bark_token" "bark_sound" "bark_icon" "bark_icon_enable" "bark_level"
"jsonpath" "corpid" "userid" "agentid" "corpsecret" "push_mode" "push_ip" "push_proxy" "tg_token" "chat_id" "dd_webhook" "we_webhook" "pp_token" "pp_channel" "pp_webhook" "pp_topic_enable" "pp_topic" "fs_webhook" "pushdeer_key" "pushdeer_srv_enable" "pushdeer_srv" "bark_srv_enable" "bark_srv" "bark_token" "bark_sound" "bark_icon" "bark_icon_enable" "bark_level"

for str_version in "wrtbwmon" "iputils-arping" "curl" "iw"; do
eval `echo ${str_version:0:2}"_version"`=`opkg list-installed|grep -w ^${str_version}|awk '{print $3}'` 2>/dev/null
Expand Down Expand Up @@ -86,7 +86,7 @@ function pushbot_init(){
[ ! -f "/usr/sbin/wrtbwmon" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】未安装 wrtbwmon ,流量统计不可用" >> ${logfile}
[ -z "$ip_version" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法获取依赖项 iputils-arping 版本号,请确认插件是否正常运行" >> ${logfile}
[ -z "$cu_version" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法获取依赖项 curl 版本号,请确认插件是否正常运行" >> ${logfile}
[ -z "${dd_webhook}${pp_token}${we_webhook}${fs_webhook}${bark_token}${pushdeer_key}" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】请填写正确的Token/Webhook " >> ${logfile} && return 1
[ -z "${dd_webhook}${pp_token}${corpid}${tg_token}${we_webhook}${fs_webhook}${bark_token}${pushdeer_key}" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】请填写正确的Token/Webhook " >> ${logfile} && return 1
local interfacelist=`getinterfacelist` && [ -z "$interfacelist" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法正确获取接口信息,请确认插件是否正常运行" >> ${logfile}
return 0
}
Expand All @@ -103,8 +103,16 @@ function diy_send(){
[ -f ${tempjsonpath} ] && local logrow=$(grep -c "" ${tempjsonpath}) || local logrow="0"
[ $logrow -eq "0" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】json 文件生成失败,请检查文件格式" >> ${logfile} && return 1
/usr/bin/jq -r '.[]' ${tempjsonpath}|grep "null" && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】参数变量生成失败,请检查设置项 `/usr/bin/jq -r '.' ${tempjsonpath}|grep "null"`" >> ${logfile}

curl -X POST -H "$content_type" -d "${data}" "${diyurl}"

if [ "$push_mode" == "1" ]; then
scp $tempjsonpath $push_ip:/tmp/temp.json
data="@/tmp/temp.json"
SSH="ssh $push_ip"
elif [ "$push_mode" == "2" ]; then
USE_PUSH_PROXY="-x $push_proxy"
fi

$SSH curl $USE_PUSH_PROXY -X POST -H "$content_type" -d "${data}" "${diyurl}"
}

# 下载设备MAC厂商信息
Expand Down