From 2e336a50c94e2e65917641208e4fb57d43ac8248 Mon Sep 17 00:00:00 2001 From: Kyle Fang Date: Mon, 7 Jul 2025 09:42:05 +0800 Subject: [PATCH] feat: add type --- packages/mtcute-adapter/src/mtcute-adapter.ts | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/mtcute-adapter/src/mtcute-adapter.ts b/packages/mtcute-adapter/src/mtcute-adapter.ts index a731056..527eebd 100644 --- a/packages/mtcute-adapter/src/mtcute-adapter.ts +++ b/packages/mtcute-adapter/src/mtcute-adapter.ts @@ -1,16 +1,10 @@ -import { TelegramClient } from '@mtcute/bun'; -import { Dispatcher } from '@mtcute/dispatcher'; import type { TextWithEntities } from '@mtcute/bun'; +import { TelegramClient } from '@mtcute/bun'; +import { Dispatcher, type MessageContext } from '@mtcute/dispatcher'; import { tl } from '@mtcute/tl'; -import type { - RootNode, - TextNode, - FormattedNode, - LinkNode, - EmojiNode, - CodeBlockNode, - BlockQuoteNode, - RowNode +import type { + RootNode, + RowNode } from '@react-telegram/core'; import { createContainer } from '@react-telegram/core'; import type { ReactElement } from 'react'; @@ -26,7 +20,7 @@ export class MtcuteAdapter { private client: TelegramClient; private dispatcher: Dispatcher; private activeContainers: Map> = new Map(); - private commandHandlers: Map ReactElement> = new Map(); + private commandHandlers: Map ReactElement> = new Map(); constructor(config: MtcuteAdapterConfig) { this.client = new TelegramClient({ @@ -291,7 +285,7 @@ export class MtcuteAdapter { } // Convenience method to handle commands with React - onCommand(command: string, handler: (ctx: any) => ReactElement) { + onCommand(command: string, handler: (ctx: MessageContext) => ReactElement) { this.commandHandlers.set(command, handler); }