From eccd73f421d5cb2d53cb581e1877d31ff50497b7 Mon Sep 17 00:00:00 2001 From: yeyang <746659424@qq.com> Date: Wed, 19 Oct 2022 01:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BE=A4=E5=8D=95=E7=8B=AC?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/notice_friend.js | 9 +- apps/notice_group.js | 23 ++--- apps/notice_message.js | 50 +++++------ apps/request.js | 70 +++++++++++++++ apps/request_friend.js | 36 -------- apps/request_group.js | 45 ---------- apps/set.js | 45 ++-------- components/Config.js | 141 +++++++++++++++++-------------- config/config/group.yaml | 15 ++++ config/config/whole.yaml | 17 ++++ config/default_config/whole.yaml | 20 +++++ model/Browser.js | 24 ++---- 12 files changed, 260 insertions(+), 235 deletions(-) create mode 100644 apps/request.js delete mode 100644 apps/request_friend.js delete mode 100644 apps/request_group.js create mode 100644 config/config/group.yaml create mode 100644 config/config/whole.yaml create mode 100644 config/default_config/whole.yaml diff --git a/apps/notice_friend.js b/apps/notice_friend.js index 34b238c..ef92944 100644 --- a/apps/notice_friend.js +++ b/apps/notice_friend.js @@ -2,6 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js' import { segment } from 'oicq' import cfg from '../../../lib/config/config.js' import xcfg from '../model/Config.js' +import { Config } from '../components/index.js' /** 好友通知 */ @@ -19,7 +20,7 @@ export class Friends extends plugin { let forwardMsg switch (e.sub_type) { case 'increase': { - if (!await redis.get(`yenai:notice:friendNumberChange`)) return + if (!Config.Notice.friendNumberChange) return logger.mark("[椰奶]新增好友") msg = [ segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${e.user_id}`), @@ -30,7 +31,7 @@ export class Friends extends plugin { break } case 'decrease': { - if (!await redis.get(`yenai:notice:friendNumberChange`)) return + if (!Config.Notice.friendNumberChange) return logger.mark("[椰奶]好友减少") msg = [ segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${e.user_id}`), @@ -41,7 +42,7 @@ export class Friends extends plugin { break } case 'recall': { - if (!await redis.get(`yenai:notice:PrivateRecall`)) return + if (!Config.Notice.PrivateRecall) return if (e.user_id == cfg.qq) return @@ -82,7 +83,7 @@ export class Friends extends plugin { break } case 'poke': { - if (!await redis.get(`yenai:notice:privateMessage`)) return + if (!Config.Notice.privateMessage) return logger.mark("[椰奶]好友戳一戳") msg = [ segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${e.user_id}`), diff --git a/apps/notice_group.js b/apps/notice_group.js index d66e780..9c489b5 100644 --- a/apps/notice_group.js +++ b/apps/notice_group.js @@ -2,6 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js' import { segment } from 'oicq' import cfg from '../../../lib/config/config.js' import xcfg from '../model/Config.js' +import { Config } from '../components/index.js' @@ -21,7 +22,7 @@ export class newgroups extends plugin { switch (e.sub_type) { case 'increase': { if (e.user_id === cfg.qq) { - if (!await redis.get(`yenai:notice:groupNumberChange`)) return + if (!Config.getGroup(e.group_id).groupNumberChange) return logger.mark("[椰奶]新增群聊") @@ -33,7 +34,7 @@ export class newgroups extends plugin { `新增群号:${e.group_id}` ] } else { - if (!await redis.get(`yenai:notice:groupMemberNumberChange`)) return + if (!Config.getGroup(e.group_id).groupMemberNumberChange) return logger.mark("[椰奶]新增群员") @@ -51,7 +52,7 @@ export class newgroups extends plugin { } case 'decrease': { if (e.dismiss) { - if (!await redis.get(`yenai:notice:groupNumberChange`)) return + if (!Config.getGroup(e.group_id).groupNumberChange) return logger.mark("[椰奶]群聊被解散") @@ -64,7 +65,7 @@ export class newgroups extends plugin { `解散群号:${e.group_id}` ] } else if (e.user_id === cfg.qq && e.operator_id !== cfg.qq) { - if (!await redis.get(`yenai:notice:groupNumberChange`)) return + if (!Config.getGroup(e.group_id).groupNumberChange) return logger.mark("[椰奶]机器人被踢") @@ -77,7 +78,7 @@ export class newgroups extends plugin { `被踢群号:${e.group_id}` ] } else if (e.user_id === cfg.qq && e.operator_id === cfg.qq) { - if (!await redis.get(`yenai:notice:groupNumberChange`)) return + if (!Config.getGroup(e.group_id).groupNumberChange) return logger.mark("[椰奶]机器人退群") @@ -89,7 +90,7 @@ export class newgroups extends plugin { `退出群号:${e.group_id}` ] } else if (e.operator_id === e.user_id) { - if (!await redis.get(`yenai:notice:groupMemberNumberChange`)) return + if (!Config.getGroup(e.group_id).groupMemberNumberChange) return logger.mark("[椰奶]群员退群") @@ -108,7 +109,7 @@ export class newgroups extends plugin { `退出群号:${e.group_id}` ] } else if (e.operator_id !== e.user_id) { - if (!await redis.get(`yenai:notice:groupMemberNumberChange`)) return + if (!Config.getGroup(e.group_id).groupMemberNumberChange) return logger.mark("[椰奶]群员被踢") @@ -132,7 +133,7 @@ export class newgroups extends plugin { } // 群管理变动 case 'admin': { - if (!await redis.get(`yenai:notice:groupAdminChange`)) return + if (!Config.getGroup(e.group_id).groupAdminChange) return e.set ? logger.mark("[椰奶]机器人被设置管理") : logger.mark("[椰奶]机器人被取消管理") if (e.user_id === cfg.qq) { @@ -166,7 +167,7 @@ export class newgroups extends plugin { case 'ban': { let Forbiddentime = getsecond(e.duration) - if (!await redis.get(`yenai:notice:botBeenBanned`)) return + if (!Config.getGroup(e.group_id).botBeenBanned) return if (e.user_id != cfg.qq) return @@ -198,7 +199,7 @@ export class newgroups extends plugin { } // 群转让 case 'transfer': { - if (!await redis.get(`yenai:notice:groupNumberChange`)) return + if (!Config.getGroup(e.group_id).groupNumberChange) return logger.mark("[椰奶]群聊转让") @@ -216,7 +217,7 @@ export class newgroups extends plugin { // 群撤回 case 'recall': { // 开启或关闭 - if (!await redis.get(`yenai:notice:groupRecall`)) return + if (!Config.getGroup(e.group_id).groupRecall) return // 是否为机器人撤回 if (e.user_id == cfg.qq) return // 是否为主人撤回 diff --git a/apps/notice_message.js b/apps/notice_message.js index 9f615ed..08750ac 100644 --- a/apps/notice_message.js +++ b/apps/notice_message.js @@ -2,6 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js' import { segment } from 'oicq' import cfg from '../../../lib/config/config.js' import xcfg from '../model/Config.js' +import { Config } from '../components/index.js' export class anotice extends plugin { constructor() { @@ -20,28 +21,29 @@ Bot.on("message", async (e) => { // 判断是否主人消息 if (cfg.masterQQ.includes(e.user_id)) return //删除缓存时间 - let deltime = Number(await redis.get(`yenai:notice:deltime`)) + let deltime = Config.Notice.deltime // 判断群聊还是私聊 if (e.isGroup) { // 关闭撤回停止存储 - if (await redis.get(`yenai:notice:groupRecall`)) { - // 写入 - await redis.set( - `notice:messageGroup:${e.message_id}`, - JSON.stringify(e.message), - { EX: deltime } - ) - } + if (!Config.getGroup(e.group_id).groupRecall) return + // 写入 + await redis.set( + `notice:messageGroup:${e.message_id}`, + JSON.stringify(e.message), + { EX: deltime } + ) + } else if (e.isPrivate) { + if (!Config.Notice.PrivateRecall) return // 关闭撤回停止存储 - if (await redis.get(`yenai:notice:PrivateRecall`)) { - // 写入 - await redis.set( - `notice:messagePrivate:${e.message_id}`, - JSON.stringify(e.message), - { EX: deltime } - ) - } + if (await redis.get(`yenai:notice:PrivateRecall`)) return + // 写入 + await redis.set( + `notice:messagePrivate:${e.message_id}`, + JSON.stringify(e.message), + { EX: deltime } + ) + } // 消息通知 @@ -50,7 +52,7 @@ Bot.on("message", async (e) => { if ( e.message[0].type == 'flash' && e.message_type === 'group' && - await redis.get(`yenai:notice:flashPhoto`) + Config.Notice.flashPhoto ) { logger.mark("[椰奶]群聊闪照") msg = [ @@ -65,7 +67,7 @@ Bot.on("message", async (e) => { } else if ( e.message[0].type == 'flash' && e.message_type === 'discuss' && - await redis.get(`yenai:notice:flashPhoto`) + Config.Notice.flashPhoto ) { logger.mark("[椰奶]讨论组闪照") msg = [ @@ -80,7 +82,7 @@ Bot.on("message", async (e) => { } else if ( e.message[0].type == 'flash' && e.message_type === 'private' && - await redis.get(`yenai:notice:flashPhoto`) + Config.Notice.flashPhoto ) { logger.mark("[椰奶]好友闪照") msg = [ @@ -91,7 +93,7 @@ Bot.on("message", async (e) => { `闪照链接:${e.message[0].url}` ] } else if (e.message_type === 'private' && e.sub_type === 'friend') { - if (!await redis.get(`yenai:notice:privateMessage`)) return + if (!Config.Notice.privateMessage) return let res = e.message // 特殊消息处理 @@ -120,7 +122,7 @@ Bot.on("message", async (e) => { ) } } else if (e.message_type === 'private' && e.sub_type === 'group') { - if (!await redis.get(`yenai:notice:grouptemporaryMessage`)) return + if (!Config.getGroup(e.group_id).grouptemporaryMessage) return // 特殊消息处理 let res = e.message let arr = getSpecial(e.message) @@ -139,7 +141,7 @@ Bot.on("message", async (e) => { ...res ] } else if (e.message_type === 'group') { - if (!await redis.get(`yenai:notice:groupMessage`)) return + if (!Config.getGroup(e.group_id).groupMessage) return // 特殊消息处理 let res = e.message let arr = getSpecial(e.message) @@ -159,7 +161,7 @@ Bot.on("message", async (e) => { ...res ] } else if (e.message_type === 'discuss') { - if (!await redis.get(`yenai:notice:groupMessage`)) return + if (!Config.getGroup(e.group_id).groupMessage) return logger.mark("[椰奶]讨论组消息") msg = [ segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${e.user_id}`), diff --git a/apps/request.js b/apps/request.js new file mode 100644 index 0000000..e18fd80 --- /dev/null +++ b/apps/request.js @@ -0,0 +1,70 @@ +import plugin from '../../../lib/plugins/plugin.js' +import { segment } from 'oicq' +import cfg from '../../../lib/config/config.js' +import xcfg from '../model/Config.js' +import { Config } from '../components/index.js' + +const ROLE_MAP = { + admin: '群管理', + owner: '群主', + member: '群员' +} + +/** 群邀请 */ +export class invitation extends plugin { + constructor() { + super({ + name: '群邀请和好友申请', + event: 'request', + priority: 2000, + }) + } +} +//群邀请 +Bot.on('request.group.invite', async (e) => { + let msg = '' + if (!Config.Notice.groupInviteRequest) return + // if (!await redis.get(`yenai:notice:groupInviteRequest`)) return + + if (cfg.masterQQ.includes(e.user_id)) return + logger.mark("[椰奶]邀请机器人进群") + msg = [ + segment.image(`https://p.qlogo.cn/gh/${e.group_id}/${e.group_id}/0`), + '[通知 - 邀请机器人进群]\n', + `目标群号:${e.group_id}\n`, + `目标群名:${e.group_name}\n`, + `邀请人QQ:${e.user_id}\n`, + `邀请人昵称:${e.nickname}\n`, + `邀请人群身份:${ROLE_MAP[e.role]}\n`, + `邀请码:${e.seq}\n` + ] + if (cfg.other.autoQuit <= 0) { + msg.push('----------------\n可引用该消息回复"同意"或"拒绝"') + } else { + msg.push('已自动处理该邀请') + } + await xcfg.getSend(msg) +}) + +//好友申请 +Bot.on('request.friend', async (e) => { + if (!Config.Notice.friendRequest) return + // if (!await redis.get(`yenai:notice:friendRequest`)) return + logger.mark("[椰奶]好友申请") + let msg = [ + segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${e.user_id}`), + '[通知 - 添加好友申请]\n', + `申请人QQ:${e.user_id}\n`, + `申请人昵称:${e.nickname}\n`, + `申请来源:${e.source || '未知'}\n`, + `附加信息:${e.comment || '无附加信息'}\n` + ] + if (cfg.other.autoFriend == 1) { + msg.push('已自动同意该好友申请') + } else { + msg.push( + `-------------\n可回复:同意申请${e.user_id} \n或引用该消息回复"同意"或"拒绝"` + ) + } + await xcfg.getSend(msg) +}) \ No newline at end of file diff --git a/apps/request_friend.js b/apps/request_friend.js deleted file mode 100644 index 49443be..0000000 --- a/apps/request_friend.js +++ /dev/null @@ -1,36 +0,0 @@ -import plugin from '../../../lib/plugins/plugin.js' -import { segment } from 'oicq' -import cfg from '../../../lib/config/config.js' -import xcfg from '../model/Config.js' - -/** 好友申请 */ -export class application extends plugin { - constructor() { - super({ - name: '好友申请', - event: 'request.friend', - priority: 2000, - }) - } - - async accept(e) { - if (!await redis.get(`yenai:notice:friendRequest`)) return - logger.mark("[椰奶]好友申请") - let msg = [ - segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${e.user_id}`), - '[通知 - 添加好友申请]\n', - `申请人QQ:${e.user_id}\n`, - `申请人昵称:${e.nickname}\n`, - `申请来源:${e.source || '未知'}\n`, - `附加信息:${e.comment || '无附加信息'}\n` - ] - if (cfg.other.autoFriend == 1) { - msg.push('已自动同意该好友申请') - } else { - msg.push( - `-------------\n可回复:同意申请${e.user_id} \n或引用该消息回复"同意"或"拒绝"` - ) - } - await xcfg.getSend(msg) - } -} \ No newline at end of file diff --git a/apps/request_group.js b/apps/request_group.js deleted file mode 100644 index 1213813..0000000 --- a/apps/request_group.js +++ /dev/null @@ -1,45 +0,0 @@ -import plugin from '../../../lib/plugins/plugin.js' -import { segment } from 'oicq' -import cfg from '../../../lib/config/config.js' -import xcfg from '../model/Config.js' - -const ROLE_MAP = { - admin: '群管理', - owner: '群主', - member: '群员' -} - -/** 群邀请 */ -export class invitation extends plugin { - constructor() { - super({ - name: '群邀请', - event: 'request.group.invite', - priority: 2000, - }) - } - - async accept(e) { - let msg = '' - if (!await redis.get(`yenai:notice:groupInviteRequest`)) return - - if (cfg.masterQQ.includes(e.user_id)) return - logger.mark("[椰奶]邀请机器人进群") - msg = [ - segment.image(`https://p.qlogo.cn/gh/${e.group_id}/${e.group_id}/0`), - '[通知 - 邀请机器人进群]\n', - `目标群号:${e.group_id}\n`, - `目标群名:${e.group_name}\n`, - `邀请人QQ:${e.user_id}\n`, - `邀请人昵称:${e.nickname}\n`, - `邀请人群身份:${ROLE_MAP[e.role]}\n`, - `邀请码:${e.seq}\n` - ] - if (cfg.other.autoQuit <= 0) { - msg.push('----------------\n可引用该消息回复"同意"或"拒绝"') - } else { - msg.push('已自动处理该邀请') - } - await xcfg.getSend(msg) - } -} \ No newline at end of file diff --git a/apps/set.js b/apps/set.js index dd39ebd..87ec219 100644 --- a/apps/set.js +++ b/apps/set.js @@ -2,7 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js' import fs from "fs"; import lodash from "lodash"; import Common from "../components/Common.js"; -import common from '../../../lib/common/common.js' +import { Config } from '../components/index.js' export class NewConfig extends plugin { @@ -42,22 +42,14 @@ export class NewConfig extends plugin { // 解析消息 let index = e.msg.replace(/#|椰奶设置|开启|关闭/g, "") - if (!configs.hasOwnProperty(index)) return // 开启还是关闭 if (/开启/.test(e.msg)) { - await redis.set(`yenai:notice:${configs[index]}`, "1").then(() => { - logger.mark(`[椰奶]已启用${index}`) - }).catch(err => { - logger.error(`[椰奶]启用失败${index}`, err) - }) + Config.modify("whole", configs[index], true) } else { - await redis.del(`yenai:notice:${configs[index]}`).then(() => { - logger.mark(`[椰奶]已禁用${index}`) - }).catch(err => { - logger.error(`[椰奶]禁用失败${index}`, err) - }) + Config.modify("whole", configs[index], false) } + // await this.yenaiset(e) return true; } @@ -74,13 +66,10 @@ export class NewConfig extends plugin { if (time < 120) return e.reply('❎ 时间不能小于两分钟') - await redis.set(`yenai:notice:deltime`, String(time[0])).then(() => { - logger.mark(`[椰奶]设置删除缓存时间为${time[0]}`) - }).catch(err => { - logger.error(`[椰奶]设置删除缓存时间失败`, err) - }) + Config.modify("whole", `deltime`, Number(time[0])) this.yenaiset(e) + return true; } @@ -95,24 +84,12 @@ export class NewConfig extends plugin { if (yes) { for (let i in configs) { if (no.includes(configs[i])) continue - - await redis.set(`yenai:notice:${configs[i]}`, "1").then(() => { - logger.mark(`[椰奶]已启用${i}`) - }).catch(err => { - logger.error(`[椰奶]启用失败${i}`, err) - }) - - await common.sleep(200) + Config.modify("whole", configs[i], yes) } } else { for (let i in configs) { if (no.includes(configs[i])) continue - await redis.del(`yenai:notice:${configs[i]}`).then(() => { - logger.mark(`[椰奶]已禁用${i}`) - }).catch(err => { - logger.error(`[椰奶]禁用失败${i}`, err) - }) - await common.sleep(200) + Config.modify("whole", configs[i], yes) } } this.yenaiset(e) @@ -121,11 +98,7 @@ export class NewConfig extends plugin { async yenaiset(e) { if (!e.isMaster) return - let config = {} - for (let i in configs) { - let res = await redis.get(`yenai:notice:${configs[i]}`) - config[configs[i]] = res - } + let config = await Config.Notice let cfg = { //好友消息 diff --git a/components/Config.js b/components/Config.js index 2242f2e..89b5c64 100644 --- a/components/Config.js +++ b/components/Config.js @@ -10,96 +10,113 @@ class Config { this.config = {} /** 监听文件 */ - this.watcher = {} + this.watcher = { config: {}, defSet: {} } - this.ignore = [] + this.initCfg() + } + /** 初始化配置 */ + initCfg() { + let path = `${Plugin_Path}/config/config/` + let pathDef = `${Plugin_Path}/config/default_config/` + const files = fs.readdirSync(pathDef).filter(file => file.endsWith('.yaml')) + for (let file of files) { + if (!fs.existsSync(`${path}${file}`)) { + fs.copyFileSync(`${pathDef}${file}`, `${path}${file}`) + } + } } - /** - * @param app 功能 - * @param name 配置文件名称 - */ - getdefSet(app, name) { - return this.getYaml(app, name, 'defSet') + /** 群配置 */ + getGroup(groupId = '') { + let config = this.getConfig('whole') + let group = this.getConfig("group") + let defCfg = this.getdefSet('whole') + + if (group[groupId]) { + return { ...defCfg, ...config, ...group[groupId] } + } + return { ...defCfg, ...config } + } + + //获取全局设置 + get Notice() { + return this.getNotice() + } + + /** 通知配置 */ + getNotice() { + let def = this.getdefSet('whole') + let config = this.getConfig('whole') + return { ...def, ...config } + } + + /** 默认配置 */ + getdefSet(name) { + return this.getYaml('default_config', name) } /** 用户配置 */ - getConfig(app, name) { - return this.getYaml(app, name, 'config') + getConfig(name) { + return this.getYaml('config', name) } /** * 获取配置yaml - * @param app 功能 - * @param name 名称 * @param type 默认跑配置-defSet,用户配置-config + * @param name 名称 */ - getYaml(app, name, type) { - let file = this.getFilePath(app, name, type) - let key = `${app}.${name}` + getYaml(type, name) { + let file = `${Plugin_Path}/config/${type}/${name}.yaml` + let key = `${type}.${name}` - if (this.config[type][key]) return this.config[type][key] + if (this.config[key]) return this.config[key] - try { - this.config[type][key] = YAML.parse( - fs.readFileSync(file, 'utf8') - ) - } catch (error) { - logger.error(`[${app}][${name}] 格式错误 ${error}`) - return false - } + this.config[key] = YAML.parse( + fs.readFileSync(file, 'utf8') + ) - this.watch(file, app, name, type) + this.watch(file, name, type) - return this[type][key] - } - - getFilePath(app, name, type) { - if (!this.config[type]) { - this.config[type] = {}; - } - - if (!this.watcher[type]) { - this.watcher[type] = {}; - } - - let config_path = `${Plugin_Path}/${type}/`; - let file = `${config_path}${app}.${name}.yaml`; - try { - if (!fs.existsSync(file)) { - let default_file = `${config_path}default/${app}.${name}.yaml`; - fs.copyFileSync(default_file, file); - } - } catch (err) { } - return file; + return this.config[key] } /** 监听配置文件 */ - watch(file, app, name, type = 'defSet') { - let key = `${app}.${name}` + watch(file, name, type = 'default_config') { + let key = `${type}.${name}` - if (this.watcher[type][key]) return + if (this.watcher[key]) return const watcher = chokidar.watch(file) watcher.on('change', path => { - delete this[type][key] - logger.mark(`[修改配置文件][${type}][${app}][${name}]`) - if (this[`change_${app}${name}`]) { - this[`change_${app}${name}`]() + delete this.config[key] + if (typeof Bot == 'undefined') return + logger.mark(`[椰奶修改配置文件][${type}][${name}]`) + if (this[`change_${name}`]) { + this[`change_${name}`]() } }) - this.watcher[type][key] = watcher + this.watcher[key] = watcher } - - save(app, name, type) { - let file = this.getFilePath(app, name, type) - if (lodash.isEmpty(data)) { - fs.existsSync(file) && fs.unlinkSync(file) - } else { - let yaml = YAML.stringify(data) - fs.writeFileSync(file, yaml, 'utf8') + /** + * @description: 修改设置 + * @param {String} name 文件名 + * @param {String} key 修改的key值 + * @param {*} value 修改的value值 + * @return {Boolean} 返回是否成功写入 + */ + modify(name, key, value) { + let path = `${Plugin_Path}/config/config/${name}.yaml` + let config = this.Notice + config[key] = value + try { + fs.writeFileSync(path, YAML.stringify(config), 'utf8') + delete this.config[`config.${name}`] + return true; + } catch (e) { + console.log(e); + return false; } } diff --git a/config/config/group.yaml b/config/config/group.yaml new file mode 100644 index 0000000..d0da0d2 --- /dev/null +++ b/config/config/group.yaml @@ -0,0 +1,15 @@ +#群单独设置 会覆盖掉全局设置 全局设置可用#椰奶设置查看 或 在whole.yaml查看 +123456: + groupMessage: false #群消息 + grouptemporaryMessage: false #群临时消息 + groupRecall: false #群撤回 + groupInviteRequest: false #群邀请 + groupAdminChange: false #群管理变动 + groupNumberChange: false #群聊列表变动 + groupMemberNumberChange: false #群成员变动 + botBeenBanned: false #禁言 + +#请严格按照此格式 不需要的设置项可删除 +123456: + groupMessage: false #群消息 + grouptemporaryMessage: false #群临时消息 diff --git a/config/config/whole.yaml b/config/config/whole.yaml new file mode 100644 index 0000000..bcfd3c3 --- /dev/null +++ b/config/config/whole.yaml @@ -0,0 +1,17 @@ +groupMessage: false +grouptemporaryMessage: false +groupRecall: false +groupInviteRequest: false +groupAdminChange: false +groupNumberChange: false +groupMemberNumberChange: false +privateMessage: false +PrivateRecall: false +friendRequest: false +friendNumberChange: false +flashPhoto: false +botBeenBanned: true +notificationsAll: false +sese: true +state: false +deltime: 600 diff --git a/config/default_config/whole.yaml b/config/default_config/whole.yaml new file mode 100644 index 0000000..09a6a96 --- /dev/null +++ b/config/default_config/whole.yaml @@ -0,0 +1,20 @@ +#群通知类 +groupMessage: true #群消息 +grouptemporaryMessage: false #群临时消息 +groupRecall: false #群撤回 +groupInviteRequest: false #群邀请 +groupAdminChange: false #群管理变动 +groupNumberChange: false #群聊列表变动 +groupMemberNumberChange: false #群成员变动 +#好友通知类 +privateMessage: true #好友消息 +PrivateRecall: false #好友撤回 +friendRequest: false #好友申请 +friendNumberChange: true #好友列表变动 +#其他设置 +flashPhoto: false #闪照 +botBeenBanned: false #禁言 +notificationsAll: false #全部通知 +sese: false #涩涩 +state: false #状态 +deltime: 600 #删除缓存 diff --git a/model/Browser.js b/model/Browser.js index 36f89ff..e15a4a1 100644 --- a/model/Browser.js +++ b/model/Browser.js @@ -1,9 +1,11 @@ -import { createRequire } from 'module' -const require = createRequire(import.meta.url) -const puppeteer = require('puppeteer'); - +import puppeteer from 'puppeteer' class Browser { + /** + * @description: 返回网页截图 + * @param {String} url 网页链接 + * @return {image} 图片 + */ async Webpage(url) { const browser = await puppeteer.launch({ args: ["--no-sandbox", "--disable-setuid-sandbox"] @@ -40,7 +42,7 @@ class Browser { * @param {String} url 网页链接 * @param {Number} width 页面的宽度 * @param {Number} height 页面的高度 - * @return {img} 图片 + * @return {image} 图片 */ async webPreview(url, width = 1920, height = 1080) { @@ -70,18 +72,6 @@ class Browser { await browser.close(); return res } - //延时函数 - sleep(delay) { - return new Promise((resolve, reject) => { - setTimeout(() => { - try { - resolve(1) - } catch (e) { - reject(0) - } - }, delay) - }) - } }