禁用私聊功能,私聊只接受ck以及抽卡链接

This commit is contained in:
Le-niao 2022-07-17 22:01:43 +08:00
parent 1e81f117cb
commit 872733eeea
3 changed files with 55 additions and 10 deletions

View File

@ -8,7 +8,7 @@ masterQQ:
# 禁用私聊功能 true私聊只接受ck以及抽卡链接Bot主人不受限制false私聊可以触发全部指令默认false
disablePrivate: false
# 禁用私聊Bot提示内容
disableMsg: "私聊已禁用"
disableMsg: "私聊已禁用仅支持发送cookie抽卡记录链接记录日志文件"
#白名单群,配置后只在该群生效
whiteGroup:

View File

@ -181,13 +181,7 @@ class PluginsLoader {
/** 是否只关注主动at */
if (!this.onlyReplyAt(e)) return
//对私聊禁用做处理当开启私聊禁用时只接收cookie以及抽卡链接
if(cfg.other.disablePrivate&&e.isPrivate&&!e.isMaster&&(e.msg?.includes(["ltoken","_MHYUUID","authkey_ver"])||/^[0-9]{9}$/.test(e.msg)||e.file?.name?.includes(["txt","xlsx","json"]))){
if (cfg.other.disableMsg) {
e.reply(cfg.other.disableMsg)
}
return true;
}
/** accept */
for (let plugin of priority) {
/** accept hook */
@ -275,7 +269,7 @@ class PluginsLoader {
e.reply('暂无权限,只有主人才能操作')
return false
}
if (e.isGroup) {
if (!e.member?._info) {
e.reply('数据加载中,请稍后再试')
@ -349,7 +343,7 @@ class PluginsLoader {
e.isPrivate = true
e.sender.card = e.sender.nickname
e.logText = `[私聊][${e.sender.nickname}(${e.user_id})]`
}
}
if (e.message_type == 'group') {
e.isGroup = true

View File

@ -0,0 +1,51 @@
import cfg from '../../lib/config/config.js'
import plugin from '../../lib/plugins/plugin.js'
export class disPri extends plugin {
constructor () {
super({
name: '禁止私聊',
dsc: '对私聊禁用做处理当开启私聊禁用时只接收cookie以及抽卡链接',
event: 'message.private',
priority: 1
})
}
async accept () {
if (!cfg.other?.disablePrivate) return
if (this.e.isMaster) return
/** 绑定ck抽卡链接 */
if (!this.e.msg?.match(/(.*)(ltoken|_MHYUUID|authkey=)(.*)/g)) {
this.e.reply(cfg.other.disableMsg)
return 'return'
}
/** 发送日志文件xlsxjson */
if (this.e.file && !this.e.file?.name?.includes(['txt', 'xlsx', 'json'])) {
this.e.reply(cfg.other.disableMsg)
return 'return'
}
}
}
export class disFriPoke extends plugin {
constructor () {
super({
name: '禁止私聊',
dsc: '对私聊禁用做处理当开启私聊禁用时只接收cookie以及抽卡链接',
event: 'notice.friend.poke',
priority: 1
})
}
async accept () {
if (!cfg.other?.disablePrivate) return
if (this.e.isMaster) return
this.e.reply(cfg.other.disableMsg)
return 'return'
}
}