# Telegram bot

{% hint style="info" %}
[**Puregram**](https://github.com/nitreojs/puregram) **- powerful and modern telegram bot api sdk for node.js and typescript 😁**
{% endhint %}

{% code overflow="wrap" %}

```typescript
import { Telegram } from "puregram";
import { HearManager } from "@puregram/hear";
import { EnkaNetwork } from "enkanetwork";

const bot = new Telegram({
    token: "SOME_SECRET_TOKEN",
});
const hearManager = new HearManager();
const enka = new EnkaNetwork();
const UID_REGEXP = /([1,2,5-9])\d{8}/;

bot.updates.on("message", hearManager.middleware);

// if message.text contains UID
hearManager.hear(UID_REGEXP, async (context) => {
    const user = await enka.fetchUser(context.text); // we will not invent the choice of language

    return context.send(
        `${user.player.nickname}'s characters list:\n\n` +
            user.characters
                .map(
                    (character) =>
                        `${character.name} (${character.rarity} ⭐) - ${character.level} level`
                )
                .join("\n")
    );
});

// else
bot.updates.on("message", (context) =>
    context.send(
        `Hi, ${context.from.firstName}! Write your uid from the Genshin Impact correctly`
    )
);

bot.updates.startPolling().then(() => console.log("[BOT] Bot was started"));

```

{% endcode %}

<figure><img src="/files/SitphPwdCoiVFAEFOPmY" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kravets.gitbook.io/enkanetwork/examples/telegram-bot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
