Skip to content

Commit

Permalink
修改程序结构,新增一次性运行脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsongsu committed Jan 14, 2024
1 parent 38520da commit ad23e2f
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 23 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.DS_Store
node_modules
node_modules
config/runner.json
4 changes: 2 additions & 2 deletions config/runner.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"bscrpc": "https://rpc.ankr.com/bsc",
"opbnb": "https://1rpc.io/opbnb",
"walletPath": "/Users/admin/Desktop/testwallet/wallet.csv",
"proxy": " ",
"maxGasPrice": 30,
"proxy": "http://9xmb93yh:[email protected]:31112",
"maxGasPrice": 50,
"minInterval": 10,
"maxInterval": 120
}
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"child_process": "^1.0.2",
"csv-parser": "^3.0.0",
"csv-writer": "^1.6.0",
"ethers": "^5.7.2",
Expand Down
File renamed without changes.
15 changes: 10 additions & 5 deletions qna3/qna3.js → src/qna3/qna3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const csv = require('csv-parser');
const readlineSync = require('readline-sync');
const axios = require('axios');
const config = require('../config/runner.json');
const config = require('../../config/runner.json');
const fakeUa = require('fake-useragent');
const contractAddress = '0xb342e7d33b806544609370271a8d074313b7bc30';
const contractABI = require('./ABI/qna3.json');
Expand All @@ -27,10 +27,15 @@ const headers = {
};

function getKeyFromUser() {
const key = readlineSync.question('请输入你的密码: ', {
hideEchoBack: true, // 密钥不回显
});
return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); // 使用SHA-256生成密钥
let key;
if (process.env.SCRIPT_PASSWORD) {
key = process.env.SCRIPT_PASSWORD;
} else {
key = readlineSync.question('请输入你的密码: ', {
hideEchoBack: true,
});
}
return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32);
}

function decrypt(text, secretKey) {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion robots/claimRaffle.js → src/robots/claimRaffle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require('axios');
const fs = require('fs');
const csv = require('csv-parser');
const config = require('../config/runner.json');
const config = require('../../config/runner.json');
const { HttpsProxyAgent } = require('https-proxy-agent');
const agent = new HttpsProxyAgent(config.proxy);
const fakeUa = require('fake-useragent');
Expand Down
15 changes: 10 additions & 5 deletions robots/getTicket.js → src/robots/getTicket.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const crypto = require('crypto');
const fs = require('fs');
const csv = require('csv-parser');
const readlineSync = require('readline-sync');
const config = require('../config/runner.json');
const config = require('../../config/runner.json');
const contractAddress = '0xC91AAacC5adB9763CEB57488CC9ebE52C76A2b05';
const contractABI = require('./ABI/abi.json');

Expand All @@ -12,10 +12,15 @@ const ethereumProvider = new ethers.providers.JsonRpcProvider(config.ethrpc);
const contractTemplate = new ethers.Contract(contractAddress, contractABI);

function getKeyFromUser() {
const key = readlineSync.question('请输入你的密码: ', {
hideEchoBack: true, // 密钥不回显
});
return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); // 使用SHA-256生成密钥
let key;
if (process.env.SCRIPT_PASSWORD) {
key = process.env.SCRIPT_PASSWORD;
} else {
key = readlineSync.question('请输入你的密码: ', {
hideEchoBack: true,
});
}
return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32);
}

function decrypt(text, secretKey) {
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 10 additions & 4 deletions web3go/reikiTask.js → src/web3go/reikiTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ const fs = require('fs');
const csv = require('csv-parser');
const readlineSync = require('readline-sync');
const axios = require('axios');
const config = require('../config/runner.json');
const config = require('../../config/runner.json');
const fakeUa = require('fake-useragent');
const { HttpsProxyAgent } = require('https-proxy-agent');

const agent = new HttpsProxyAgent(config.proxy);

function getKeyFromUser() {
const key = readlineSync.question('请输入你的密码: ', {
hideEchoBack: true,
});
let key;
if (process.env.SCRIPT_PASSWORD) {
key = process.env.SCRIPT_PASSWORD;
} else {
key = readlineSync.question('请输入你的密码: ', {
hideEchoBack: true,
});
}
return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32);
}


function decrypt(text, secretKey) {
let parts = text.split(':');
let iv = Buffer.from(parts.shift(), 'hex');
Expand Down
15 changes: 10 additions & 5 deletions web3go/web3goMint.js → src/web3go/web3goMint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ const crypto = require('crypto');
const fs = require('fs');
const csv = require('csv-parser');
const readlineSync = require('readline-sync');
const config = require('../config/runner.json');
const config = require('../../config/runner.json');
const contractAddress = '0xa4Aff9170C34c0e38Fed74409F5742617d9E80dc';
const contractABI = require('./ABI/reiki.json');

const provider = new ethers.providers.JsonRpcProvider(config.bscrpc);
const contractTemplate = new ethers.Contract(contractAddress, contractABI);

function getKeyFromUser() {
const key = readlineSync.question('请输入你的密码: ', {
hideEchoBack: true, // 密钥不回显
});
return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32); // 使用SHA-256生成密钥
let key;
if (process.env.SCRIPT_PASSWORD) {
key = process.env.SCRIPT_PASSWORD;
} else {
key = readlineSync.question('请输入你的密码: ', {
hideEchoBack: true,
});
}
return crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32);
}

function decrypt(text, secretKey) {
Expand Down
37 changes: 37 additions & 0 deletions taskRunner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { spawn } = require('child_process');
const readlineSync = require('readline-sync');
const path = require('path');

// 脚本路径列表
const scripts = [
'./src/web3go/reikiTask.js',
'./src/web3go/web3goMint.js',
'./src/robots/getTicket.js',
'./src/robots/claimRaffle.js',
];

const password = readlineSync.question('请输入密码: ', {
hideEchoBack: true // 密码输入时不显示字符
});

runScript(0);

function runScript(index) {
if (index < scripts.length) {
const scriptName = path.basename(scripts[index], '.js');
console.log(`开始执行脚本: ${scriptName}`);

const childProcess = spawn('node', [scripts[index]], {
env: { ...process.env, SCRIPT_PASSWORD: password },
stdio: 'inherit'
});

childProcess.on('close', (code) => {
console.log(`脚本 ${scriptName} 执行完成,退出码 ${code}`);
if (index + 1 < scripts.length) {
console.log(`脚本 ${scriptName} 执行完成,开始执行脚本 ${path.basename(scripts[index + 1], '.js')}`);
}
runScript(index + 1);
});
}
}

0 comments on commit ad23e2f

Please sign in to comment.