🤖️sync 2021-07-27 23:24:21

This commit is contained in:
root 2021-07-27 23:24:21 +08:00
parent 3f5eac6d4f
commit 554c5cede4
3 changed files with 116 additions and 46 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
## Build 20210722-001
## Build 20210727-001
## 导入通用变量与函数
dir_shell=/ql/shell
@ -20,6 +20,9 @@ repo=$repo4 #默认调用 shufflewzc 仓
## 调试模式开关默认是0表示关闭设置为1表示开启
DEBUG="1"
## 本脚本限制的最大线程数量
proc_num="7"
## 备份配置文件开关默认是1表示开启设置为0表示关闭。备份路径 /ql/config/bak/
BACKUP="1"
## 是否删除指定天数以前的备份文件开关默认是1表示开启设置为0表示关闭。删除路径 /ql/config/bak/
@ -68,7 +71,8 @@ diy_help_rules(){
BreakHelpType="0" ## 屏蔽模式
BreakHelpNum="4 9-14 15~18 19_21" ## 屏蔽账号序号或序号区间
## 定义是否自动更新配置文件中的互助码和互助规则默认为1表示更新留空或其他数值表示不更新。
## 定义是否自动更新配置文件中的互助码和互助规则
## 默认为 UpdateType="1" 表示更新互助码和互助规则UpdateType="2" 表示只更新互助码不更新互助规则UpdateType="3" 表示只更新互助规则,不更新互助码;留空或其他数值表示不更新。
UpdateType="1"
## 定义是否自动安装或修复缺失的依赖默认为1表示自动修复留空或其他数值表示不修复。
@ -209,7 +213,7 @@ export_codes_sub() {
local BreakHelpInterval=$(echo $BreakHelpNum | perl -pe "{s|~|-|; s|_|-|}" | sed 's/\(\d\+\)-\(\d\+\)/{\1..\2}/g')
local BreakHelpNumArray=($(eval echo $BreakHelpInterval))
local BreakHelpNumVerify=$(echo $BreakHelpNum | sed 's/ //g' | perl -pe "{s|-||; s|~||; s|_||}" | sed 's/^\d\+$//g')
local i j k m n t pt_pin_in_log code tmp_grep tmp_my_code tmp_for_other user_num tmp_helptype HelpTemp random_num_list
local i j k m n q t pt_pin_in_log code tmp_grep tmp_my_code tmp_for_other user_num tmp_helptype HelpTemp random_num_list
local envs=$(eval echo "\$JD_COOKIE")
local array=($(echo $envs | sed 's/&/ /g'))
local user_sum=${#array[*]}
@ -245,6 +249,17 @@ export_codes_sub() {
## 输出ForOther系列变量
if [[ ${#code[*]} -gt 0 ]]; then
[[ $DiyHelpType = "1" ]] && diy_help_rules $2
case $2 in
Fruit | Bean | DreamFactory | Jxnc | Cfd)
q="4"
;;
Pet)
q="6"
;;
*)
q="$user_sum"
;;
esac
case $tmp_helptype in
0) ## 全部一致
HelpTemp="全部一致"
@ -279,7 +294,7 @@ export_codes_sub() {
for ((m = 0; m < ${#pt_pin[*]}; m++)); do
tmp_for_other=""
j=$((m + 1))
for ((n = $m; n < $(($user_sum + $m)); n++)); do
for ((n = $m; n < $(($q + $m)); n++)); do
[[ $m -eq $n ]] && continue
if [[ $((n + 1)) -le $user_sum ]]; then
k=$((n + 1))
@ -309,7 +324,7 @@ export_codes_sub() {
echo -e "\n## 采用\"$HelpTemp\"互助模板:"
for ((m = 0; m < ${#pt_pin[*]}; m++)); do
tmp_for_other=""
random_num_list=$(seq $user_sum | sort -R)
random_num_list=$(seq $user_sum | sort -R | head -$((q-1)))
j=$((m + 1))
for n in $random_num_list; do
[[ $j -eq $n ]] && continue
@ -337,7 +352,7 @@ export_codes_sub() {
for ((m = 0; m < ${#pt_pin[*]}; m++)); do
tmp_for_other=""
j=$((m + 1))
for ((n = 0; n < ${#pt_pin[*]}; n++)); do
for ((n = 0; n < $q; n++)); do
[[ $m -eq $n ]] && continue
k=$((n + 1))
if [[ $BreakHelpType = "1" ]]; then
@ -392,7 +407,7 @@ export_all_codes() {
esac
fi
[[ $BreakHelpType = "1" ]] && echo -e "\n#$cur_time 您已启用屏蔽模式,账号 $BreakHelpNum 将不被助力!"
if [ "$ps_num" -gt 7 ]; then
if [ "$ps_num" -gt $proc_num ]; then
echo -e "\n#$cur_time 检测到 code.sh 的线程过多 ,请稍后再试!"
exit
elif [ -z $repo ]; then
@ -413,7 +428,7 @@ export_all_codes() {
}
#更新配置文件中互助码的函数
help_codes_rules(){
help_codes(){
local envs=$(eval echo "\$JD_COOKIE")
local array=($(echo $envs | sed 's/&/ /g'))
local user_sum=${#array[*]}
@ -450,6 +465,17 @@ for ((i=1; i<=100; i++)); do
sed -i "s/^$config_name_my$i='\S*'$/$config_name_my$i=''/" $file_task_before
fi
done
}
#更新配置文件中互助规则的函数
help_rules(){
local envs=$(eval echo "\$JD_COOKIE")
local array=($(echo $envs | sed 's/&/ /g'))
local user_sum=${#array[*]}
local config_name=$1
local config_name_my=My$config_name
local config_name_for_other=ForOther$config_name
local i j k
#更新配置文件中的互助规则
if [ -z "$(cat $file_task_before | grep "^$config_name_for_other\d")" ]; then
@ -544,7 +570,7 @@ export_codes_sub_only(){
echo "$config_name$j='$tmp_my_code'"
done
else
echo "#$cur_time 从日志中未找到任何互助码"
echo "## 从日志中未找到任何互助码"
fi
fi
}
@ -555,11 +581,12 @@ update_help(){
latest_log=$log_path
case $UpdateType in
1)
if [ "$ps_num" -le 7 ] && [ -f $log_path ] && [ -f $file_task_before ]; then
if [ "$ps_num" -le $proc_num ] && [ -f $log_path ] && [ -f $file_task_before ]; then
backup_del
echo -e "\n#$cur_time 开始更新配置文件的互助码和互助规则" | tee -a $latest_log
for i in ${name_config[@]}; do
help_codes_rules $i
help_codes $i
help_rules $i
done
for i in ${name_config_only[@]}; do
help_codes_only $i
@ -572,6 +599,39 @@ case $UpdateType in
echo -e "\n#$cur_time 配置文件不存在,请检查后重试!" | tee -a $latest_log
fi
;;
2)
if [ "$ps_num" -le $proc_num ] && [ -f $log_path ] && [ -f $file_task_before ]; then
backup_del
echo -e "\n#$cur_time 开始更新配置文件的互助码,不更新互助规则" | tee -a $latest_log
for i in ${name_config[@]}; do
help_codes $i
done
for i in ${name_config_only[@]}; do
help_codes_only $i
done
sed -i "4c ## 上次导入时间:$(date +%Y年%m月%d日\ %X)" /ql/config/task_before.sh
echo -e "\n#$cur_time 配置文件的互助码已完成更新" | tee -a $latest_log
elif [ ! -f $log_path ]; then
echo -e "\n#$cur_time 日志文件不存在,请检查后重试!" | tee -a $latest_log
elif [ ! -f $file_task_before ]; then
echo -e "\n#$cur_time 配置文件不存在,请检查后重试!" | tee -a $latest_log
fi
;;
3)
if [ "$ps_num" -le $proc_num ] && [ -f $log_path ] && [ -f $file_task_before ]; then
backup_del
echo -e "\n#$cur_time 开始更新配置文件的互助规则,不更新互助码" | tee -a $latest_log
for i in ${name_config[@]}; do
help_rules $i
done
sed -i "4c ## 上次导入时间:$(date +%Y年%m月%d日\ %X)" /ql/config/task_before.sh
echo -e "\n#$cur_time 配置文件的互助规则已完成更新" | tee -a $latest_log
elif [ ! -f $log_path ]; then
echo -e "\n#$cur_time 日志文件不存在,请检查后重试!" | tee -a $latest_log
elif [ ! -f $file_task_before ]; then
echo -e "\n#$cur_time 配置文件不存在,请检查后重试!" | tee -a $latest_log
fi
;;
*)
echo -e "\n#$cur_time 您已设置不更新配置文件的互助码和互助规则,跳过更新!" | tee -a $latest_log
;;
@ -654,11 +714,13 @@ install_dependencies_force(){
}
install_dependencies_all(){
install_dependencies_normal $package_name
cd /ql/scripts
for i in $package_name; do
install_dependencies_force $i
done
if [ "$ps_num" -le $proc_num ]; then
install_dependencies_normal $package_name
cd /ql/scripts
for i in $package_name; do
install_dependencies_force $i
done
fi
}

View File

@ -1,6 +1,6 @@
## Version: v2.8.0
## Date: 2021-06-20
## Mod: Build20210727-001
## Mod: Build20210727-002
## Update Content: 可持续发展纲要\n1. session管理破坏性修改\n2. 配置管理可编辑config下文件\n3. 自定义脚本改为查看脚本\n4. 移除互助相关
## 上面版本号中如果第2位数字有变化那么代表增加了新的参数如果只有第3位数字有变化仅代表更新了注释没有增加新的参数可更新可不更新
@ -125,10 +125,10 @@ export GOBOT_QQ=""
## TempBlockCookie="2" # Cookie2 不玩京喜工厂和东东工厂
## ;;
## *jd_jdzz* | *jd_joy*) # 京喜赚赚和宠汪汪的活动脚本关键词
## TempBlockCookie="3 6" # Cookie3 、Cookie6 不玩京东赚赚和宠汪汪
## TempBlockCookie="3 7_8 9-10 12~13" # Cookie3 、Cookie7至8、Cookie9至10、Cookie12至13 不玩京东赚赚和宠汪汪
## ;;
## *) # 其他活动
## TempBlockCookie="" # 默认为空值,表示其他帐号参加全部活动。填写帐号序号表示临时屏蔽指定 Cookie 参加其他活动
## TempBlockCookie="" # 默认为空值,表示其他帐号参加全部活动。填写帐号序号表示临时指定 Cookie 只能参加其他活动
## ;;
## esac
case $1 in

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Build 20210722-001
# Build 20210727-001
## 东东农场:
MyFruit1=''
@ -141,38 +141,59 @@ var_name=(
TokenJxnc ## 17、京喜Token(京喜财富岛提现用)
)
## 临时屏蔽某账号运行活动脚本
TempBlock_JD_COOKIE(){
source $file_env
local TempBlockCookieInterval=$(echo $TempBlockCookie | perl -pe "{s|~|-|; s|_|-|}" | sed 's/\(\d\+\)-\(\d\+\)/{\1..\2}/g')
local TempBlockCookieArray=($(eval echo $TempBlockCookieInterval))
local envs=$(eval echo "\$JD_COOKIE")
local array=($(echo $envs | sed 's/&/ /g'))
local user_sum=${#array[*]}
local m n t
for ((m = 1; m <= $user_sum; m++)); do
n=$((m - 1))
for ((t = 0; t < ${#TempBlockCookieArray[*]}; t++)); do
[[ "${TempBlockCookieArray[t]}" = "$m" ]] && unset array[n]
done
done
jdCookie=$(echo ${array[*]} | sed 's/\ /\&/g')
[[ ! -z $jdCookie ]] && export JD_COOKIE="$jdCookie"
temp_user_sum=${#array[*]}
}
## 组合互助码格式化为全局变量的函数
combine_sub() {
source $file_env
local what_combine=$1
local combined_all=""
local tmp1 tmp2
local TempBlockCookieArray=($(echo $TempBlockCookie))
local TempBlockCookieInterval=$(echo $TempBlockCookie | perl -pe "{s|~|-|; s|_|-|}" | sed 's/\(\d\+\)-\(\d\+\)/{\1..\2}/g')
local TempBlockCookieArray=($(eval echo $TempBlockCookieInterval))
local envs=$(eval echo "\$JD_COOKIE")
local array=($(echo $envs | sed 's/&/ /g'))
local user_sum=${#array[*]}
local a b c i j sum
for ((j=1; j <= $user_sum; j++)); do
local tmp1=$what_combine$j
local a b i j t sum
for ((i=1; i <= $user_sum; i++)); do
local tmp1=$what_combine$i
local tmp2=${!tmp1}
[[ ${tmp2} ]] && sum=$j || break
[[ ${tmp2} ]] && sum=$i || break
done
for ((i = 1; i <= $user_sum; i++)); do
for ((j = 1; j <= $user_sum; j++)); do
a=$temp_user_sum
b=${#TempBlockCookieArray[*]}
c=$sum
if [[ $a -ne $c ]]; then
for num in ${TempBlockCookie}; do
[[ $i -eq $num ]] && continue 2
b=$sum
if [[ $a -ne $b ]]; then
for ((t = 0; t < ${#TempBlockCookieArray[*]}; t++)); do
[[ "${TempBlockCookieArray[t]}" = "$j" ]] && continue 2
done
fi
local tmp1=$what_combine$i
local tmp1=$what_combine$j
local tmp2=${!tmp1}
combined_all="$combined_all&$tmp2"
done
echo $combined_all | perl -pe "{s|^&||; s|^@+||; s|&@|&|g; s|@+&|&|g; s|@+|@|g; s|@+$||}"
}
## 正常依次运行时,组合所有账号的Cookie与互助码
## 正常依次运行时,组合互助码格式化为全局变量
combine_all() {
for ((i = 0; i < ${#env_name[*]}; i++)); do
result=$(combine_sub ${var_name[i]})
@ -182,19 +203,6 @@ combine_all() {
done
}
## 临时屏蔽某账号运行活动脚本
TempBlock_JD_COOKIE(){
source $file_env
local envs=$(eval echo "\$JD_COOKIE")
local array=($(echo $envs | sed 's/&/ /g'))
for num in ${TempBlockCookie}; do
unset array[$(($num-1))]
done
jdCookie=$(echo ${array[*]} | sed 's/\ /\&/g')
[[ ! -z $jdCookie ]] && export JD_COOKIE="$jdCookie"
temp_user_sum=${#array[*]}
}
TempBlock_JD_COOKIE
#if [[ $(ls $dir_code) ]]; then