Skip to content

Commit

Permalink
A push_impl.dingtalk.sh, U push_notify.sh, _disk_notify_global.exampl…
Browse files Browse the repository at this point in the history
…e: add backend dingtalk
  • Loading branch information
yurenchen000 committed Oct 25, 2024
1 parent f783b3d commit b90f6d3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions _disk_notify_global.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ TELEGRAM_CHAT_ID='your chat id here'

push_backend='feishu'
FEISHU_BOT_TOKEN='your feishu bot token (uuid) here'
## don't turn on signature
## https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot#42b6d092

push_backend='dingtalk'
DINGTALK_BOT_TOKEN='your dingtalk bot token (uuid) here'
## don't turn on signature
## https://open.dingtalk.com/document/orgapp/obtain-the-webhook-address-of-a-custom-robot


## backend can set multi channels now
push_backend='wxpusher pushplus'
Expand Down
30 changes: 30 additions & 0 deletions push_impl.dingtalk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

## --------- push via feishu bot

## need conf
# DINGTALK_BOT_TOKEN=

## msg is markdown //also support text (via content)
do_push_dingtalk(){
local tit="$1"
local msg="$2"

curl -s "https://oapi.dingtalk.com/robot/send?access_token=$DINGTALK_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d @- <<-EOF
{
"msgtype": "markdown",
"markdown": {
"title": "$tit",
"text": "**== $tit ==** \n$msg"
}
}
EOF

echo
# echo "==`date -Is`: $tit: $msg" >&2
}

## note: this file indent need to be tabs, cause bash here-doc
## msg formats: https://open.dingtalk.com/document/orgapp/custom-bot-send-message-type#66407430cd5xr

2 changes: 2 additions & 0 deletions push_notify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ do_push_notify(){
case "$backend" in
telegram) do_push_telegram "$tit" "$msg";;
feishu) do_push_feishu "$tit" "$msg";;
dingtalk) do_push_dingtalk "$tit" "$msg";;
pushplus) do_push_pushplus "$tit" "$msg";;
wxpusher) do_push_wxpusher "$tit" "$msg";;
serverchan) do_push_serverchan "$tit" "$msg";;
Expand All @@ -32,6 +33,7 @@ load_push_impl(){
case "$backend" in
telegram) source $dir/push_impl.telegram.sh;;
feishu) source $dir/push_impl.feishu.sh;;
dingtalk) source $dir/push_impl.dingtalk.sh;;
pushplus) source $dir/push_impl.pushplus.sh;;
wxpusher) source $dir/push_impl.wxpusher.sh;;
serverchan) source $dir/push_impl.serverchan.sh;;
Expand Down

0 comments on commit b90f6d3

Please sign in to comment.