Skip to content

Commit

Permalink
fix: fix typings
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Feb 25, 2025
1 parent 4d25df2 commit 91be71b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions adapters/qq/src/bot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface GetAppAccessTokenResult {
expires_in: number
}

export class QQBot<C extends Context = Context> extends Bot<C, QQBot.Config> {
export class QQBot<C extends Context = Context, T extends QQBot.Config = QQBot.Config> extends Bot<C, T> {
static MessageEncoder = QQMessageEncoder
static inject = {
required: ['http'],
Expand All @@ -26,7 +26,7 @@ export class QQBot<C extends Context = Context> extends Bot<C, QQBot.Config> {
private _token: string
private _timer: NodeJS.Timeout

constructor(ctx: C, config: QQBot.Config) {
constructor(ctx: C, config: T) {
super(ctx, config, 'qq')
let endpoint = config.endpoint
if (config.sandbox) {
Expand All @@ -46,7 +46,7 @@ export class QQBot<C extends Context = Context> extends Bot<C, QQBot.Config> {
})
this.internal = new GroupInternal(this, () => this.http)
if (config.protocol === 'websocket') {
this.ctx.plugin(WsClient, this)
this.ctx.plugin(WsClient, this as any)
} else {
this.ctx.plugin(HttpServer, this)
}
Expand Down Expand Up @@ -130,6 +130,9 @@ export namespace QQBot {

export type Config = BaseConfig & (HttpServer.Options | WsClient.Options)

export namespace Config {
}

export const Config: Schema<Config> = Schema.intersect([
Schema.object({
id: Schema.string().description('机器人 id。').required(),
Expand Down
2 changes: 1 addition & 1 deletion adapters/qq/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { QQBot } from './bot'
import { Opcode, Payload } from './types'
import { adaptSession, decodeUser } from './utils'

export class WsClient<C extends Context = Context> extends Adapter.WsClient<C, QQBot<C>> {
export class WsClient<C extends Context = Context> extends Adapter.WsClient<C, QQBot<C, QQBot.Config & WsClient.Options>> {
_sessionId = ''
_s: number = null
_ping: NodeJS.Timeout
Expand Down
2 changes: 1 addition & 1 deletion adapters/whatsapp/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class WhatsAppAdapter<C extends Context = Context> extends Adapter<C, Wha
ctx.on('ready', async () => {
const data = await internal.getPhoneNumbers(config.id)
for (const item of data) {
const bot = new WhatsAppBot(ctx, {})
const bot = new WhatsAppBot(ctx)
bot.selfId = item.id
bot.adapter = this
bot.internal = internal
Expand Down
4 changes: 2 additions & 2 deletions adapters/zulip/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ function setupReaction(session: Session, data: ReactionEvent) {
export async function adaptSession(bot: ZulipBot, input: Event) {
const session = bot.session({})
if (input.type === 'message') {
await decodeMessage(bot, input.message, session.event.message = {}, session)
await decodeMessage(bot, input.message, session.event.message = {}, session.event)
} else if (input.type === 'reaction') {
session.type = input.op === 'add' ? 'reaction-added' : 'reaction-removed'
const { message } = await bot.internal.getMessage(input.message_id.toString())
setupMessage(session, message)
setupMessage(session.event, message)
session.messageId = input.message_id.toString()
setupReaction(session, input)
} else if (input.type === 'delete_message' && input.message_type === 'stream') {
Expand Down

0 comments on commit 91be71b

Please sign in to comment.