2024-06-11 22:10:46 +08:00
|
|
|
|
import { ConfigController as cfg } from 'yunzai/config'
|
2024-06-12 10:47:19 +08:00
|
|
|
|
import { Plugin } from 'yunzai/core'
|
2024-06-11 21:03:42 +08:00
|
|
|
|
/**
|
2024-06-17 22:52:15 +08:00
|
|
|
|
*
|
2024-06-11 21:03:42 +08:00
|
|
|
|
*/
|
2024-06-12 10:47:19 +08:00
|
|
|
|
export class disPri extends Plugin {
|
2024-06-11 21:03:42 +08:00
|
|
|
|
/**
|
2024-06-17 22:52:15 +08:00
|
|
|
|
*
|
2024-06-11 21:03:42 +08:00
|
|
|
|
*/
|
|
|
|
|
constructor() {
|
|
|
|
|
/**
|
|
|
|
|
name: '禁止私聊',
|
|
|
|
|
dsc: '对私聊禁用做处理当开启私聊禁用时只接收cookie以及抽卡链接',
|
|
|
|
|
*/
|
2024-06-12 22:36:39 +08:00
|
|
|
|
super()
|
|
|
|
|
this.event = 'message.private'
|
2024-06-11 21:03:42 +08:00
|
|
|
|
this.priority = 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-06-17 22:52:15 +08:00
|
|
|
|
*
|
|
|
|
|
* @returns
|
2024-06-11 21:03:42 +08:00
|
|
|
|
*/
|
|
|
|
|
async accept() {
|
|
|
|
|
if (!cfg.other?.disablePrivate) return
|
|
|
|
|
|
|
|
|
|
if (this.e.isMaster) return
|
|
|
|
|
|
|
|
|
|
/** 发送日志文件,xlsx,json */
|
|
|
|
|
if (this.e.file) {
|
2024-06-17 22:52:15 +08:00
|
|
|
|
if (!/(.*)\.txt|xlsx|json/gi.test(this.e.file?.name)) {
|
2024-06-11 21:03:42 +08:00
|
|
|
|
this.sendTips()
|
|
|
|
|
return 'return'
|
|
|
|
|
} else {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 绑定ck,抽卡链接 */
|
2024-06-17 22:52:15 +08:00
|
|
|
|
let wordReg =
|
|
|
|
|
/(.*)(ltoken|_MHYUUID|authkey=)(.*)|导出记录(json)*|(记录|安卓|苹果|ck|cookie|体力)帮助|^帮助$|^#*(删除|我的)ck$|^#(我的)?(uid|UID)[0-9]{0,2}$/g
|
2024-06-11 21:03:42 +08:00
|
|
|
|
/** 自定义通行字符 */
|
|
|
|
|
let disableAdopt = cfg.other?.disableAdopt
|
|
|
|
|
if (!Array.isArray(disableAdopt)) {
|
|
|
|
|
disableAdopt = []
|
|
|
|
|
}
|
2024-06-17 22:52:15 +08:00
|
|
|
|
disableAdopt = disableAdopt.filter(str => str != null && str !== '')
|
2024-06-11 21:03:42 +08:00
|
|
|
|
let disableReg = `(.*)(${disableAdopt.join('|')})(.*)`
|
|
|
|
|
if (this.e.raw_message) {
|
2024-06-17 22:52:15 +08:00
|
|
|
|
if (
|
|
|
|
|
!new RegExp(wordReg).test(this.e.raw_message) &&
|
|
|
|
|
(disableAdopt.length === 0 ||
|
|
|
|
|
!new RegExp(disableReg).test(this.e.raw_message))
|
|
|
|
|
) {
|
2024-06-11 21:03:42 +08:00
|
|
|
|
this.sendTips()
|
|
|
|
|
return 'return'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-06-17 22:52:15 +08:00
|
|
|
|
*
|
|
|
|
|
* @returns
|
2024-06-11 21:03:42 +08:00
|
|
|
|
*/
|
|
|
|
|
async sendTips() {
|
|
|
|
|
/** 冷却cd 10s */
|
|
|
|
|
let cd = 10
|
|
|
|
|
|
|
|
|
|
if (this.e.user_id == cfg.qq) return
|
|
|
|
|
|
|
|
|
|
/** cd */
|
|
|
|
|
let key = `Yz:disablePrivate:${this.e.user_id}`
|
|
|
|
|
if (await redis.get(key)) return
|
|
|
|
|
|
|
|
|
|
this.e.reply(cfg.other.disableMsg)
|
|
|
|
|
|
|
|
|
|
redis.setEx(key, cd, '1')
|
|
|
|
|
}
|
2024-06-17 22:52:15 +08:00
|
|
|
|
}
|