Skip to content

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

@EsunR

Description

@EsunR

我希望借助使用 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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions