E
E
enabl32018-03-12 11:53:05
Python
enabl3, 2018-03-12 11:53:05

How to give a command to a bot without a slash "/"?

Hello everyone, in general, the question is clear.
How can I ask the bot to execute a command without using a slash, be it a single word or a phrase where there is a command?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikita, 2018-03-12
@enabl3

If you want to display this command in the command menu, then no way. Also, it will not be possible to make a command without a slash a link. If a command without a slash is strongly needed (it's not very clear why), you can process a text message and check that the text begins or is equal to the command name. Python example:

def text_handler(bot, update):
  if update.message.text.startswith("hello"):
    update.reply_text("Hello User!")

U
Uno, 2018-03-13
@Noizefan

The question was created, apparently, without marking which bible TS uses to work with api. Here it needs to be modified, according to the standard, they only process all slash commands. When parsing json from webhook requests, the bot receives ALL messages in general, do whatever you want.

R
Roman Katzendorn, 2018-03-24
@localhostunix

for pytelegrambotapi
@bot.message_handler(regexp='zapis')
def zapis(message):
msg = bot.send_message(message.chat.id, message.chat.id)
pass

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question