From e90d37ac9b54fc955a231e2186e6f1d2973301fb Mon Sep 17 00:00:00 2001 From: root Date: Mon, 16 Aug 2021 04:10:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=EF=B8=8Fsync=202021-08-16=2004:10:?= =?UTF-8?q?01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scripts/sh/Helpcode2.8/code.sh | 8 +- Scripts/sh/Helpcode2.8/config_sample.sh | 39 +++++++- Scripts/sh/Helpcode2.8/task_before.sh | 117 +++++++++++++++++++----- 3 files changed, 134 insertions(+), 30 deletions(-) diff --git a/Scripts/sh/Helpcode2.8/code.sh b/Scripts/sh/Helpcode2.8/code.sh index 178cbe1..912679d 100644 --- a/Scripts/sh/Helpcode2.8/code.sh +++ b/Scripts/sh/Helpcode2.8/code.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -## Build 20210811-001 +## Build 20210816-001 ## 导入通用变量与函数 dir_shell=/ql/shell @@ -400,10 +400,6 @@ export_all_codes() { echo -e "\n## ${name_chinese[i]}:" export_codes_sub "${name_js[i]}" "${name_config[i]}" "${name_chinese[i]}" done - for ((i = 0; i < ${#name_js_only[*]}; i++)); do - echo -e "\n## ${name_chinese_only[i]}:" - export_codes_sub_only "${name_js_only[i]}" "${name_config_only[i]}" "${name_chinese_only[i]}" - done fi } @@ -674,11 +670,11 @@ install_dependencies_all(){ ## 执行并写入日志 +ps -ef|grep "code.sh"|grep -Ev "grep|$$"|awk '{print $1}'|xargs kill -9 >/dev/null 2>&1 [[ $FixDependType = "1" ]] && [[ "$ps_num" -le $proc_num ]] && install_dependencies_all >/dev/null 2>&1 & latest_log=$(ls -r $dir_code | head -1) latest_log_path="$dir_code/$latest_log" ps_num="$(ps | grep code.sh | grep -v grep | wc -l)" -#[[ ! -z "$(ps -ef|grep -w 'code.sh'|grep -v grep)" ]] && ps -ef|grep -w 'code.sh'|grep -v grep|awk '{print $1}'|xargs kill -9 export_all_codes | perl -pe "{s|京东种豆|种豆|; s|crazyJoy任务|疯狂的JOY|}" sleep 5 update_help diff --git a/Scripts/sh/Helpcode2.8/config_sample.sh b/Scripts/sh/Helpcode2.8/config_sample.sh index 0fa06d3..541894a 100644 --- a/Scripts/sh/Helpcode2.8/config_sample.sh +++ b/Scripts/sh/Helpcode2.8/config_sample.sh @@ -1,6 +1,6 @@ ## Version: v2.8.0 ## Date: 2021-06-20 -## Mod: Build20210815-001 +## Mod: Build20210815-002 ## Update Content: 可持续发展纲要\n1. session管理破坏性修改\n2. 配置管理可编辑config下文件\n3. 自定义脚本改为查看脚本\n4. 移除互助相关 ## 上面版本号中,如果第2位数字有变化,那么代表增加了新的参数,如果只有第3位数字有变化,仅代表更新了注释,没有增加新的参数,可更新可不更新 @@ -170,8 +170,8 @@ esac ## esac case $1 in *jd_fruit*) - RandomMode="1" - ran_num="5" + RandomMode="" + ran_num="" ;; *jd_dreamFactory* | *jd_jdfactory*) RandomMode="" @@ -183,6 +183,39 @@ case $1 in ;; esac +## 12. 组队环境变量 +### 环境变量填写要求较高,建议群组内确认填写结果 +scr_name="$1" ## 不可删除 +case $1 in + *jd_sendBean* | *jd_sddd*) ## 送豆得豆活动脚本关键词 + teamer_num="11" ## 单个队伍中的总账号数为 11 个 + team_num="1" ## 每个账号发起组队的最大队伍数为 1 个 + ;; + *xmGame*) ## 小米-星空大冒险活动脚本关键词 + teamer_num="11" ## 单个队伍中的总账号数为 11 个 + team_num="1" ## 每个账号发起组队的最大队伍数为 1 个 + ;; + *jd_zdjr*) ## 组队瓜分京豆活动脚本关键词 + teamer_num="5 5 5 5" ## 对应各个活动中单个队伍中的总账号数分别为 5 5 5 5 个 + team_num="2 3 3 5" ## 对应各个活动中每个账号发起组队的最大队伍数为 2 3 3 5 个 + activityId=( ## 活动 activityId;需手动抓包。按数组分行填写至括号内 + 54f071f4eb794092a872392696be7d8d + 0582063f78434ed599becfc8f812c2ee + bbda11ba7a9644148d65c8b0b78f0bd2 + 92c03af2ce744f6f94de181ccee15e4f + ) + activityUrl=( ## 活动 activityUrl;需手动抓包。按数组分行填写至括号内 + https://cjhydz-isv.isvjcloud.com + https://lzkjdz-isv.isvjcloud.com + https://lzkjdz-isv.isvjcloud.com + https://cjhydz-isv.isvjcloud.com + ) + ;; + *) ## 不可删除 + scr_name="" ## 不可删除 + ;; ## 不可删除 +esac + ## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可 # 定义每日签到的通知形式 diff --git a/Scripts/sh/Helpcode2.8/task_before.sh b/Scripts/sh/Helpcode2.8/task_before.sh index c79a8d7..b4efc5a 100644 --- a/Scripts/sh/Helpcode2.8/task_before.sh +++ b/Scripts/sh/Helpcode2.8/task_before.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -# Build 20210815-001 +# Build 20210815-002 + +p1=$1 name_js=( jd_fruit @@ -99,8 +101,9 @@ TempBlock_JD_COOKIE(){ temp_user_sum=${#array[*]} } +## 随机账号运行活动 Random_JD_COOKIE(){ - source $file_env + [[ -z $JD_COOKIE ]] && source $file_env local envs=$(eval echo "\$JD_COOKIE") local array=($(echo $envs | sed 's/&/ /g')) local user_sum=${#array[*]} @@ -120,6 +123,71 @@ Random_JD_COOKIE(){ fi } +## 组队任务 +combine_team(){ + p=$1 + q=$2 + export jd_zdjr_activityId=$3 + export jd_zdjr_activityUrl=$4 +} + +team_task(){ + [[ -z $JD_COOKIE ]] && source $file_env + local envs=$(eval echo "\$JD_COOKIE") + local array=($(echo $envs | sed 's/&/ /g')) + local user_sum=${#array[*]} + local i j k x y p q + local scr=$scr_name + local teamer_array=($teamer_num) + local team_array=($team_num) + if [[ -f /ql/scripts/$scr ]]; then + for ((i=0; i<${#teamer_array[*]}; i++)); do + combine_team ${teamer_array[i]} ${team_array[i]} ${activityId[i]} ${activityUrl[i]} + [[ $q -ge $(($user_sum/p)) ]] && q=$(($user_sum/p)) + for ((m = 0; m < $user_sum; m++)); do + j=$((m + 1)) + x=$((m/q)) + y=$(((p - 1)*m + 1)) + COOKIES_HEAD="${array[x]}" + COOKIES="" + if [[ $j -le $q ]]; then + for ((n = 1; n < $p; n++)); do + COOKIES="$COOKIES&${array[y]}" + let y++ + done + elif [[ $j -eq $((q + 1)) ]]; then + for ((n = 1; n < $((p-1)); n++)); do + COOKIES_HEAD="${array[x]}&${array[0]}" + COOKIES="$COOKIES&${array[y]}" + let y++ + done + elif [[ $j -gt $((q + 1)) ]]; then + [[ $((y+1)) -le $user_sum ]] && y=$(((p - 1)*m)) || break + for ((n = $m; n < $((m + p -1)); n++)); do + COOKIES="$COOKIES&${array[y]}" + let y++ + [[ $y = $x ]] && y=$((y+1)) + [[ $((y+1)) -gt $user_sum ]] && break + done + fi + result=$(echo -e "$COOKIES_HEAD$COOKIES") + if [[ $result ]]; then + export JD_COOKIE=$result + if [[ ${#activityId[*]} -gt 0 ]]; then + for ((k=0; k<=${#activityId[*]}; k++)); do + node /ql/scripts/$scr + done + else + node /ql/scripts/$scr + fi + fi +# echo $JD_COOKIE + done + done + exit + fi +} + ## 组合互助码格式化为全局变量的函数 combine_sub() { source $file_env @@ -163,31 +231,38 @@ combine_all() { done } -for ((i = 0; i < ${#env_name[*]}; i++)); do - export ${env_name[i]}="" -done +## 正常依次运行时,组合互助码格式化为全局变量 +combine_only() { + local scr=$p1 ## 活动脚本完整文件名 + for ((i = 0; i < ${#env_name[*]}; i++)); do + case $scr in + *${name_js[i]}.js | *${name_js[i]}.ts) + if [[ -f $dir_log/.ShareCode/${name_config[i]}.log ]]; then + . $dir_log/.ShareCode/${name_config[i]}.log + result=$(combine_sub ${var_name[i]}) + if [[ $result ]]; then + export ${env_name[i]}=$result + fi + fi + ;; + *) + export ${env_name[i]}="" + ;; + esac + done +} TempBlock_JD_COOKIE && Random_JD_COOKIE +if [ $scr_name ]; then + team_task +elif [ $p1 ]; then + combine_only +fi + #if [[ $(ls $dir_code) ]]; then # latest_log=$(ls -r $dir_code | head -1) # . $dir_code/$latest_log # combine_all #fi -for ((i = 0; i < ${#env_name[*]}; i++)); do - case $1 in - *${name_js[i]}.js | *${name_js[i]}.ts) - if [[ -f $dir_log/.ShareCode/${name_config[i]}.log ]]; then - . $dir_log/.ShareCode/${name_config[i]}.log - result=$(combine_sub ${var_name[i]}) - if [[ $result ]]; then - export ${env_name[i]}=$result - fi - fi - ;; - *) - export ${env_name[i]}="" - ;; - esac -done