mirror of
https://github.com/Le-niao/Yunzai-Bot.git
synced 2025-01-09 05:57:31 +08:00
禁用私聊功能,私聊只接受ck以及抽卡链接
This commit is contained in:
parent
1e81f117cb
commit
872733eeea
@ -8,7 +8,7 @@ masterQQ:
|
||||
# 禁用私聊功能 true:私聊只接受ck以及抽卡链接(Bot主人不受限制),false:私聊可以触发全部指令,默认false
|
||||
disablePrivate: false
|
||||
# 禁用私聊Bot提示内容
|
||||
disableMsg: "私聊已禁用"
|
||||
disableMsg: "私聊已禁用,仅支持发送cookie,抽卡记录链接,记录日志文件"
|
||||
|
||||
#白名单群,配置后只在该群生效
|
||||
whiteGroup:
|
||||
|
@ -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
|
||||
|
51
plugins/system/disablePrivate.js
Normal file
51
plugins/system/disablePrivate.js
Normal 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'
|
||||
}
|
||||
|
||||
/** 发送日志文件,xlsx,json */
|
||||
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'
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user