An open API service indexing awesome lists of open source software.

https://github.com/evermake/tgx

JSX for Telegram messages.
https://github.com/evermake/tgx

jsx telegram telegram-bots

Last synced: about 1 month ago
JSON representation

JSX for Telegram messages.

Awesome Lists containing this project

README

        

![tgx](tgx.png)

Implementation of `jsx-runtime` to create Telegram messages using JSX.

## Installation

```sh
deno add jsr:@evermake/tgx
# or
npx jsr add @evermake/tgx
# or
pnpm dlx jsr add @evermake/tgx
# or
yarn dlx jsr add @evermake/tgx
# or
bunx jsr add @evermake/tgx
```

Then in your `tsconfig.json`:

```jsonc
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@evermake/tgx",
// ...
}
}
```

## Example

Usage with [grammY](https://grammy.dev):

```tsx
import { html } from '@evermake/tgx'
import { Bot } from 'grammy'

const Greeting = (props: { name: string }) => (
<>Hello, {props.name}!>
)

const bot = new Bot(/* TOKEN */)

bot.command('start', async (ctx) => {
await ctx.reply(
html(),
{ parse_mode: 'HTML' }
)
})

bot.start()
```

## License

[MIT](./LICENSE)