From 9d655033aa64f138434fc4e2f6b55b9909bfae25 Mon Sep 17 00:00:00 2001 From: name Date: Sat, 5 Feb 2022 15:10:41 +0800 Subject: [PATCH] improve code --- scripts/notify.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/notify.sh b/scripts/notify.sh index 93de31b..d410953 100755 --- a/scripts/notify.sh +++ b/scripts/notify.sh @@ -17,7 +17,6 @@ if [ -z $CHATIDS ]; then >&2 echo -e "\033[1;31mMissing ChatIds! Please get ChatId from @GroupIDbot on Telegram Chats(Muti chatids split with comma ',') and set it in Repo Environment Values\033[0m" exit 2 fi -chat_ids=`echo $CHATIDS | sed 's/,/ /g'` function login_gh() { printf "#%.0s" {1..60} @@ -70,11 +69,13 @@ function main() { dest_version=`awk '/DestVersion/ { print $2 }' ${temp_path}/release.info` release_info="$release_info%0A%0A*NotifyFrom:*%20[Github](https://github.com/tom-snow/wechat-windows-versions/releases/tag/v$dest_version)" - for chatid in $chat_ids + echo $CHATIDS | sed 's/,/\n/g' > ${temp_path}/chat_ids + # while IFS="" read -r chatid || [ -n "$chatid" ] + while IFS="" read -r chatid do api_link="https://api.telegram.org/bot$BOTTOKEN/sendMessage?chat_id=$chatid&text=*New%20WeChat%20Windows%20Version!!*%0A%0A$release_info&parse_mode=Markdown&disable_web_page_preview=true" curl -s -o /dev/null $api_link - done + done < ${temp_path}/chat_ids gh auth logout --hostname github.com | echo "y" clean_data 0