Skip to content

Commit

Permalink
fix(chat): fix typing issue with other adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jun 17, 2021
1 parent 27717c9 commit a5af832
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/plugin-chat/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -13,7 +13,7 @@ declare module 'koishi-core' {

namespace Bot {
interface Platforms {
'web': SandboxBot
'webui': SandboxBot
}
}
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a5af832

Please sign in to comment.