Skip to content
Advertisement

Receive the typed value from the user after the command in python telegram bot

For example, we have a command called a chart /chart Now I want to get the value that the user enters after this command

example: /chart 123456 now How should i get that 123456? This is the code used to create the command:

JavaScript

I read the python telegram bot documents but did not find what I was looking for

Advertisement

Answer

The code you provided is for when the user input the command /start.

Anyway, you can get the content of the input message directly from the Update and then split the message (because it returns everything that has been written, including the command itself) by the command and obtain the input arguments to the command, like this:

JavaScript

To make all working correctly, you will have to add a CommandHandler, like this:

JavaScript

In this way the output for /chart 12345 will be just 12345, as shown in the picture: command executed into the telegram chat

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement