UNPKG

koishi-plugin-kbot

Version:
98 lines (97 loc) 3.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.apply = exports.logger = exports.Config = void 0; /* * @Author: Kabuda-czh * @Date: 2023-01-30 12:09:42 * @LastEditors: Kabuda-czh * @LastEditTime: 2023-07-11 11:16:44 * @FilePath: \KBot-App\plugins\kbot\src\plugins\guildManage\index.ts * @Description: * * Copyright (c) 2023 by Kabuda-czh, All Rights Reserved. */ const node_path_1 = require("node:path"); const koishi_1 = require("koishi"); const router_1 = require("./router"); const command_1 = require("./command"); const common_1 = require("./common"); exports.Config = koishi_1.Schema.object({ // monitorSpeech: Schema.intersect([ // Schema.object({ // enabled: Schema.boolean().default(false).description('是否开启群发言监控'), // }), // Schema.union([ // Schema.object({ // enabled: Schema.const(true).required(), // violations: Schema.union([ // Schema.array(String), // Schema.transform(String, value => [value]), // ]).default([]).description('违规词语列表'), // count: Schema.number().min(1).max(999).default(3).description('每天违规次数'), // handleWay: Schema.union([ // Schema.const('mute').description('禁言'), // Schema.const('kick').description('踢出群聊'), // ]).role('radio').default('mute').description('违规处理方式'), // }), // Schema.object({ // enabled: Schema.const(false), // }), // ]), // ]), // monitorGuildAdd: Schema.intersect([ // Schema.object({ // enabled: Schema.boolean().default(false).description('是否开启群入群监控'), // }), // Schema.union([ // Schema.object({ // enabled: Schema.const(true).required(), // timer: Schema.number().default(60).description('入群问答超时时间(秒)'), // questions: Schema.dict(String).role('table').required().description('入群问答 (左边 key 为 问题, 右边 value 为 答案)'), // }), // Schema.object({ // enabled: Schema.const(false), // }), // ]), // ]), }); exports.logger = new koishi_1.Logger('kbot-plugin-guildManage'); function apply(context) { context.model.extend('channel', { disable: 'list', watchDelete: 'boolean', }); context.command('kbot/guildManage', '群管理指令'); // TODO 优化 switch 变为 filter -> 解决中间件无法屏蔽的问题 context.before('attach-channel', (session, fields) => { if (!session.argv) return fields.add('disable'); }); // check channel context.before('command/execute', async ({ session, command }) => { return await session.observeChannel(['disable']).then((channel) => { const { disable = [] } = channel || {}; while (command) { if (disable.includes(command.name)) return ''; command = command.parent; } }); }); // 监听群撤回消息 // TODO 因 messages 插件暂时无法正确使用, 所以暂时无法监听群撤回消息 // context.guild().on('message-deleted', async (session) => { // }) (0, common_1.initCommon)(context); (0, command_1.initCommand)(context); Object.keys(router_1.routerStrategies).forEach((key) => { context.router.all(key, router_1.routerStrategies[key](context)); }); context.using(['console'], (ctx) => { ctx.console.addEntry({ dev: (0, node_path_1.resolve)(__dirname, '../../../client/index.ts'), prod: (0, node_path_1.resolve)(__dirname, '../../../dist'), }); }); } exports.apply = apply;