From 052e57ac3d547683138e981b0e350efe6efb7040 Mon Sep 17 00:00:00 2001 From: Shigma Date: Tue, 31 Oct 2023 15:59:34 +0800 Subject: [PATCH] fix: add missing injects --- package.json | 18 +++++++++--------- src/index.ts | 18 +++++++++++------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 4482697..4c90c86 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "koishi-plugin-novelai", "description": "Generate images by diffusion models", - "version": "1.18.4", + "version": "1.19.1", "main": "lib/index.js", "typings": "lib/index.d.ts", "files": [ @@ -63,22 +63,22 @@ "generate" ], "peerDependencies": { - "koishi": "^4.15.0" + "koishi": "^4.15.3" }, "devDependencies": { - "@koishijs/plugin-help": "^2.3.2", + "@koishijs/plugin-help": "^2.3.3", "@koishijs/translator": "^1.1.1", "@koishijs/vitepress": "^3.0.1", - "@types/libsodium-wrappers-sumo": "^0.7.5", - "@types/node": "^20.4.2", + "@types/libsodium-wrappers-sumo": "^0.7.7", + "@types/node": "^20.8.9", "atsc": "^1.2.2", - "koishi": "^4.15.0", - "sass": "^1.63.6", - "typescript": "^5.1.6", + "koishi": "^4.15.3", + "sass": "^1.69.5", + "typescript": "^5.2.2", "vitepress": "1.0.0-rc.4" }, "dependencies": { "image-size": "^1.0.2", - "libsodium-wrappers-sumo": "^0.7.11" + "libsodium-wrappers-sumo": "^0.7.13" } } diff --git a/src/index.ts b/src/index.ts index d8bcea9..87cebd9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,6 +28,10 @@ function handleError(session: Session, err: Error) { return session.text('.unknown-error') } +export const inject = { + optional: ['translator'], +} + export function apply(ctx: Context, config: Config) { ctx.i18n.define('zh-CN', require('./locales/zh-CN')) ctx.i18n.define('zh-TW', require('./locales/zh-TW')) @@ -85,7 +89,8 @@ export function apply(ctx: Context, config: Config) { } const cmd = ctx.command('novelai ') - .alias('nai', 'imagine') + .alias('nai') + .alias('imagine') .userFields(['authority']) .shortcut('imagine', { i18n: true, fuzzy: true }) .shortcut('enhance', { i18n: true, fuzzy: true, options: { enhance: true } }) @@ -114,13 +119,12 @@ export function apply(ctx: Context, config: Config) { input = '' options = options.resolution ? { resolution: options.resolution } : {} } - } - else if ( - !config.defaultPromptSw && - session.user.authority < session.resolve(config.authLv) + } else if ( + !config.defaultPromptSw + && session.user.authority < session.resolve(config.authLv) ) return session.text('internal.low-auth') - const haveInput = input?.trim() ? true : false + const haveInput = !!input?.trim() if (!haveInput && !config.defaultPromptSw) return session.execute('help novelai') // Check if the user is allowed to use this command. @@ -184,7 +188,7 @@ export function apply(ctx: Context, config: Config) { } const [errPath, prompt, uc] = parseInput( - session, input, config, options.override, config.defaultPromptSw + session, input, config, options.override, config.defaultPromptSw, ) if (errPath) return session.text(errPath)