✨ 优化群违禁词匹配,增加违禁词添加人、添加时间
This commit is contained in:
69
CHANGELOG.md
69
CHANGELOG.md
@@ -1,10 +1,12 @@
|
||||
# 1.2.2
|
||||
# 1.2.3
|
||||
|
||||
* 优化群违禁词匹配,增加违禁词添加人、添加时间
|
||||
* 优化群字符列表,字符id显示
|
||||
|
||||
# 1.2.1 ~ 1.2.2
|
||||
|
||||
* 新增可选依赖项`puppeteer-extra``puppeteer-extra-plugin-stealth`
|
||||
* 更新Puppeteer 请求 ascii2d 绕过 cf js challenge
|
||||
|
||||
# 1.2.1
|
||||
|
||||
* 新增`#加精`
|
||||
* 新增群违禁词功能
|
||||
|
||||
@@ -12,65 +14,36 @@
|
||||
|
||||
* 适配`Trss-Yunzai`一些功能
|
||||
* 修改`状态`布局
|
||||
|
||||
# 1.1.9
|
||||
|
||||
* 新增SauceNAO失败是否自动使用ascii2d配置项
|
||||
* 新增saucenao相似度过低是否自动使用ascii2d配置项
|
||||
* 修改SauceNAO超时时间防止timeOut
|
||||
* `手表协议不支持点赞`不再发送,而是输出在控制台
|
||||
* 修复批量踢人报错
|
||||
* 优化部分代码
|
||||
|
||||
|
||||
# 1.1.8
|
||||
|
||||
* `椰奶状态`新增图表
|
||||
|
||||
# 1.1.7
|
||||
|
||||
* 新增由 **@卡丘** 提供的bgg搜索
|
||||
* 新增`#椰奶设置xxx单独开启/关闭`
|
||||
* 在群里发送该指令可单独开启或关闭功能
|
||||
* 新增`#椰奶设置xxx单独取消`
|
||||
* 可以取消单独设置的功能
|
||||
* 椰奶设置图片检测到有单独设置的功能增加`群单独`标签
|
||||
|
||||
|
||||
# 1.1.6
|
||||
|
||||
* 新增**匿名**发送消息
|
||||
* 优化部分代码
|
||||
* 新增`对方正在输入`事件通知
|
||||
|
||||
# 1.1.5
|
||||
|
||||
* 新增`#椰奶涩涩帮助`ⁿᵉʷ
|
||||
* 新增`#来点秀人`ⁿᵉʷ
|
||||
|
||||
# 1.1.4
|
||||
|
||||
* 新增`#椰奶涩涩设置`ⁿᵉʷ
|
||||
* 新增`椰奶设置渲染精度`ⁿᵉʷ
|
||||
* 优化`椰奶帮助`样式
|
||||
* 恢复`#coser`
|
||||
* 修改点赞图片api
|
||||
|
||||
# 1.1.3
|
||||
|
||||
* 新增`#查看代理设置`ⁿᵉʷ
|
||||
* 优化pixiv和bika开启或关闭图片直连
|
||||
* 优化回复撤回是文件时删除文件
|
||||
* 适配`segment`全局变量
|
||||
|
||||
# 1.1.2
|
||||
|
||||
* 删除`#coser`功能
|
||||
* 参考面板和收益曲线增加更新功能,例:`#更新甘雨参考面板`
|
||||
* 新增`#哔咔下一话`ⁿᵉʷ
|
||||
|
||||
# 1.1.1
|
||||
|
||||
* 增加`Pixiv token登录`**墙内需代理**
|
||||
* 增加`#pixiv登录信息`查询登录状态ⁿᵉʷ
|
||||
* 增加`#来n张推荐图`ⁿᵉʷ
|
||||
@@ -89,16 +62,10 @@
|
||||
* 如配置文件不是最新请复制**default_config**的文件到**config**进行配置
|
||||
* 优化目录结构
|
||||
* 修复已知BUG
|
||||
|
||||
# 1.0.8
|
||||
|
||||
* 新增`哔咔`相关功能ⁿᵉʷ
|
||||
* 支持配置哔咔和pixv代理
|
||||
* 支持哔咔和pixiv图片直连
|
||||
* 添加`#user搜索`pixiv用户搜索ⁿᵉʷ
|
||||
|
||||
# 1.0.7
|
||||
|
||||
* 增加依赖`systeminformation`不安装将无法使用椰奶状态
|
||||
* 修改全部QQ接口为QQ官方接口,修改唱歌和翻译接口
|
||||
* 修改点赞图片接口
|
||||
@@ -108,11 +75,6 @@
|
||||
* 如出现许多cmd任务进程可尝试关闭此设置
|
||||
* 优化椰奶状态样式
|
||||
* 修复已知BUG
|
||||
|
||||
|
||||
|
||||
# 1.0.6
|
||||
|
||||
* 优化椰奶状态样式
|
||||
* 状态增加网速显示
|
||||
* 增加`#椰奶状态pro`感谢**@时雨星空**提供
|
||||
@@ -120,10 +82,6 @@
|
||||
* 增加`#群发言榜单`查看发言数据
|
||||
* 可在后面加上7天查看7天的发言数据
|
||||
* 状态增加**Liunx**和**Mac**硬盘传输速率显示
|
||||
|
||||
|
||||
# 1.0.5
|
||||
|
||||
* 陌生人点赞设置并入椰奶设置
|
||||
* 增加陌生人点赞,感谢**@小飞**提供的方法
|
||||
* 因不活跃的号可能会点赞失败请使用`#椰奶设置陌生人点赞开启`选择性开启
|
||||
@@ -134,19 +92,12 @@
|
||||
* Pid搜图增加更多信息
|
||||
* **sese**和**sesepro**支持群聊单独设置
|
||||
* 增加头衔屏蔽词
|
||||
|
||||
|
||||
# 1.0.4
|
||||
|
||||
* 增加群管功能
|
||||
* 使用`#椰奶群管帮助`查看
|
||||
* 状态增加**windows**的硬盘内存显示
|
||||
* 删除功能`#waifu`
|
||||
* 增加Pixiv排行榜类型**AI、新人、原创...**
|
||||
* 增加好友申请方式更改`#更改好友申请方式``#(开启|关闭)好友添加`
|
||||
|
||||
# 1.0.3
|
||||
|
||||
* 增加`#看看日|周|月|男性向|女性向榜`Pixiv榜单
|
||||
* 增加`#pid搜图`以Pixiv插画Id搜图
|
||||
* 增加`#tag搜图`以tag关键词搜图
|
||||
@@ -156,9 +107,6 @@
|
||||
* 增加`#uid搜图`用画师的**uid**或**画师名**进行搜索
|
||||
* 增加`#同意|拒绝全部好友申请`
|
||||
* 增加`#半次元话题`
|
||||
|
||||
# 1.0.2
|
||||
|
||||
* 增加`GitHub简略图`**当发送GitHub链接时会自动发送一张简略图**
|
||||
* 增加`#群星级`
|
||||
* 增加`#椰奶状态`**图片版状态**
|
||||
@@ -166,13 +114,8 @@
|
||||
* 增加`#搜索菜单`**使用各大引擎搜索返回图片**
|
||||
* 支持群通知可单独设置
|
||||
* 请在**yenai-plugin/config/config/group.yaml**进行配置
|
||||
|
||||
# 1.0.1
|
||||
|
||||
* 增加`#椰奶帮助`
|
||||
* 增加`#椰奶版本`
|
||||
* 增加`#椰奶更新日志`
|
||||
* 增加`#椰奶设置`
|
||||
|
||||
# 1.0.0
|
||||
* 椰奶插件v1.0
|
||||
|
||||
@@ -334,7 +334,7 @@ export class GroupAdmin extends plugin {
|
||||
|
||||
let msg = data.data.word_list.map((item, index) => {
|
||||
let { wording, word_id, word_desc } = item.word_info
|
||||
return `${index + 1}:${wording}-${word_id}\n寓意:${word_desc}`
|
||||
return `${word_id}:${wording}\n寓意:${word_desc}`
|
||||
}).join('\n')
|
||||
e.reply(msg)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
super({
|
||||
name: '椰奶群违禁词',
|
||||
event: 'message.group',
|
||||
priority: 500,
|
||||
priority: 1,
|
||||
rule: [
|
||||
{
|
||||
reg: '^#?新增(模糊|精确)?(踢|禁|撤|踢撤|禁撤)?违禁词.*$',
|
||||
@@ -51,7 +51,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
return false
|
||||
}
|
||||
const groupBannedWords = GroupBannedWords.initTextArr(e.group_id)
|
||||
if (_.isEmpty(groupBannedWords)) {
|
||||
if (_.isEmpty(groupBannedWords.reg)) {
|
||||
return false
|
||||
}
|
||||
const KeyWord = e.toString()
|
||||
@@ -59,15 +59,13 @@ export class NewGroupBannedWords extends plugin {
|
||||
.replace(`{at:${Bot.uin}}`, '')
|
||||
.trim()
|
||||
const trimmedKeyWord = this.trimAlias(KeyWord)
|
||||
const matchingWord = Object.keys(groupBannedWords).find((word) =>
|
||||
_.includes(trimmedKeyWord, word)
|
||||
const matchingWord = groupBannedWords.reg.find(item =>
|
||||
new RegExp(item).test(trimmedKeyWord)
|
||||
)
|
||||
if (!matchingWord) return false
|
||||
|
||||
const type = groupBannedWords[matchingWord]
|
||||
const isAccurateModeOK = type.matchType == 1 && trimmedKeyWord === matchingWord
|
||||
const isVagueModeOK = type.matchType == 2 && _.includes(trimmedKeyWord, matchingWord)
|
||||
const isOK = isAccurateModeOK || isVagueModeOK
|
||||
// 获取原始违禁词,去除正则符号
|
||||
const rawBannedWords = matchingWord.replace(/\^|\$/g, '')
|
||||
const type = groupBannedWords.data[rawBannedWords]
|
||||
const punishments = {
|
||||
'1': async () => await e.member.kick(),
|
||||
'2': async () => await e.member.mute(GroupBannedWords.getMuteTime(e.group_id)),
|
||||
@@ -81,9 +79,9 @@ export class NewGroupBannedWords extends plugin {
|
||||
await e.recall()
|
||||
}
|
||||
}
|
||||
if (isOK && punishments[type.penaltyType]) {
|
||||
if (punishments[type.penaltyType]) {
|
||||
await punishments[type.penaltyType]()
|
||||
const keyWordTran = await GroupBannedWords.keyWordTran(matchingWord)
|
||||
const keyWordTran = await GroupBannedWords.keyWordTran(rawBannedWords)
|
||||
const senderCard = e.sender.card || e.sender.nickname
|
||||
common.sendMasterMsg([
|
||||
`触发违禁词:${keyWordTran}\n`,
|
||||
@@ -101,7 +99,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
if (!word[3]) return e.reply('需要添加的屏蔽词为空')
|
||||
try {
|
||||
let res = GroupBannedWords.addBannedWords(
|
||||
e.group_id, word[3].trim(), word[1], word[2]
|
||||
e.group_id, word[3].trim(), word[1], word[2], e.user_id
|
||||
)
|
||||
e.reply([
|
||||
'✅ 成功添加违禁词\n',
|
||||
@@ -133,13 +131,15 @@ export class NewGroupBannedWords extends plugin {
|
||||
word = word.replace(/#?查看违禁词/, '').trim()
|
||||
if (!word) return e.reply('需要查询的屏蔽词为空')
|
||||
try {
|
||||
let res = GroupBannedWords.queryBannedWords(e.group_id, word)
|
||||
const { words, matchType, penaltyType, addedBy, date } = GroupBannedWords.queryBannedWords(e.group_id, word)
|
||||
e.reply([
|
||||
'✅ 查询违禁词\n',
|
||||
'违禁词:',
|
||||
await res.words,
|
||||
`\n匹配模式:${res.matchType}\n`,
|
||||
`处理方式:${res.penaltyType}`
|
||||
await words,
|
||||
`\n匹配模式:${matchType}\n`,
|
||||
`处理方式:${penaltyType}\n`,
|
||||
`添加人:${addedBy ?? '未知'}\n`,
|
||||
`添加时间:${date ?? '未知'}`
|
||||
])
|
||||
} catch (error) {
|
||||
e.reply(error.message)
|
||||
@@ -147,15 +147,20 @@ export class NewGroupBannedWords extends plugin {
|
||||
}
|
||||
|
||||
async list (e) {
|
||||
const groupBannedWords = GroupBannedWords.initTextArr(e.group_id)
|
||||
const groupBannedWords = GroupBannedWords.initTextArr(e.group_id).data
|
||||
let msg = []
|
||||
for (let i in groupBannedWords) {
|
||||
let { matchType, penaltyType } = groupBannedWords[i]
|
||||
if (_.isEmpty(groupBannedWords)) {
|
||||
return e.reply('❎ 没有违禁词')
|
||||
}
|
||||
for (const i in groupBannedWords) {
|
||||
const { matchType, penaltyType, addedBy, date } = groupBannedWords[i]
|
||||
msg.push([
|
||||
'违禁词:',
|
||||
await GroupBannedWords.keyWordTran(i),
|
||||
`\n匹配模式:${GroupBannedWords.matchTypeMap[matchType]}\n`,
|
||||
`处理方式:${GroupBannedWords.penaltyTypeMap[penaltyType]}`
|
||||
`处理方式:${GroupBannedWords.penaltyTypeMap[penaltyType]}\n`,
|
||||
`添加人:${addedBy ?? '未知'}\n`,
|
||||
`添加时间:${date ?? '未知'}`
|
||||
])
|
||||
}
|
||||
common.getforwardMsg(e, msg)
|
||||
|
||||
@@ -10,7 +10,7 @@ const yunzai_ver = `v${cfg.package.version}`
|
||||
let logs = {}
|
||||
let changelogs = []
|
||||
let currentVersion
|
||||
let versionCount = 3
|
||||
let versionCount = 2
|
||||
|
||||
const getLine = function (line) {
|
||||
line = line.replace(/(^\s*\*|\r)/g, '')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import _ from 'lodash'
|
||||
import moment from 'moment'
|
||||
import { Data, Plugin_Path } from '../components/index.js'
|
||||
|
||||
export default new class {
|
||||
@@ -21,7 +22,7 @@ export default new class {
|
||||
}
|
||||
|
||||
addBannedWords (
|
||||
groupId, words, matchType = '精确', penaltyType = '禁'
|
||||
groupId, words, matchType = '精确', penaltyType = '禁', addedBy
|
||||
) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
if (!data.bannedWords) data.bannedWords = {}
|
||||
@@ -30,8 +31,10 @@ export default new class {
|
||||
let matchTypeMapMirr = _.invert(this.matchTypeMap)
|
||||
let penaltyTypeMapMirr = _.invert(this.penaltyTypeMap)
|
||||
data.bannedWords[words] = {
|
||||
matchType: matchTypeMapMirr[matchType],
|
||||
penaltyType: penaltyTypeMapMirr[penaltyType]
|
||||
matchType: Number(matchTypeMapMirr[matchType]),
|
||||
penaltyType: Number(penaltyTypeMapMirr[penaltyType]),
|
||||
date: moment().format('MMM Do YY'),
|
||||
addedBy
|
||||
}
|
||||
Data.writeJSON(`${groupId}.json`, data, this.root)
|
||||
delete this.dataCach[groupId]
|
||||
@@ -56,6 +59,7 @@ export default new class {
|
||||
if (!data.bannedWords[words]) throw Error(`❎ 违禁词${words}不存在`)
|
||||
let { matchType, penaltyType } = data.bannedWords[words]
|
||||
return {
|
||||
...data.bannedWords[words],
|
||||
words: this.keyWordTran(words),
|
||||
matchType: this.matchTypeMap[matchType],
|
||||
penaltyType: this.penaltyTypeMap[penaltyType]
|
||||
@@ -116,10 +120,20 @@ export default new class {
|
||||
if (this.dataCach[groupId]) return this.dataCach[groupId]
|
||||
|
||||
try {
|
||||
this.dataCach[groupId] =
|
||||
Data.readJSON(`${groupId}.json`, this.root)?.bannedWords
|
||||
const data = Data.readJSON(`${groupId}.json`, this.root)?.bannedWords
|
||||
this.dataCach[groupId] = {}
|
||||
this.dataCach[groupId].data = data
|
||||
this.dataCach[groupId].reg = []
|
||||
for (const item in data) {
|
||||
if (data[item].matchType == 2) {
|
||||
this.dataCach[groupId].reg.push(item)
|
||||
} else {
|
||||
this.dataCach[groupId].reg.push(`^${item}$`)
|
||||
}
|
||||
}
|
||||
return this.dataCach[groupId]
|
||||
} catch (error) {
|
||||
logger.error(error)
|
||||
logger.error(`json格式错误:${this.root}/${groupId}.json`)
|
||||
delete this.dataCach[groupId]
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user