|
|
|
@ -146,6 +146,28 @@ function fileSizeStr(){ |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function Request(){ |
|
|
|
|
while true |
|
|
|
|
do |
|
|
|
|
echo "发送消息命令:$1" |
|
|
|
|
result=`bash -c "$1"` |
|
|
|
|
echo "请求响应:$result" |
|
|
|
|
if [ `echo $result|jq .ok` = true ] |
|
|
|
|
then |
|
|
|
|
return 1 |
|
|
|
|
elif [ `echo $result|jq .error_code` -eq 429 ] |
|
|
|
|
then |
|
|
|
|
second=`echo $result|jq .parameters.retry_after` |
|
|
|
|
sleep $second |
|
|
|
|
echo "${second}后再发起请求" |
|
|
|
|
Request $1 |
|
|
|
|
else |
|
|
|
|
echo "执行命令遇到未知错误!" |
|
|
|
|
return 0 |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
basePath=`cat $config_file|jq -r .basePath` |
|
|
|
|
if [ ! -f $basePath ] |
|
|
|
|
then |
|
|
|
@ -165,10 +187,8 @@ rank_json=$today.json |
|
|
|
|
|
|
|
|
|
rule='sed -e "s/\\&/\\&/g"|sed -e "s/\\</\\</g"|sed -e "s/\\>/\\>/g"' |
|
|
|
|
|
|
|
|
|
sleepText=`cat $config_file | jq .sleep.text` |
|
|
|
|
sleepImage=`cat $config_file | jq .sleep.image` |
|
|
|
|
curl -v -d chat_id=$chat_id -d parse_mode=HTML -d text="Pixiv排行榜已更新,$sleepText秒后开始处理<a href='https://www.pixiv.net/ranking.php?mode%3D$mode%26content%3D$content'>$today日榜</a>数据。#date$_today #日期$_today %0A%0A<strong>排名是什么?</strong>%0A排名是以pixiv上所有公开作品为对象的统计以及排名。%0A毎日0:00~23时59分59秒的阅览树・「赞!」数等为排名的依据,期结果由pixiv独自的算法「pixiv rank β」决定。统计结果于每日中午12:00公开。%0A<a href='https://www.pixiv.help/hc/zh-cn/categories/360001065093-%E6%9C%89%E5%85%B3%E6%8E%92%E8%A1%8C%E6%A6%9C'>有关排行榜</a>" $baseApi/sendMessage |
|
|
|
|
sleep $sleepText |
|
|
|
|
Request "curl -v -d chat_id=$chat_id -d parse_mode=HTML -d text=\"Pixiv排行榜已更新,开始处理<a href='https://www.pixiv.net/ranking.php?mode%3D$mode%26content%3D$content'>$today日榜</a>数据。#date$_today #日期$_today %0A%0A<strong>排名是什么?</strong>%0A排名是以pixiv上所有公开作品为对象的统计以及排名。%0A毎日0:00~23时59分59秒的阅览树・「赞!」数等为排名的依据,期结果由pixiv独自的算法「pixiv rank β」决定。统计结果于每日中午12:00公开。%0A<a href='https://www.pixiv.help/hc/zh-cn/categories/360001065093-%E6%9C%89%E5%85%B3%E6%8E%92%E8%A1%8C%E6%A6%9C'>有关排行榜</a>\" $baseApi/sendMessage" |
|
|
|
|
|
|
|
|
|
if [ ! -f $rank_json ] |
|
|
|
|
then |
|
|
|
|
echo "get data from $rank_url" |
|
|
|
@ -347,19 +367,17 @@ do |
|
|
|
|
fi |
|
|
|
|
if [[ $fileCount -eq $maxFileCount ]] |
|
|
|
|
then |
|
|
|
|
command="curl -v -F chat_id=$chat_id $fileList -F media='[`echo $media | cut -c 2-`]' $baseApi/sendMediaGroup" |
|
|
|
|
echo "上传图片命令:$command" |
|
|
|
|
result=`bash -c "$command"` |
|
|
|
|
|
|
|
|
|
if [ `echo $result|jq .ok` == "true" ] |
|
|
|
|
Request "curl -v -F chat_id=$chat_id $fileList -F media='[`echo $media | cut -c 2-`]' $baseApi/sendMediaGroup" |
|
|
|
|
if [ `echo $?` -eq 1 ] |
|
|
|
|
then |
|
|
|
|
sleep $sleepImage |
|
|
|
|
text="以上作品日榜排名分别是 #排名${start_rank}_${end_rank} #rank${start_rank}_${end_rank} ,点击作品可以查看pid/标题/画师/tag信息." |
|
|
|
|
else |
|
|
|
|
text="#排名${start_rank}_${end_rank} #rank${start_rank}_${end_rank}作品上传失败,请联系管理员" |
|
|
|
|
fi |
|
|
|
|
curl -v -d chat_id=$chat_id -d text=$text $baseApi/sendMessage |
|
|
|
|
sleep $sleepText |
|
|
|
|
|
|
|
|
|
Request "curl -v -d chat_id=$chat_id -d text=\"$text\" $baseApi/sendMessage" |
|
|
|
|
|
|
|
|
|
fileList='' |
|
|
|
|
media='' |
|
|
|
|
fileCount=0 |
|
|
|
@ -369,7 +387,7 @@ done |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
next_expected_at=`curl -v https://cronitor.io/api/monitors/$CronitorJobName -u $CronitorKey:''|jq .next_expected_at` |
|
|
|
|
curl -v -d chat_id=$chat_id -d text="以上就是$today日榜前${length}名作品,本次推送完毕,下次推送时间预计是`date -d @$next_expected_at '+%Y-%m-%d %H:%M:%S'`,如有问题请联系管理员。 #date$_today #日期$_today " $baseApi/sendMessage |
|
|
|
|
Request "curl -v -d chat_id=$chat_id -d text=\"以上就是$today日榜前${length}名作品,本次推送完毕,下次推送时间预计是`date -d @$next_expected_at '+%Y-%m-%d %H:%M:%S'`,如有问题请联系管理员。 #date$_today #日期$_today \" $baseApi/sendMessage" |
|
|
|
|
|
|
|
|
|
find -type f -mtime +7|grep html|xargs rm -f |
|
|
|
|
find -type f -mtime +7|grep json|xargs rm -f |
|
|
|
|