代码:
import { Context, Schema } from 'koishi'
export const name = 'catbot-core'
export interface Config {
BotName: string,
MessageType
}
export const Config: Schema<Config> = Schema.object({
BotName: Schema.string().description('机器人名称').default('CatBot'),
MessageType: Schema.union(['Text', 'Image(暂时无法使用)']).description('消息类型')
})
export function apply(ctx: Context, cfg: Config) {
ctx.command("catbot").action(async ({ session }) => {
if (cfg.MessageType == 'Text')
var help = "CatBot 帮助\n" +
"Catbot:显示帮助信息"
return help;
});
}
环境:
System:
OS: Windows 11 10.0.26080
CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz
Binaries:
Node: 21.5.0
Yarn: 4.1.0
Koishi:
Core: 4.17.2
Console: 5.28.1
日志:
2024-04-10 01:14:38 [W] app TypeError: Invalid URL: aaa/api/onmessage/catbot
at Proxy.resolveURL (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\undios\lib\index.cjs:135:13)
at [cordis.invoke] (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\undios\lib\index.cjs:159:22)
at applyTraceable (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\@cordisjs\core\src\utils.ts:65:32)
at Object.apply (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\@cordisjs\core\src\utils.ts:57:14)
at Proxy.<anonymous> (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\undios\lib\index.cjs:72:36)
at Proxy.<anonymous> (F:\待整理\Teams\Bot\Koishi\Dev\external\lightningrobot\src\index.ts:21:39)
at Proxy.emit (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\@cordisjs\core\src\events.ts:100:16)
at _SandboxBot.dispatch (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\@satorijs\core\src\bot.ts:159:20)
at Client.ctx.console.addListener.authority (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\@koishijs\plugin-sandbox\src\index.ts:109:9)
at WebSocket.receive (F:\待整理\Teams\Bot\Koishi\Dev\node_modules\@koishijs\console\src\client.ts:35:45)