Answer the question
In order to leave comments, you need to log in
How to expand a possible telegram bot written in python (Varieties of answers)?
How to supplement this telegram bot so that when you enter certain phrases, a certain phrase is taken from the config folder. (Circled within the code, but with different data, both input and output).
@bot.message_handler(content_types=["text"])
def get_phrase(message):
if message.text == "Я не красивая":
bot.send_message(message.chat.id, random.choice(config.phrases))
else:
bot.send_message(message.chat.id, "Ятт")
Answer the question
In order to leave comments, you need to log in
Use the random library
import random as r
otvet = ["ты не тупой", "ты умный", "красавчик"] // значения
s_otvet = r.choice(start_words) // выбирает рандомно слова
@bot.message_handler(content_types=["text"])
def get_phrase(message):
if message.text == "Я не красивая":
bot.send_message(message.chat.id, s_otvet)
else:
bot.send_message(message.chat.id, "Ятт")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question