Merge remote-tracking branch 'upstream/master'

This commit is contained in:
dlandon
2024-05-08 09:43:32 -05:00
15 changed files with 109 additions and 18 deletions
@@ -624,4 +624,54 @@ done
]]>
</Script>
</Agent>
<Agent>
<Name>Wxwork</Name>
<Variables>
<Variable Help="企业微信的企业ID" Desc="CropId" Default="企业ID">CropId</Variable>
<Variable Help="企业微信应用ID" Desc="AgentId" Default="应用ID">AgentId</Variable>
<Variable Help="企业微信应用的Secret" Desc="Secret" Default="应用Secret">Secret</Variable>
<Variable Help="企业微信的代理通知url[b]http://xxx.com/[/b]nginx的反代,主要是为了让出口IP固定" Desc="ProxyUrl" Default="代理地址">ProxyUrl</Variable>
<Variable Help="Specify the fields which are included in the title of the notification." Desc="Notification Title" Default="$SUBJECT">TITLE</Variable>
<Variable Help="Specify the fields which are included in the message body of the notification." Desc="Notification Message" Default="$DESCRIPTION">MESSAGE</Variable>
</Variables>
<Script>
<![CDATA[
#!/bin/bash
############
{0}
############
# Markdown newline style for message content
TITLE=$(echo -e "$SUBJECT")
MESSAGE=$(echo -e "$DESCRIPTION")
CORP_ID=$(echo -e "$CropId")
APP_SECRET=$(echo -e "$Secret")
TO_USER="@all"
AGENT_ID=$(echo -e "$AgentId")
# 获取 access token
ACCESS_TOKEN=\$(curl -s -G "$proxy_url/cgi-bin/gettoken" \
-d "corpid=\$CORP_ID" \
-d "corpsecret=\$APP_SECRET" | jq -r '.access_token')
# 发送消息
send_message() {
local message="[Unraid]->[\$TITLE]\\n\$MESSAGE"
curl -s -H "Content-Type: application/json" -X POST \
"$ProxyUrl/cgi-bin/message/send?access_token=\$ACCESS_TOKEN" \
-d "{
\"touser\": \"\$TO_USER\",
\"msgtype\": \"text\",
\"agentid\": \"\$AGENT_ID\",
\"text\": {
\"content\": \"\$message\"
},
\"safe\":0
}"
}
# 调用发送消息函数
send_message
]]>
</Script>
</Agent>
</Agents>
+9 -3
View File
@@ -180,16 +180,22 @@ function http_get_contents(string $url, array $opts = [], array &$getinfo = NULL
}
}
$out = curl_exec($ch);
if(isset($getinfo)) {
if (curl_errno($ch) == 23) {
// error 23 detected, try CURLOPT_ENCODING = null
curl_setopt($ch, CURLOPT_ENCODING, null);
$out = curl_exec($ch);
}
if (isset($getinfo)) {
$getinfo = curl_getinfo($ch);
}
if (curl_errno($ch)) {
$msg = curl_error($ch) . " {$url}";
if ($errno = curl_errno($ch)) {
$msg = "Curl error $errno: " . (curl_error($ch) ?: curl_strerror($errno)) . ". Requested url: '$url'";
if(isset($getinfo)) {
$getinfo['error'] = $msg;
}
my_logger($msg, "http_get_contents");
}
curl_close($ch);
return $out;
}
/**