1
0
mirror of https://github.com/6dylan6/jdpro.git synced 2026-04-20 11:03:08 +08:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Chat240515 73b7f7030c Merge 8bed3d663d into 026f4e5394 2024-07-25 14:03:37 +08:00
153 changed files with 5837 additions and 1224 deletions
-18
View File
@@ -1,18 +0,0 @@
name: 问题反馈 🐞
description: 有问题先更新订阅,不行才提
body:
- type: input
id: version
attributes:
label: 青龙版本
validations:
required: true
- type: textarea
id: description
attributes:
label: 问题描述
description: 尽量详细描述问题,附上错误日志或截图。
placeholder: 请描述
validations:
required: true
-5
View File
@@ -1,5 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: TG Chat
url: https://t.me/dylan_jdpro
about: 关注tg不迷路
@@ -1,9 +0,0 @@
name: "💡功能建议"
description: 为项目提想法
labels: ["pending","feature"]
body:
- type: textarea
id: require
attributes:
label: 需求描述
placeholder: 请描述
+43 -37
View File
@@ -6,15 +6,15 @@
### [TG CHANEL](https://t.me/dylan_jdpro)
国内机(带加速,也不太稳):
国内机(带代理):
```
ql repo https://js.googo.win/https://github.com/6dylan6/jdpro.git "jd_|jx_|jddj_" "backUp" "^jd[^_]|USER|JD|function|sendNotify|utils"
ql repo https://js.jdpro.site/https://github.com/6dylan6/jdpro.git "jd_|jx_|jddj_" "backUp" "^jd[^_]|USER|JD|function|sendNotify|utils"
```
默认代理拉不了,自行找可用代理
国外机(国外ip有限制可能有些任务不能正常运行):
国外机:
```
ql repo https://github.com/6dylan6/jdpro.git "jd_|jx_|jddj_" "backUp" "^jd[^_]|USER|JD|function|sendNotify|utils"
@@ -22,19 +22,31 @@ ql repo https://github.com/6dylan6/jdpro.git "jd_|jx_|jddj_" "backUp" "^jd[^_]|U
```
定时随意
## 使用
1、部署青龙登陆,版本不用追新,稳定才好,推荐部署到内网(不要外网访问,2.20.2以下版本面板会被免密登录偷家,如果必须外网就用最新版本吧)。
线报监控类,[入口](https://github.com/6dylan6/jdm.git)
2、到订阅管理创建订阅并运行;正确配置[参考](https://github.com/6dylan6/jdpro/issues/22)
带图评价(PC版CK,本库也有简化版可用)[入口](https://github.com/6dylan6/auto_comment.git)
3、订阅执行完,到定时任务搜索依赖安装(jd_indeps)任务执行;
4、到环境变量,创建变量,名称: JD_COOKIE,值:抓的CK(要安全就手抓),多个每行建一个,不要全写在一个;
## 简要流程
1、部署青龙并登陆。
2、到配置管理config.sh修改,差不多在17行(特别注意,没有修改此配置,sh类型任务拉不下来);
RepoFileExtensions="js py"修改为 RepoFileExtensions="js py sh" 保存;
3、到订阅管理创建订阅并运行;正确配置[参考](https://github.com/6dylan6/jdpro/issues/22)
4、订阅运行完毕,到定时任务搜索依赖安装任务执行;
4、到环境变量,创建变量,名称: JD_COOKIE,值:抓的CK(要安全就手抓),多个依次创建;
5、配置通知,通知的key填写到配置管理config.sh文件;
6、sendnotify.js文件用库里的到青龙deps目录下,否则会被青龙自带覆盖
<details>
<summary>笔记</summary>
@@ -68,20 +80,33 @@ export NOTIFY_SHOWNAMETYPE="4" 效果是 : 账号名称:备注
3、因为青龙有随机延时(可以在配置文件设置为0,默认300秒),所以涉及准点运行的任务,最后加now,如果是desi或conc不用加也会准时跑。
4、脚本的通知,需把通知key变量在config.sh文件配置
4、青龙系统通知(新增删除任务、登录等通知,需把通知变量写到config.sh文件,在环境变量里只发脚本运行通知哈
5、建议调整任务运行超时时间,青龙默认1小时有些跑不完就被强制结束,config.sh里配置。CommandTimeoutTime="3h" 即改为3小时,根据自己ck数量调整
5、如果通知文件发现和库里的不一致,那是被青龙自带的覆盖了,手动拷贝一份到deps目录下
6、ck掉线,不是常用地ip,短时间内连续获得豆可能就会会触发风控掉线
6、建议调整任务运行超时时间,青龙默认1小时有些跑不完就被强制结束,config.sh里配置。CommandTimeoutTime="3h" 即改为3小时,根据自己ck数量调整。
</code></pre>
</details>
## 通用环境变量(到配置管理-config.sh里添加变量,export xxx='xxx'格式)
AUTOCFG='true' 自动配置sendNotify文件到deps目录
如需禁止某些CK参加所有活动或某些活动功能,实现重组CK顺序功能,包括随机、优先、轮换、组队、分段等功能,把[task_before](./docker/task_before.sh)文件内容复制到配置管理task_before.sh保存
代理API模式(API代理是通过url接得到随机可用代理ip,格式是:xxx.xxx.xxx.xxx:xxxx
常用变量举例:
DY_PROXY='URL1#URL2' 多个#分割
Recombin_CK_Mode="1" 全部顺序随机
Recombin_CK_Mode="2" Recombin_CK_ARG1="15" 假设有100个CK,前15个CK按正常顺序靠前,其余CK随机乱序
Recombin_CK_Mode="3" Recombin_CK_ARG1="5" Recombin_CK_ARG2="5" 假设有100个CK,希望前5个账号始终保持在前部,剩余95个账号按照轮换模式每天轮换5个
其他用法具体参考[文档](https://docs.qq.com/doc/DTXh6QUVjRXJ1TFdN)
## 通用变量
代理API模式部分支持
DY_PROXY='URL1@URL2' 多个@分割
PERMIT_API='test' 需要走API代理的js关键词,多个&分割,可不设置,支持的js都会走
@@ -89,32 +114,13 @@ DY_PROXY_RENUM='5' 获取IP失败重试次数
DY_PROXY_REDELAY='3' 获取失败重试间隔 单位秒
代理池模式(就是一个代理服务器的地址)
代理池模式支持全部js脚
DP_POOL='http://xxx' 代理池url
PERMIT_JS='farm&plant&opencard' 需要走代理池的js关键词,多个&分割(可不设置,如果不设置就是所有的js都会走)
PERMIT_JS='farm&plant&opencard' 需要走代理池的js关键词,多个&分割,必须设置
BANPIN 禁止某pin执行任务
ALLOWPIN 只执行某pin执行任务
多个任务同pin:任务1|任务2@pin1,pin2
多个任务不同pin:任务1@pin,pin2&任务2@pin2,pin3
不指定任务只写pin:全部任务
示例
export BANPIN='draw@pin1,pin2'
export ALLOWPIN='draw@pin1,pin2'
## 支持的通知方式
server酱,go-cqhttppushdeerBark Apptg bot,钉钉bot,企业微信bot,企业微信应用消息,飞书,iGotpush plusWxPushergotify
+11 -6
View File
@@ -1,12 +1,17 @@
version: '2'
services:
ql_web:
image: whyour/qinglong:2.17.9
image: whyour/qinglong:2.11.3
container_name: ql
volumes:
- ./qinglong/data:/ql/data
- ./qinglong/deps/pnpm:/root/.local/share/pnpm
- ./qinglong/deps/pip3:/usr/local/lib/python3.11/site-packages
- ./data/config:/ql/config
- ./data/log:/ql/log
- ./data/db:/ql/db
- ./data/scripts:/ql/scripts
- ./data/repo:/ql/repo
ports:
- "5700:5700"
restart: unless-stopped
- "0.0.0.0:5700:5700"
environment:
- ENABLE_HANGUP=true
- ENABLE_WEB_PANEL=true
restart: always
+17 -8
View File
@@ -46,16 +46,25 @@ cd $ql_path
cat > docker-compose.yml <<EOF
version: '2'
services:
ql_web:
image: whyour/qinglong:2.17.9
container_name: ql
qinglong:
image: whyour/qinglong:2.11.3
container_name: qinglong
volumes:
- ./qinglong/data:/ql/data
- ./qinglong/deps/pnpm:/root/.local/share/pnpm
- ./qinglong/deps/pip3:/usr/local/lib/python3.11/site-packages
- ./data/config:/ql/config
- ./data/log:/ql/log
- ./data/db:/ql/db
- ./data/scripts:/ql/scripts
- ./data/repo:/ql/repo
ports:
- "5700:5700"
restart: unless-stopped
- "0.0.0.0:5500:5700"
networks:
- net
environment:
- ENABLE_HANGUP=true
- ENABLE_WEB_PANEL=true
restart: always
networks:
net:
EOF
docker-compose up -d
if [ $? -ne 0 ] ; then
+2 -7
View File
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
## Build 20220831-001-test
## 6dylan6_20240905
## 6dylan6_0212
name_js=(
jd_farm_help
jd_farmnew_code_help
jd_farm_help_new
#jd_pet
jd_plantBean_help
#jd_dreamFactory
@@ -18,7 +18,6 @@ name_js=(
#jd_sgmh
#jd_cfd
jd_health
jd_farmshare
#jd_carnivalcity
#jd_city
#jd_moneyTree
@@ -39,7 +38,6 @@ name_config=(
#Sgmh
#Cfd
Health
Fruit_new
#Carni
#City
#MoneyTree
@@ -60,7 +58,6 @@ name_chinese=(
#闪购盲盒
#京喜财富岛
东东健康社区
农场小程序助力
#京东手机狂欢城
#城城领现金
#摇钱树
@@ -81,7 +78,6 @@ env_name=(
#JDSGMH_SHARECODES ## 11、闪购盲盒互助码
#JDCFD_SHARECODES ## 12、京喜财富岛互助码
JDHEALTH_SHARECODES ## 13、东东健康社区互助码
NEWFRUITSHARECODES ## 14、新农场小程序
#JD818_SHARECODES ## 14、京东手机狂欢城互助码
#CITY_SHARECODES ## 15、城城领现金互助码
#MONEYTREE_SHARECODES ## 16、摇钱树
@@ -102,7 +98,6 @@ var_name=(
#ForOtherSgmh ## 11、闪购盲盒互助规则
#ForOtherCfd ## 12、京喜财富岛互助规则
ForOtherHealth ## 13、东东健康社区互助规则
ForOtherFruit_new ## 新农场小程序
#ForOtherCarni ## 14、京东手机狂欢城互助规则
#ForOtherCity ## 15、城城领现金互助规则
#ForOtherMoneyTree ## 16、摇钱树
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+137 -150
View File
@@ -4,160 +4,147 @@ const got = require('got');
require('dotenv').config();
const { readFile } = require('fs/promises');
const path = require('path');
const qlDir = '/ql';
const fs = require('fs');
const tokenFileList = ['/ql/data/db/keyv.sqlite', '/ql/data/config/auth.json', '/ql/config/auth.json'];
let authFile = getLatestFile(tokenFileList);
const HOSTS = ['http://127.0.0.1:5600','http://127.0.0.1:5700'];
function api(options){
const req = got.extend({prefixUrl: HOSTS[0],retry:{limit:0},timeout:{request:5000}})(options);
['json','text','buffer'].forEach(m=>{
const orig=req[m].bind(req);
req[m]=()=>orig().catch(e=>['ECONNREFUSED','ETIMEDOUT'].includes(e.code)?got.extend({prefixUrl:HOSTS[1],retry:{limit:0},timeout:{request:5000}})(options)[m]():Promise.reject(e));
});
return req;
}
function getLatestFile(files) {
let latestFile = null;
let latestMtime = 0;
for (const file of files) {
try {
const stats = fs.statSync(file);
const mtime = stats.mtimeMs;
if (mtime > latestMtime) {
latestMtime = mtime;
latestFile = file;
}
} catch (e) {
}
}
return latestFile;
}
let Fileexists = fs.existsSync('/ql/data/config/auth.json');
let authFile="";
if (Fileexists)
authFile="/ql/data/config/auth.json"
else
authFile="/ql/config/auth.json"
//const authFile = path.join(qlDir, 'config/auth.json');
const api = got.extend({
prefixUrl: 'http://127.0.0.1:5600',
retry: { limit: 0 },
});
async function getToken() {
const authConfig = await readFile(authFile);
// console.log(authConfig.toString().match(/"token":"(.*?)",/)[1])
return authConfig.toString().match(/"token":"([^"]*)"(?!.*"token":)/)[1];
const authConfig = JSON.parse(await readFile(authFile));
return authConfig.token;
}
// getToken()
module.exports.getEnvs = async () => {
const token = await getToken();
const body = await api({
url: 'api/envs',
searchParams: {
searchValue: 'JD_COOKIE',
t: Date.now(),
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
},
}).json();
return body.data;
module.exports.getEnvs = async () => {
const token = await getToken();
const body = await api({
url: 'api/envs',
searchParams: {
searchValue: 'JD_COOKIE',
t: Date.now(),
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
},
}).json();
return body.data;
};
module.exports.getEnvsCount = async () => {
const data = await this.getEnvs();
return data.length;
const data = await this.getEnvs();
return data.length;
};
module.exports.addEnv = async (cookie, remarks) => {
const token = await getToken();
const body = await api({
method: 'post',
url: 'api/envs',
params: { t: Date.now() },
json: [{
name: 'JD_COOKIE',
value: cookie,
remarks,
}],
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
const token = await getToken();
const body = await api({
method: 'post',
url: 'api/envs',
params: { t: Date.now() },
json: [{
name: 'JD_COOKIE',
value: cookie,
remarks,
}],
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.updateEnv = async (cookie, eid, remarks) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs',
params: { t: Date.now() },
json: {
name: 'JD_COOKIE',
value: cookie,
_id: eid,
remarks,
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs',
params: { t: Date.now() },
json: {
name: 'JD_COOKIE',
value: cookie,
_id: eid,
remarks,
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.updateEnv11 = async (cookie, eid, remarks) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs',
params: { t: Date.now() },
json: {
name: 'JD_COOKIE',
value: cookie,
id: eid,
remarks,
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs',
params: { t: Date.now() },
json: {
name: 'JD_COOKIE',
value: cookie,
id: eid,
remarks,
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.DisableCk = async (eid) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs/disable',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs/disable',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.EnableCk = async (eid) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs/enable',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs/enable',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.getstatus = async (eid) => {
module.exports.getstatus = async(eid) => {
const envs = await this.getEnvs();
var tempid = 0;
for (let i = 0; i < envs.length; i++) {
tempid = 0;
tempid = 0;
if (envs[i]._id) {
tempid = envs[i]._id;
}
@@ -171,7 +158,7 @@ module.exports.getstatus = async (eid) => {
return 99;
};
module.exports.getEnvById = async (eid) => {
module.exports.getEnvById = async(eid) => {
const envs = await this.getEnvs();
var tempid = 0;
for (let i = 0; i < envs.length; i++) {
@@ -190,28 +177,28 @@ module.exports.getEnvById = async (eid) => {
};
module.exports.getEnvByPtPin = async (Ptpin) => {
const envs = await this.getEnvs();
for (let i = 0; i < envs.length; i++) {
var tempptpin = decodeURIComponent(envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/) && envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
if (tempptpin == Ptpin) {
return envs[i];
}
}
return "";
const envs = await this.getEnvs();
for (let i = 0; i < envs.length; i++) {
var tempptpin = decodeURIComponent(envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/) && envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
if(tempptpin==Ptpin){
return envs[i];
}
}
return "";
};
module.exports.delEnv = async (eid) => {
const token = await getToken();
const body = await api({
method: 'delete',
url: 'api/envs',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
const token = await getToken();
const body = await api({
method: 'delete',
url: 'api/envs',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
+152 -188
View File
@@ -3,27 +3,27 @@
*/
//此处填写京东账号cookie。
let CookieJDs = [
'',//账号一ck,例:pt_key=XXX;pt_pin=XXX;
'',//账号二ck,例:pt_key=XXX;pt_pin=XXX;如有更多,依次类推
'',//账号一ck,例:pt_key=XXX;pt_pin=XXX;
'',//账号二ck,例:pt_key=XXX;pt_pin=XXX;如有更多,依次类推
]
let IP = '';
// 判断环境变量里面是否有京东ck
if (process.env.JD_COOKIE) {
if (process.env.JD_COOKIE.indexOf('&') > -1) {
CookieJDs = process.env.JD_COOKIE.split('&');
} else if (process.env.JD_COOKIE.indexOf('\n') > -1) {
CookieJDs = process.env.JD_COOKIE.split('\n');
} else {
CookieJDs = [process.env.JD_COOKIE];
}
if (process.env.JD_COOKIE.indexOf('&') > -1) {
CookieJDs = process.env.JD_COOKIE.split('&');
} else if (process.env.JD_COOKIE.indexOf('\n') > -1) {
CookieJDs = process.env.JD_COOKIE.split('\n');
} else {
CookieJDs = [process.env.JD_COOKIE];
}
}
if (JSON.stringify(process.env).indexOf('GITHUB') > -1) {
console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`);
!(async () => {
await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`)
await process.exit(0);
})()
}
//if (JSON.stringify(process.env).indexOf('GITHUB') > -1) {
// console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`);
// !(async () => {
// await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`)
// await process.exit(0);
// })()
//}
//!(async () => {
// IP = await getIP();
// try {
@@ -34,207 +34,171 @@ if (process.env.JD_COOKIE) {
CookieJDs = [...new Set(CookieJDs.filter(item => !!item))]
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { };
if (process.env.BANPIN) {
try {
let banpin = process.env.BANPIN;
if (banpin.includes('@')) {
const arr = banpin.split('&');
for (let i of arr) {
//if (process.mainModule.filename.includes(i.split('^')[0])) {
if (i.split('@')[0].split('|').filter(x => process.argv[1].includes(x)).length != 0) {
let pinarr = i.split('@')[1].split(',');
console.log(`\n已配置该任务不执行pin: ${JSON.stringify(pinarr)}`);
for (let j of pinarr) {
j = decodeURIComponent(j);
CookieJDs = CookieJDs.filter(x => !x.includes(encodeURIComponent(j)));
}
try {
let banpin = process.env.BANPIN;
if (banpin.includes('@')) {
const arr = banpin.split('&');
for (let i of arr) {
//if (process.mainModule.filename.includes(i.split('^')[0])) {
if (i.split('@')[0].split('|').filter(x => process.argv[1].includes(x)).length != 0) {
let pinarr = i.split('@')[1].split(',');
console.log(`已配置该任务不执行pin: ${JSON.stringify(pinarr)}`);
for (let j of pinarr) {
CookieJDs = CookieJDs.filter(x => !x.includes(encodeURIComponent(j)));
}
}
}
} else {
let pinarr = banpin.split(',');
console.log(`\n❗已配置全部任务不执行pin: ${JSON.stringify(pinarr)}`);
for (let i of pinarr) {
i = decodeURIComponent(i);
CookieJDs = CookieJDs.filter(x => !x.includes(encodeURIComponent(i)));
}
}
} catch { }
}
if (process.env.ALLOWPIN) {
try {
const pin = process.env.ALLOWPIN;
const runck = [];
if (pin.includes('@')) {
const arr = pin.split('&');
}
for (let i of arr) {
//if (process.mainModule.filename.includes(i.split('^')[0])) {
if (i.split('@')[0].split('|').filter(x => process.argv[1].includes(x)).length != 0) {
let pinarr = i.split('@')[1].split(',');
console.log(`\n❗已配置该任务只执行pin: ${JSON.stringify(pinarr)}`);
for (let j of pinarr) {
j = decodeURIComponent(j);
runck.push(...CookieJDs.filter(x => x.includes(encodeURIComponent(j))));
}
}
}
} else {
let pinarr = pin.split(',');
console.log(`\n❗已配置全部任务只执行pin: ${JSON.stringify(pinarr)}`);
for (let i of pinarr) {
i = decodeURIComponent(i);
runck.push(...CookieJDs.filter(x => x.includes(encodeURIComponent(i))));
}
}
if (runck.length > 0) {
CookieJDs = runck
}
} catch { }
} else {
let pinarr = banpin.split(',');
console.log(`已配置全局不执行pin: ${JSON.stringify(pinarr)}`);
for (let i of pinarr) {
CookieJDs = CookieJDs.filter(x => !x.includes(encodeURIComponent(i)));
}
}
} catch { }
}
console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=================`);
console.log(`===========脚本执行时间:${formatdate(new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000))}============`);
console.log('>>>>>>>>>>>>6dylan6提醒您:有问题先更新不行在反馈>>>>>>>>>>>>>\n');
console.log(`Tips:‼️青龙2.20.2以下版本不要外网访问,已被爆破可任意登录!必须要外网的就全新安装新版吧,升级不行\n`);
console.log('>>>>>>>>>>>>6Dy提醒您:有问题先更新不行在反馈>>>>>>>>>>>>>\n');
for (let i = 0; i < CookieJDs.length; i++) {
if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`);
CookieJDs[i] = CookieJDs[i].replace(/[\u4e00-\u9fa5]/g, (str) => encodeURI(str));
const index = (i + 1 === 1) ? '' : (i + 1);
exports['CookieJD' + index] = CookieJDs[i].trim();
if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`);
CookieJDs[i] = CookieJDs[i].replace(/[\u4e00-\u9fa5]/g, (str) => encodeURI(str));
const index = (i + 1 === 1) ? '' : (i + 1);
exports['CookieJD' + index] = CookieJDs[i].trim();
}
let permit = process.env.PERMIT_JS ? process.env.PERMIT_JS.split('&') : '';
if (process.env.DP_POOL) {
if (permit && permit.filter(x => process.mainModule.filename.includes(x)).length != 0) {
try {
require("global-agent/bootstrap");
global.GLOBAL_AGENT.HTTP_PROXY = process.env.DP_POOL;
global.GLOBAL_AGENT.NO_PROXY = process.env.NO_PROXY || '127.0.0.1,localhost';
console.log(`\n---------------使用代理池模式---------------\n`);
} catch {
throw new Error(`请安装global-agent依赖,才能启用代理!`);
}
} else {
if (permit && permit.filter(x => process.mainModule.filename.includes(x)).length != 0) {
try {
require("global-agent/bootstrap");
global.GLOBAL_AGENT.HTTP_PROXY = process.env.DP_POOL;
console.log(`\n---------------使用代理池模式---------------\n`);
} catch {
throw new Error(`请安装global-agent依赖,才能启用代理!`);
}
} else {
}
}
function getIP() {
const https = require('https');
return new Promise((resolve, reject) => {
let opt = {
hostname: "www.cip.cc",
port: 443,
path: "/",
method: "GET",
headers: {
"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36',
},
timeout: 5000
}
const req = https.request(opt, (res) => {
res.setEncoding('utf-8');
let tmp = '';
res.on('error', reject);
res.on('data', d => tmp += d);
res.on('end', () => resolve(tmp));
});
req.on('error', reject);
req.end();
const https = require('https');
return new Promise((resolve, reject) => {
let opt = {
hostname: "www.cip.cc",
port: 443,
path: "/",
method: "GET",
headers: {
"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36',
},
timeout: 5000
}
const req = https.request(opt, (res) => {
res.setEncoding('utf-8');
let tmp = '';
res.on('error', reject);
res.on('data', d => tmp += d);
res.on('end', () => resolve(tmp));
});
req.on('error', reject);
req.end();
});
}
// 以下为注入互助码环境变量(仅nodejs内起效)的代码
function SetShareCodesEnv(nameChinese = "", nameConfig = "", envName = "") {
let rawCodeConfig = {}
let fs = require('fs')
// 读取互助码
let shareCodeLogPath = fs.existsSync(`${process.env.QL_DIR}/data`) ? `${process.env.QL_DIR}/data/log/.ShareCode/${nameConfig}.log` : `${process.env.QL_DIR}/log/.ShareCode/${nameConfig}.log`;
if (fs.existsSync(shareCodeLogPath)) {
// 因为faker2目前没有自带ini,改用已有的dotenv来解析
// // 利用ini模块读取原始互助码和互助组信息
// let ini = require('ini')
// rawCodeConfig = ini.parse(fs.readFileSync(shareCodeLogPath, 'utf-8'))
let rawCodeConfig = {}
let fs = require('fs')
// 读取互助码
let shareCodeLogPath = fs.existsSync(`${process.env.QL_DIR}/data`) ? `${process.env.QL_DIR}/data/log/.ShareCode/${nameConfig}.log` : `${process.env.QL_DIR}/log/.ShareCode/${nameConfig}.log`;
if (fs.existsSync(shareCodeLogPath)) {
// 因为faker2目前没有自带ini,改用已有的dotenv来解析
// // 利用ini模块读取原始互助码和互助组信息
// let ini = require('ini')
// rawCodeConfig = ini.parse(fs.readFileSync(shareCodeLogPath, 'utf-8'))
// 使用env模块
require('dotenv').config({ path: shareCodeLogPath })
rawCodeConfig = process.env
// 使用env模块
require('dotenv').config({ path: shareCodeLogPath })
rawCodeConfig = process.env
}
// 解析每个用户的互助码
let codes = {}
Object.keys(rawCodeConfig).forEach(function (key) {
if (key.startsWith(`My${nameConfig}`)) {
codes[key] = rawCodeConfig[key]
}
});
// 解析每个用户的互助码
let codes = {}
Object.keys(rawCodeConfig).forEach(function (key) {
if (key.startsWith(`My${nameConfig}`)) {
codes[key] = rawCodeConfig[key]
}
});
// 解析每个用户要帮助的互助码组,将用户实际的互助码填充进去
let helpOtherCodes = {}
Object.keys(rawCodeConfig).forEach(function (key) {
if (key.startsWith(`ForOther${nameConfig}`)) {
let helpCode = rawCodeConfig[key]
for (const [codeEnv, codeVal] of Object.entries(codes)) {
helpCode = helpCode.replace("${" + codeEnv + "}", codeVal)
}
// 解析每个用户要帮助的互助码组,将用户实际的互助码填充进去
let helpOtherCodes = {}
Object.keys(rawCodeConfig).forEach(function (key) {
if (key.startsWith(`ForOther${nameConfig}`)) {
let helpCode = rawCodeConfig[key]
for (const [codeEnv, codeVal] of Object.entries(codes)) {
helpCode = helpCode.replace("${" + codeEnv + "}", codeVal)
}
helpOtherCodes[key] = helpCode
}
});
// 按顺序用&拼凑到一起,并放入环境变量,供目标脚本使用
let shareCodes = []
let leftIndex = 1, rightIndex = Object.keys(helpOtherCodes).length
// 判断是否是ptask并行触发,若是,则修改实际需要设置的互助码范围
let ptaskLeft = process.env.PTASK_LEFT
let ptaskRight = process.env.PTASK_RIGHT
if (ptaskLeft && ptaskRight) {
leftIndex = Number(ptaskLeft)
rightIndex = Number(ptaskRight)
helpOtherCodes[key] = helpCode
}
});
for (let idx = leftIndex; idx <= rightIndex; idx++) {
shareCodes.push(helpOtherCodes[`ForOther${nameConfig}${idx}`])
}
let shareCodesStr = shareCodes.join('&')
process.env[envName] = shareCodesStr
// 按顺序用&拼凑到一起,并放入环境变量,供目标脚本使用
let shareCodes = []
let leftIndex = 1, rightIndex = Object.keys(helpOtherCodes).length
let totalCodeCount = rightIndex - leftIndex + 1
//console.info(`${nameChinese}的 互助码环境变量 ${envName},共计 ${totalCodeCount} 组互助码,总大小为 ${shareCodesStr.length} 字节`)
// 判断是否是ptask并行触发,若是,则修改实际需要设置的互助码范围
let ptaskLeft = process.env.PTASK_LEFT
let ptaskRight = process.env.PTASK_RIGHT
if (ptaskLeft && ptaskRight) {
leftIndex = Number(ptaskLeft)
rightIndex = Number(ptaskRight)
}
for (let idx = leftIndex; idx <= rightIndex; idx++) {
shareCodes.push(helpOtherCodes[`ForOther${nameConfig}${idx}`])
}
let shareCodesStr = shareCodes.join('&')
process.env[envName] = shareCodesStr
let totalCodeCount = rightIndex - leftIndex + 1
//console.info(`${nameChinese}的 互助码环境变量 ${envName},共计 ${totalCodeCount} 组互助码,总大小为 ${shareCodesStr.length} 字节`)
}
// 判断当前活动脚本是否在互助脚本列表中
function IsShareJsFile() {
// 尝试获取在task_before.sh中设置的 互助活动的脚本文件名的关键部分 列表
let rawJsNameList = process.env.ShareCodeJSNameList
if (!rawJsNameList) {
return false
// 尝试获取在task_before.sh中设置的 互助活动的脚本文件名的关键部分 列表
let rawJsNameList = process.env.ShareCodeJSNameList
if (!rawJsNameList) {
return false
}
// 转换为list
let jsNameList = process.env.ShareCodeJSNameList.split(" ")
// 判断当前
let currentActivityScriptFileName = GetCurrentActivityScriptFileName()
let isShareJsFile = false
for (let idx = 0; idx < jsNameList.length; idx++) {
if (currentActivityScriptFileName.includes(jsNameList[idx])) {
isShareJsFile = true
break
}
}
// 转换为list
let jsNameList = process.env.ShareCodeJSNameList.split(" ")
// 判断当前
let currentActivityScriptFileName = GetCurrentActivityScriptFileName()
let isShareJsFile = false
for (let idx = 0; idx < jsNameList.length; idx++) {
if (currentActivityScriptFileName.includes(jsNameList[idx])) {
isShareJsFile = true
break
}
}
return isShareJsFile
return isShareJsFile
}
// 获取当前活动脚本的文件名
function GetCurrentActivityScriptFileName() {
const path = require('path')
return path.basename(process.argv[1])
const path = require('path')
return path.basename(process.argv[1])
}
// 若在task_before.sh 中设置了要设置互助码环境变量的活动名称和环境变量名称信息,则在nodejs中处理,供活动使用
@@ -242,14 +206,14 @@ let nameChinese = process.env.ShareCodeConfigChineseName
let nameConfig = process.env.ShareCodeConfigName
let envName = process.env.ShareCodeEnvName
if (nameChinese && nameConfig && envName) {
SetShareCodesEnv(nameChinese, nameConfig, envName)
SetShareCodesEnv(nameChinese, nameConfig, envName)
}
function formatdate(date) {
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
const hours = ('0' + date.getHours()).slice(-2);
const minutes = ('0' + date.getMinutes()).slice(-2);
const seconds = ('0' + date.getSeconds()).slice(-2);
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
const hours = ('0' + date.getHours()).slice(-2);
const minutes = ('0' + date.getMinutes()).slice(-2);
const seconds = ('0' + date.getSeconds()).slice(-2);
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
}
+1 -2
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+2682 -3
View File
File diff suppressed because one or more lines are too long
+766 -4
View File
File diff suppressed because one or more lines are too long
+1 -4
View File
@@ -114,10 +114,7 @@ async function bean() {
}
}
} else {
// 完全无数据时才抛出异常,否则返回之前统计出来的数据
if (!todayArr.length && !yesterdayArr.length) {
$.errorMsg = `数据异常`;
}
$.errorMsg = `数据异常`;
// $.msg($.name, ``, `账号${$.index}${$.nickName}\n${$.errorMsg}`);
t = 1;
}
-7
View File
File diff suppressed because one or more lines are too long
+1 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+7
View File
File diff suppressed because one or more lines are too long
-6
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+207
View File
File diff suppressed because one or more lines are too long
+1 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+12
View File
File diff suppressed because one or more lines are too long
+12
View File
File diff suppressed because one or more lines are too long
+12
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+18 -1
View File
File diff suppressed because one or more lines are too long
+6 -4
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+20
View File
File diff suppressed because one or more lines are too long
+11
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5 -3
View File
File diff suppressed because one or more lines are too long
+10 -3
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+18
View File
File diff suppressed because one or more lines are too long
+2 -3
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10
View File
File diff suppressed because one or more lines are too long
+10
View File
File diff suppressed because one or more lines are too long
+7
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
-8
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
#依赖安装,运行一次就好
#0 8 5 5 * jd_indeps.sh
#new Env('依赖安装');
#
npm_ver=`pnpm -v|awk -F. '{print $1}'`
if [[ $npm_ver -ge 7 ]];then
export PNPM_HOME="/root/.local/share/pnpm"
export PATH="$PNPM_HOME:$PATH"
fi
echo -e "安装脚本所需依赖,不一定一次全部安装成功,请自己检查\n"
echo -e "开始安装............\n"
#apk add g++ make pixman-dev pango-dev cairo-dev pkgconf --no-cache
#apk add g++ make --no-cache
pnpm config set registry https://registry.npmmirror.com
pnpm install -g
pnpm install -g ds
pnpm install -g png-js
pnpm install -g date-fns
pnpm install -g axios
pnpm install -g crypto-js
pnpm install -g ts-md5
pnpm install -g tslib
pnpm install -g @types/node
pnpm install -g request
pnpm install -g jsdom
pnpm install -g moment
pnpm install -g cheerio
pnpm install -g tough-cookie
pnpm install -g https-proxy-agent
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ jieba
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ requests
rm -rf /usr/local/pnpm-global/5/node_modules/.pnpm/canvas*
rm -rf /root/.local/share/pnpm/global/5/.pnpm/canvas*
echo -e "\n所需依赖安装完成,请检查有没有报错,可尝试再次运行"
+328
View File
File diff suppressed because one or more lines are too long
+14
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+9
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+213
View File
File diff suppressed because one or more lines are too long
+179
View File
@@ -0,0 +1,179 @@
/*
京东快递
@Leaf
*/
const $ = new Env('京东快递');
const got = require('got');
const envSplitor = ['&','\n','@']
const ckNames = ['JD_COOKIE']
const MAX_THREAD = parseInt(process.env['jd_jdkd_thread']) || 5
const DEFAULT_TIMEOUT=8000, DEFAULT_RETRY=3;
const default_UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.31(0x18001f2f) NetType/WIFI Language/zh_CN miniProgram/wx73247c7819d61796'
const Referer = 'https://jingcai-h5.jd.com/'
const Origin = 'https://jingcai-h5.jd.com'
const client = got.extend({
headers:{
Connection:'keep-alive',
'User-Agent': default_UA,
Referer,
Origin,
AppParams: JSON.stringify({"appid":158,"ticket_type":"m"}),
ClientInfo: JSON.stringify({"appName":"jingcai","client":"m"}),
'LOP-DN': 'jingcai.jd.com',
'X-Requested-With': 'XMLHttpRequest',
},
retry: {limit:0},
timeout: DEFAULT_TIMEOUT,
followRedirect: false,
})
class BasicClass{constructor(){this.index=$.userIdx++;this.name='';} log(msg,opt={}){var m='',n=$.userCount.toString().length;;if(this.index)m+=`账号[${$.padStr(this.index,n)}]`;if(this.name)m+=`[${this.name}]`;$.log(m+msg,opt);} async request(opt){var resp=null,count=0;var fn=opt.fn||opt.url;opt.method=opt?.method?.toUpperCase()||'GET';while(count++<DEFAULT_RETRY){try{await client(opt).then(t=>{resp=t},e=>{resp=e.response});if(((resp?.statusCode/100)|0)<=4)break;}catch(e){if(e.name=='TimeoutError'){this.log(`[${fn}]请求超时,重试第${count}`);}else{this.log(`[${fn}]请求错误(${e.message}),重试第${count}`);}};} if(resp==null)return Promise.resolve({statusCode:-1,headers:null,result:null});let{statusCode,headers,body}=resp;if(body)try{body=JSON.parse(body);}catch{};return Promise.resolve({statusCode,headers,result:body})}}
let http = new BasicClass();
class UserClass extends BasicClass {
constructor(ck) {
super()
this.cookie = ck
this.pt_pin = ck.match(/pin=([\w\-\%]+)/) ? ck.match(/pin=([\w\-\%]+)/)[1] : ''
this.name = decodeURIComponent(this.pt_pin)
}
async queryTaskList() {
try {
let options = {
fn: 'queryTaskList',
method: 'post',
url: 'https://lop-proxy.jd.com/ESGApi/queryTaskList',
headers: {Cookie:this.cookie,'event-id':$.randomPattern('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx')},
json: [{"pin":"$cooMrdGatewayUid$"}],
}
let {result} = await this.request(options)
let code = result?.code
if(code == 1) {
//console.log(JSON.stringify(result?.content?.taskInfoList))
for(let task of (result?.content?.taskInfoList||[]).filter(x => x.taskReachNum < x.taskNeedReachNum && x.triggerType==1 && !x.taskTitle.includes('加购'))) {
await this.reachTaskInfo(task);
await $.wait(1000);
break;
}
} else {
let errCode = code || result?.error_response?.code
let errMsg = result?.msg || result?.error_response?.zh_desc
this.log(`查询任务列表出错[${errCode}]: ${errMsg}`)
}
} catch (e) {
$.log(e)
} finally {
return Promise.resolve()
}
}
async reachTaskInfo(task) {
try {
let options = {
fn: 'reachTaskInfo',
method: 'post',
url: 'https://lop-proxy.jd.com/ESGApi/reachTaskInfo',
headers: {Cookie:this.cookie,'event-id':$.randomPattern('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx')},
json: [{
taskNo: task.taskNo,
childTaskId: task.childTaskId,
pin: "$cooMrdGatewayUid$",
}],
}
let {result} = await this.request(options)
let code = result?.code
if(code == 1) {
this.log(`完成任务[${task.taskTitle}]成功`);
await $.wait(1000);
await this.queryTaskList();
} else {
let errCode = code || result?.error_response?.code
let errMsg = result?.msg || result?.error_response?.zh_desc
this.log(`完成任务[${task.taskTitle}]失败[${errCode}]: ${errMsg}`)
}
} catch (e) {
$.log(e)
} finally {
return Promise.resolve()
}
}
async queryCanGetRewardTaskList() {
try {
let options = {
fn: 'queryCanGetRewardTaskList',
method: 'post',
url: 'https://lop-proxy.jd.com/ESGApi/queryCanGetRewardTaskList',
headers: {Cookie:this.cookie,'event-id':$.randomPattern('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx')},
json: [{"pin":"$cooMrdGatewayUid$"}],
}
let {result} = await this.request(options)
let code = result?.code
if(code == 1) {
for(let item of (result?.content?.personalCarbonRewardRespDtoList||[])) {
await this.operationPersonalCarbonIntegral(item)
}
} else {
let errCode = code || result?.error_response?.code
let errMsg = result?.msg || result?.error_response?.zh_desc
this.log(`查询可领取奖励出错[${errCode}]: ${errMsg}`)
}
} catch (e) {
$.log(e)
} finally {
return Promise.resolve()
}
}
async operationPersonalCarbonIntegral(item) {
try {
let options = {
fn: 'operationPersonalCarbonIntegral',
method: 'post',
url: 'https://lop-proxy.jd.com/ESGApi/operationPersonalCarbonIntegral',
headers: {Cookie:this.cookie,'event-id':$.randomPattern('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx')},
json: [{
type: 2,
operationType: 1,
rewardNo: item.rewardNo,
taskNo: item.taskNo,
pin: "$cooMrdGatewayUid$",
}],
}
let {result} = await this.request(options)
let code = result?.code
if(code == 1) {
this.log(`收取[${item.taskTitle}]奖励成功, 现在有${result?.content?.carbonIntegral}g能量`)
} else {
let errCode = code || result?.error_response?.code
let errMsg = result?.msg || result?.error_response?.zh_desc
this.log(`收取[${item.taskTitle}]奖励失败[${errCode}]: ${errMsg}`)
}
} catch (e) {
$.log(e)
} finally {
return Promise.resolve()
}
}
async userTask() {
await this.queryTaskList();
await this.queryCanGetRewardTaskList();
}
}
!(async () => {
$.read_env(UserClass);
await $.threadTask('userTask',MAX_THREAD)
})()
.catch((e) => $.log(e))
.finally(() => $.exitNow())
function Env(name){return new class{constructor(name){this.name=name;this.startTime=Date.now();this.log(`[${this.name}]开始运行\n`,{time:true});this.notifyStr=[];this.notifyFlag=true;this.userIdx=0;this.userList=[];this.userCount=0;} log(msg,options={}){let opt={console:true};Object.assign(opt,options);if(opt.time){let fmt=opt.fmt||'hh:mm:ss';msg=`[${this.time(fmt)}]`+msg;} if(opt.notify)this.notifyStr.push(msg);if(opt.console)console.log(msg);} read_env(Class){let envStrList=ckNames.map(x=>process.env[x]);for(let env_str of envStrList.filter(x=>!!x)){let sp=envSplitor.filter(x=>env_str.includes(x));let splitor=sp.length>0?sp[0]:envSplitor[0];for(let ck of env_str.split(splitor).filter(x=>!!x)){this.userList.push(new Class(ck));}} this.userCount=this.userList.length;if(!this.userCount){this.log(`未找到变量,请检查变量${ckNames.map(x => '['+x+']').join('或')}`,{notify:true});return false;} this.log(`共找到${this.userCount}个账号`);return true;} async threads(taskName,conf,opt={}){while(conf.idx<$.userList.length){let user=$.userList[conf.idx++];await user[taskName](opt);}} async threadTask(taskName,thread){let taskAll=[];let taskConf={idx:0};while(thread--)taskAll.push(this.threads(taskName,taskConf));await Promise.all(taskAll);} time(t,x=null){let xt=x?new Date(x):new Date;let e={"M+":xt.getMonth()+1,"d+":xt.getDate(),"h+":xt.getHours(),"m+":xt.getMinutes(),"s+":xt.getSeconds(),"q+":Math.floor((xt.getMonth()+3)/3),S:this.padStr(xt.getMilliseconds(),3)};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(xt.getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t;} async showmsg(){if(!this.notifyFlag)return;if(!this.notifyStr.length)return;var notify=require('./sendNotify');this.log('\n============== 推送 ==============');await notify.sendNotify(this.name,this.notifyStr.join('\n'));} padStr(num,length,opt={}){let padding=opt.padding||'0';let mode=opt.mode||'l';let numStr=String(num);let numPad=(length>numStr.length)?(length-numStr.length):0;let pads='';for(let i=0;i<numPad;i++){pads+=padding;} if(mode=='r'){numStr=numStr+pads;}else{numStr=pads+numStr;} return numStr;} json2str(obj,c,encode=false){let ret=[];for(let keys of Object.keys(obj).sort()){let v=obj[keys];if(v&&encode)v=encodeURIComponent(v);ret.push(keys+'='+v);} return ret.join(c);} str2json(str,decode=false){let ret={};for(let item of str.split('&')){if(!item)continue;let idx=item.indexOf('=');if(idx==-1)continue;let k=item.substr(0,idx);let v=item.substr(idx+1);if(decode)v=decodeURIComponent(v);ret[k]=v;} return ret;} randomPattern(pattern,charset='abcdef0123456789'){let str='';for(let chars of pattern){if(chars=='x'){str+=charset.charAt(Math.floor(Math.random()*charset.length));}else if(chars=='X'){str+=charset.charAt(Math.floor(Math.random()*charset.length)).toUpperCase();}else{str+=chars;}} return str;} randomString(len,charset='abcdef0123456789'){let str='';for(let i=0;i<len;i++){str+=charset.charAt(Math.floor(Math.random()*charset.length));} return str;} randomList(a){let idx=Math.floor(Math.random()*a.length);return a[idx];} wait(t){return new Promise(e=>setTimeout(e,t));} async exitNow(){await this.showmsg();let e=Date.now();let s=(e-this.startTime)/1000;this.log('');this.log(`[${this.name}]运行结束,共运行了${s}`,{time:true});process.exit(0);}} (name)}
+22
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
-6
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+2 -3
View File
File diff suppressed because one or more lines are too long
+7
View File
File diff suppressed because one or more lines are too long
-13
View File
File diff suppressed because one or more lines are too long
-6
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
-6
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+216
View File
File diff suppressed because one or more lines are too long
-6
View File
File diff suppressed because one or more lines are too long
+4 -4
View File
File diff suppressed because one or more lines are too long
+3 -3
View File
File diff suppressed because one or more lines are too long
+8
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+19
View File
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More