mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
feat: 中奖通知设置可设黑名单
This commit is contained in:
parent
ec0c5da092
commit
08f4375c21
@ -1,4 +1,4 @@
|
||||
const { log, delay, infiniteNumber } = require('./utils')
|
||||
const { log, delay, infiniteNumber, judge } = require('./utils')
|
||||
const { sendNotify } = require('./helper/notify')
|
||||
const config = require('./data/config')
|
||||
const global_var = require('./data/global_var')
|
||||
@ -37,7 +37,7 @@ async function isMe() {
|
||||
if (unread_count) {
|
||||
bili_client.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
await delay(1000);
|
||||
if (config.notice_key_words.some(it => new RegExp(it).test(content))) {
|
||||
if (judge(content, config.notice_key_words)) {
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()} \n\n`
|
||||
desp += `用户: ${sender_uid} \n\n`
|
||||
desp += `私信你(${global_var.get("myUID")})说: ${content} \n\n`
|
||||
|
||||
14
lib/utils.js
14
lib/utils.js
@ -130,6 +130,20 @@ const utils = {
|
||||
}
|
||||
return array;
|
||||
},
|
||||
/**
|
||||
* 关键词判断
|
||||
* @param {string} text
|
||||
* @param {string[]} key_words startwith '~' 表示黑名单
|
||||
* @return {boolean}
|
||||
*/
|
||||
judge(text, key_words) {
|
||||
return key_words.reduce((acc, word) => {
|
||||
word.startsWith('~')
|
||||
? RegExp(word.slice(1)).test(text) && (acc = false)
|
||||
: RegExp(word).test(text) && (acc = true)
|
||||
return acc
|
||||
}, false)
|
||||
},
|
||||
/**
|
||||
* 是否有指定环境变量
|
||||
* @param {string} env_name
|
||||
|
||||
2
main.js
2
main.js
@ -10,7 +10,7 @@ const metainfo = [
|
||||
` __/ | | | `,
|
||||
` |___/ |_| `,
|
||||
` `,
|
||||
` Verison: v2.0.3`,
|
||||
` Verison: v2.0.4`,
|
||||
` Written by shanmite`,
|
||||
]
|
||||
/**多账号存储 */
|
||||
|
||||
@ -178,11 +178,13 @@ module.exports = {
|
||||
is_exception: false,
|
||||
|
||||
/**
|
||||
* 中奖通知关键词(满足一个就推送)
|
||||
* 符合js正则表达式的字符串
|
||||
* - 中奖通知关键词(满足一个就推送)
|
||||
* - 符合js正则表达式的字符串
|
||||
* - 若以 ~ 开头则表示为黑名单规则
|
||||
*/
|
||||
notice_key_words: [
|
||||
"中奖", "获得", "填写", "写上", "提供", "收货地址", "支付宝账号", "码", "大会员"
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
|
||||
"~预约抽奖通知"
|
||||
],
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user