2023-11-01 14:05:45 +03:00
|
|
|
# @mtcute/dispatcher
|
2022-08-24 23:37:26 +03:00
|
|
|
|
2023-11-01 14:05:45 +03:00
|
|
|
📖 [API Reference](https://ref.mtcute.dev/modules/_mtcute_dispatcher.html)
|
|
|
|
🧐 [Guide](https://mtcute.dev/guide/dispatcher/intro.html)
|
2022-08-24 23:37:26 +03:00
|
|
|
|
2023-11-01 14:05:45 +03:00
|
|
|
Dispatcher and bot framework based on @mtcute/client.
|
|
|
|
|
|
|
|
## Features
|
|
|
|
- **Straightforward**: Simple and expressive API
|
|
|
|
- **State**: Supports storing state for each chat
|
|
|
|
- **Filters**: Powerful and easy-to-use filtering system
|
|
|
|
- **Middleware**: Basic middleware support for updates
|
|
|
|
- **Scenes**: Built-in support for scenes
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```ts
|
|
|
|
import { NodeTelegramClient, Dispatcher } from '@mtcute/node'
|
|
|
|
|
|
|
|
const tg = new NodeTelegramClient({ ... })
|
|
|
|
const dp = Dispatcher.for(tg)
|
|
|
|
|
|
|
|
dp.onNewMessage(async (msg) => {
|
|
|
|
await msg.replyText('Hello world!')
|
|
|
|
})
|
|
|
|
```
|