From a5af832d1a1f697be3ee345c346b672355cced4d Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Fri, 18 Jun 2021 02:02:48 +0800 Subject: [PATCH] fix(chat): fix typing issue with other adapter --- packages/plugin-chat/src/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/plugin-chat/src/index.ts b/packages/plugin-chat/src/index.ts index 8b704d3d70..7c56dbac36 100644 --- a/packages/plugin-chat/src/index.ts +++ b/packages/plugin-chat/src/index.ts @@ -1,4 +1,4 @@ -import { Bot, Context, Random, segment, Session, template } from 'koishi-core' +import { Adapter, Bot, Context, Random, segment, Session, template } from 'koishi-core' import { resolve } from 'path' import { WebServer } from 'koishi-plugin-webui' import receiver, { Message, ReceiverConfig } from './receiver' @@ -13,7 +13,7 @@ declare module 'koishi-core' { namespace Bot { interface Platforms { - 'web': SandboxBot + 'webui': SandboxBot } } } @@ -34,12 +34,12 @@ template.set('chat', { receive: '[{{ channelName || "私聊" }}] {{ username }}: {{ abstract }}', }) -export class SandboxBot extends Bot<'web'> { +export class SandboxBot extends Bot<'webui'> { username = 'sandbox' status = Bot.Status.GOOD - constructor(public readonly adapter: WebServer) { - super(adapter, { type: 'web', selfId: 'sandbox' }) + constructor(public readonly adapter: WebServer & Adapter<'webui'>) { + super(adapter, { type: 'webui', selfId: 'sandbox' }) } async sendMessage(id: string, content: string) { @@ -107,7 +107,7 @@ export function apply(ctx: Context, options: Config = {}) { content = await ctx.transformAssets(content) this.send('sandbox:user', content) const session = new Session(ctx.app, { - platform: 'web', + platform: 'webui', userId: id, content, channelId: this.id,