0

I'm using the sendMessage method from telegram api

I want to send something like this:

Some message some_text_for_command , another text.


When user will read this message from telegram bot, he can click on some_text_for_command and this action will generate message from user, which should looks like this:

/some_command with_text

Is is possible to realize something like this?

Because, when I try to use messageEntity is doesn't work:

curl --location --request POST 'https://api.telegram.org/bot{bot_code}/sendMessage' \
--header 'Content-Type: application/json' \
--data-raw '{
    "chat_id": 1,
    "text": "/some_command text, another text",
    "entities": [
        {
            "type" : "bot_command",
            "offset": 0,
            "length": 18
        }
    ]
}'

So telegram just parses message and gives an ability to click only on some_command, not for the command with the text. Also if I try to send message without \, it should parse it at all.

0stone0
  • 34,288
  • 4
  • 39
  • 64
Pavel
  • 918
  • 7
  • 18

1 Answers1

1

No, unfortunately this is not possible.


There are 2 ways to come somehow close to your desired output.

Option 1, command + keyboard

You could send a command without a parameter, like /some_command where in response on clicking that command you show a keyboard with the options available for some_text

Example image from documenatation on how the keyboard could look like: enter image description here

Option 2, inline-code + copy/paste

You could send an inline code block, on which the user can press to copy the whole command, this way the user just have to click and paste the command to the bot:

`/some_command some_text`

How to make that when you click on the text it was copied pytelegrambotapi

0stone0
  • 34,288
  • 4
  • 39
  • 64