# MTCute Integration This project includes an adapter for using the React Telegram reconciler with [MTCute](https://github.com/mtcute/mtcute), a TypeScript library for Telegram's MTProto API. ## Setup 1. Install dependencies: ```bash bun add @mtcute/bun @mtcute/dispatcher @mtcute/html-parser ``` 2. Create a `.env` file with your Telegram credentials: ```env API_ID=your_api_id API_HASH=your_api_hash BOT_TOKEN=your_bot_token ``` 3. Get your API credentials from https://my.telegram.org 4. Create a bot and get the token from @BotFather on Telegram ## Usage ### Basic Example ```tsx import React, { useState } from 'react'; import { MtcuteAdapter } from './mtcute-adapter'; // Create your React component const CounterApp = () => { const [count, setCount] = useState(0); return ( <> Counter: {count} {'\n'} ); }; // Set up the bot const adapter = new MtcuteAdapter({ apiId: parseInt(process.env.API_ID!), apiHash: process.env.API_HASH!, botToken: process.env.BOT_TOKEN!, }); // Handle commands adapter.onCommand('counter', () => ); // Start the bot await adapter.start(process.env.BOT_TOKEN!); ``` ### How It Works 1. **React to Telegram Conversion**: The adapter converts the React tree into Telegram's message format: - Text nodes → Plain text - Formatting elements → MessageEntity objects - `` elements → InlineKeyboardMarkup - `