diff --git a/packages/core/src/adapter.ts b/packages/core/src/adapter.ts index 29cdd76b..f98b2941 100644 --- a/packages/core/src/adapter.ts +++ b/packages/core/src/adapter.ts @@ -3,12 +3,9 @@ import { Status, WebSocket } from '@satorijs/protocol' import { Context } from '.' import { Bot } from './bot' import Schema from 'schemastery' -import Logger from 'reggol' - -const logger = new Logger('adapter') export abstract class Adapter = Bot> { - static schema = false + static schema = false as const public bots: B[] = [] @@ -51,6 +48,7 @@ export namespace Adapter { async start() { let _retryCount = 0 + const logger = this.ctx.logger('adapter') const { retryTimes, retryInterval, retryLazy } = this.config const reconnect = async (initial = false) => { diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index e3e47ab2..397526cd 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -86,13 +86,13 @@ export interface Events extends cordis.Events { 'before-send'(session: GetSession, options: SendOptions): Awaitable 'send'(session: GetSession): void /** @deprecated use `login-added` instead */ - 'bot-added'(client: Bot): void + 'bot-added'(client: Bot): void /** @deprecated use `login-removed` instead */ - 'bot-removed'(client: Bot): void + 'bot-removed'(client: Bot): void /** @deprecated use `login-updated` instead */ - 'bot-status-updated'(client: Bot): void - 'bot-connect'(client: Bot): Awaitable - 'bot-disconnect'(client: Bot): Awaitable + 'bot-status-updated'(client: Bot): void + 'bot-connect'(client: Bot): Awaitable + 'bot-disconnect'(client: Bot): Awaitable } export interface Context { @@ -107,7 +107,7 @@ export class Context extends cordis.Context { // remove generic type to loosen the constraint static readonly Session = Session as new (bot: Bot, event: Partial) => Session - public bots = new Proxy([] as Bot[] & Dict, { + public bots = new Proxy([] as Bot[] & Dict>, { get(target, prop) { if (prop in target || typeof prop === 'symbol') { return Reflect.get(target, prop) @@ -130,7 +130,7 @@ export class Context extends cordis.Context { this.http = new Quester(config.request) - this.on('internal/warning', (format, ...args) => { + this.on('internal/warning', function (format, ...args) { this.logger('app').warn(format, ...args) }) }