diff --git a/core/src/app.ts b/core/src/app.ts index cfdfa3f1..a3c774f2 100644 --- a/core/src/app.ts +++ b/core/src/app.ts @@ -57,7 +57,7 @@ export class App extends EventEmitter { async renderMessage(template: string, message?: T) { for (const render of this.renders) { try { - template = await render(template, message); + template = await render(template, message); } catch (e: unknown) { return `消息渲染失败:${(e as Error)?.message || '未知错误'}`; } diff --git a/core/src/command.ts b/core/src/command.ts index 858bd074..9a55177a 100644 --- a/core/src/command.ts +++ b/core/src/command.ts @@ -397,12 +397,14 @@ export class Command { message: Message, template: string, ): Command.RunTime | void { - if (bot.command_prefix) { - if (!template.startsWith(bot.command_prefix)) return; - template = template.replace(bot.command_prefix, ''); - } let argv = this.parseSugar(template); - if (!argv.name) argv = this.parseArgv(template); + if (!argv.name) { + if (bot.command_prefix) { + if (!template.startsWith(bot.command_prefix)) return; + template = template.replace(bot.command_prefix, ''); + } + argv = this.parseArgv(template); + } if (argv.name !== this.name) { if (this.aliasNames.includes(argv.name)) argv.name = this.name!; else return; diff --git a/core/src/config.ts b/core/src/config.ts index edf0096e..12bedd95 100644 --- a/core/src/config.ts +++ b/core/src/config.ts @@ -28,7 +28,13 @@ export class Config { }, set: (target, p, value, receiver) => { if (Reflect.has(this, p)) return Reflect.set(this, p, value, receiver); - const result = Reflect.set(target, p, receiver); + const result = Reflect.set(target, p, value, receiver); + this.#saveConfig(); + return result; + }, + defineProperty: (target: T, property: string | symbol, attributes: PropertyDescriptor) => { + if (Reflect.has(this, property)) return Reflect.defineProperty(target, property, attributes); + const result = Reflect.defineProperty(target, property, attributes); this.#saveConfig(); return result; }, diff --git a/packages/adapters/qq/src/utils.ts b/packages/adapters/qq/src/utils.ts index 01ffed6e..14386db2 100644 --- a/packages/adapters/qq/src/utils.ts +++ b/packages/adapters/qq/src/utils.ts @@ -38,8 +38,8 @@ export function formatSendable(message: Sendable) { ...parseFromTemplate(item).map(ele => { const { type, data } = ele; return { - type, ...data, + type, } as MessageElem; }), ); diff --git a/zhin/src/plugins/commandParser.ts b/zhin/src/plugins/commandParser.ts index d97ce745..02c034fe 100644 --- a/zhin/src/plugins/commandParser.ts +++ b/zhin/src/plugins/commandParser.ts @@ -26,7 +26,7 @@ commandParser .command('tip [name:string]') .scope('private', 'group', 'guild', 'direct') .desc('输出指令提示文本') - .alias('提示') + .sugar('提示') .sugar(/^(\S+)提示$/, { args: ['$1'] }) .option('-H [showHidden:boolean] 显示隐藏指令') .action(({ options, adapter, bot, message }, target) => { diff --git a/zhin/src/plugins/zhinManager.ts b/zhin/src/plugins/zhinManager.ts index b26c1faf..2654a865 100644 --- a/zhin/src/plugins/zhinManager.ts +++ b/zhin/src/plugins/zhinManager.ts @@ -96,7 +96,7 @@ const zhinManager = new Plugin('zhin管理'); zhinManager .command('status') .desc('查看知音运行状态') - .alias('状态') + .sugar('状态') .action(({ adapter }) => { const restartTimes = Number(process.env?.RESTART_TIMES); const lastRestartTime = Date.now() - process.uptime() * 1000;