0.3.2 • Published 1 year ago
@telegum/tgx v0.3.2
Implementation of jsx-runtime to create Telegram messages using JSX.
Installation
npm i @telegum/tgxThen in your tsconfig.json:
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@telegum/tgx",
    // ...
  }
}Example
Usage with grammY:
import { html } from '@telegum/tgx'
import { Bot } from 'grammy'
const Greeting = (props: { name: string }) => (
  <>Hello, <b>{props.name}</b>!</>
)
const bot = new Bot(/* TOKEN */)
bot.command('start', async (ctx) => {
  await ctx.reply(
    html(<Greeting name={ctx.from.first_name} />),
    { parse_mode: 'HTML' }
  )
})
bot.start()