Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教在将 koishi 作为依赖使用时,如何加载该插件 #60

Open
EsunR opened this issue Dec 21, 2024 · 0 comments
Open

请教在将 koishi 作为依赖使用时,如何加载该插件 #60

EsunR opened this issue Dec 21, 2024 · 0 comments

Comments

@EsunR
Copy link

EsunR commented Dec 21, 2024

我希望借助使用 koishi + koishi-plugin-adapter-onebot 来迭代已有的聊天机器人项目,因此我按照 koishi 的官方文档:https://github.com/koishijs/docs/blob/main/zh-CN/manual/starter/direct.md 进行配置。但是按照教程配置完成之后,发现 OneBotBot 类没有被有效的实例化,也没有调用 ctx.server 来创建 onebot 路由,导致最终请求 404。

我的现有的代码如下:

import server from "@koishijs/plugin-server"
import { Context } from "koishi"
import OneBotAdapter from "koishi-plugin-adapter-onebot"
import { qqBotConfig } from "../config"

const ctx = new Context()

ctx.plugin(server, {
  port: 3001,
  host: "0.0.0.0",
}) // 提供后端服务

ctx.plugin(OneBotAdapter, {
  protocol: "http",
  selfId: qqBotConfig.botQQ,
  path: "/onebot",
  endpoint: "localhost:3000",
})

export function getKoishiCtx() {
  return ctx
}
@EsunR EsunR changed the title 请教如何在将 koishi 作为依赖使用时,如何加载该插件 请教在将 koishi 作为依赖使用时,如何加载该插件 Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant