N
N
Nika9802022-02-18 11:27:22
Python
Nika980, 2022-02-18 11:27:22

How to write a telegram bot with commands through /?

How to make a bot with commands through / ?
I learned how to do with Inline and Reply button, but I need it to look like in this example, 620f58026e081391541431.jpegwithout buttons at all, but with commands like this. And so that these commands do not come up in the list. Just to poke and open something further.

Here is the beginning of the code, what's next?

import telebot;
import random;
from telebot import types;
bot = telebot.TeleBot('******************************')

@bot.message_handler(content_types=['text'])
def get_text_messages(message):

    bot.send_message(message.from_user.id, f" Добро пожаловать.")

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rayzl111, 2022-02-18
@Nika980

@bot.message_handler(content_types=['text'])

Change this to
@bot.message_handler(commands=[' Your command '])

And everything with a slash will work

N
Nikolay Savelyev, 2022-02-18
@AgentSmith

FatherBot has documentation,
everything is described here https://core.telegram.org/bots

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question