feat: 推送中奖检测可添加账号备注(#121)

详见env.example.js
This commit is contained in:
shanmite 2022-02-07 15:05:10 +08:00
parent b80c65558d
commit 3f59076d83
3 changed files with 16 additions and 4 deletions

View File

@ -2,6 +2,7 @@ module.exports = Object.freeze({
/**
* ## 账号相关
* - `COOKIE` 是必填项
* - `NOTE` 帐号备注
* - `NUMBER` 表示是第几个账号
* - `CLEAR` 是否启用清理功能
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
@ -18,6 +19,7 @@ module.exports = Object.freeze({
*/
account_parm: {
COOKIE: "",
NOTE: "",
NUMBER: 1,
CLEAR: true,
@ -31,10 +33,17 @@ module.exports = Object.freeze({
/**
* 为防止环境变量过长, 请将多账号填在此处
* 以大括号内容为模板依次复制(包含大括号),逗号分割
* ```
* ...
* NUMBER: 1
* ...
* NUMBER: 2
* ```
*/
multiple_account_parm: [
{
COOKIE: "",
NOTE: "",
NUMBER: 1,
CLEAR: true,
WAIT: 60 * 1000

View File

@ -7,8 +7,9 @@ const bili = require('./net/bili')
/**
* 是否中奖
* @param {number} num
* @param {string} [note]
*/
async function isMe(num) {
async function isMe(num, note = "无") {
let desp = '';
const
{ notice_key_words, update_session_wait, get_session_wait, check_session_pages } = config,
@ -93,7 +94,8 @@ async function isMe(num) {
log.info('中奖检测', '--> OK');
}
if (desp) {
desp += '中奖了别忘给脚本(https://github.com/shanmiteko/LotteryAutoScript)点一个Star哦, 赞助一两块也不是不可以_(:з」∠)_\n\n'
desp += `帐号备注: ${note}\n\n`;
desp += '中奖了别忘给脚本(https://github.com/shanmiteko/LotteryAutoScript)点一个Star哦, 赞助一两块也不是不可以_(:з」∠)_\n\n'
log.info('可能中奖了', desp);
await sendNotify(`帐号${num}可能中奖了`, desp);
} else {

View File

@ -21,7 +21,7 @@ let loop_wait = 0;
* @returns {Promise<string>} 错误信息
*/
async function main() {
const { COOKIE, NUMBER, CLEAR, ENABLE_MULTIPLE_ACCOUNT, MULTIPLE_ACCOUNT_PARM } = process.env;
const { COOKIE, NOTE, NUMBER, CLEAR, ENABLE_MULTIPLE_ACCOUNT, MULTIPLE_ACCOUNT_PARM } = process.env;
if (ENABLE_MULTIPLE_ACCOUNT) {
let muti_acco = multiple_account.length
? multiple_account
@ -33,6 +33,7 @@ async function main() {
process.env.COOKIE = acco.COOKIE;
process.env.NUMBER = acco.NUMBER;
process.env.CLEAR = acco.CLEAR;
process.env.NOTE = acco.NOTE;
const err_msg = await main();
if (err_msg) {
return err_msg
@ -65,7 +66,7 @@ async function main() {
case 'check':
log.info('中奖检测', '检查是否中奖');
loop_wait = check_loop_wait;
await isMe(NUMBER);
await isMe(NUMBER, NOTE);
break;
case 'clear':
if (CLEAR) {