Answer the question
In order to leave comments, you need to log in
How to create condition text equals "/" + "random something" then... Python?
I am using pyTelegramBotAPI
import telebot I have
this code:
@bot.message_handler(content_types=["text"])
def any_msg(message):
if message.text == "/" + "random anything":
bot.send_message(message.from_user. id, "*good*", parse_mode="Markdown")
random_anything is written as an example, I suspect that there must be some function
Question: how to create such a function that if message.text equals "something" + "something -something random", or "something" + "number from 1 to 10"? How is it written in Python?
Answer the question
In order to leave comments, you need to log in
It's easier to check that if there is some text after /, then it is random (or maybe I misunderstood)
if '/' in message.text and len(message.text) > 1:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question