⚗️ add
This commit is contained in:
41
apps/groupBannedWords.js
Normal file
41
apps/groupBannedWords.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import { common, GroupBannedWords } from '../model/index.js'
|
||||
|
||||
export class NewGroupBannedWords extends plugin {
|
||||
constructor () {
|
||||
super({
|
||||
name: '椰奶群屏蔽词',
|
||||
event: 'message.group',
|
||||
priority: 500,
|
||||
rule: [
|
||||
{
|
||||
reg: '^#?新增屏蔽词.*$',
|
||||
fnc: 'add'
|
||||
},
|
||||
{
|
||||
reg: '^#?删除屏蔽词.*$',
|
||||
fnc: 'del'
|
||||
},
|
||||
{
|
||||
reg: '^#?查看屏蔽词.*$',
|
||||
fnc: 'query'
|
||||
}
|
||||
]
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
async add (e) {
|
||||
if (!common.Authentication(e, 'admin', 'admin')) return false
|
||||
let words = e.msg.replace(/#?新增屏蔽词/, '')?.split(',')
|
||||
if (!words) return e.reply('需要添加的屏蔽词为空')
|
||||
GroupBannedWords.addBannedWords(e.group_id, words)
|
||||
}
|
||||
|
||||
async del (e) {
|
||||
|
||||
}
|
||||
|
||||
async query (e) {
|
||||
|
||||
}
|
||||
}
|
||||
1
config/group/.gitignore
vendored
Normal file
1
config/group/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.json
|
||||
@@ -84,7 +84,9 @@ export default new class newCommon {
|
||||
* @param {Array<string|object>} message - 发送的消息数组,数组每一项为转发消息的一条消息
|
||||
* @param {Object} [options] - 发送消息的配置项
|
||||
* @param {Number} [options.recallMsg=0] - 撤回时间,单位秒,默认为0表示不撤回
|
||||
* @param {{nickname:string,user_id:number}} [options.info] - 转发发送人信息
|
||||
* @param {object} [options.info] - 转发发送人信息
|
||||
* @param {string} options.info.nickname - 转发人昵称
|
||||
* @param {number} options.info.user_id - 转发人QQ
|
||||
* @param {string|array} [options.fkmsg] - 风控消息,不传则默认消息
|
||||
* @param {Boolean} [options.isxml] - 是否处理卡片,若为true则处理卡片
|
||||
* @param {Boolean} [options.isxmlMsg] - 处理卡片显示的消息
|
||||
|
||||
17
model/GroupBannedWords.JS
Normal file
17
model/GroupBannedWords.JS
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Data, Plugin_Path } from '../components/index.js'
|
||||
import _ from 'lodash'
|
||||
export default new class {
|
||||
constructor () {
|
||||
this.root = `${Plugin_Path}/config/group`
|
||||
}
|
||||
|
||||
addBannedWords (groupId, words) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
if (!data.bannedWords)data.bannedWords = []
|
||||
if (Array.isArray(words)) words = [words]
|
||||
let uniqWords = _.uniq(words)
|
||||
data.bannedWords.push(...words)
|
||||
Data.writeJSON(`${groupId}.json`, data, this.root)
|
||||
return uniqWords
|
||||
}
|
||||
}()
|
||||
@@ -12,6 +12,7 @@ import Ascii2D from './PicSearch/ascii2d.js'
|
||||
import SauceNAO from './PicSearch/saucenao.js'
|
||||
import WhatAnime from './PicSearch/whatanime.js'
|
||||
import listener from './listener/loader.js'
|
||||
import GroupBannedWords from './GroupBannedWords.js'
|
||||
// 加载监听事件
|
||||
listener.load()
|
||||
// 导出模块
|
||||
@@ -29,6 +30,7 @@ export {
|
||||
Bika,
|
||||
uploadRecord,
|
||||
GroupAdmin,
|
||||
GroupBannedWords,
|
||||
QQApi,
|
||||
funApi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user