Answer the question
In order to leave comments, you need to log in
How can I make it so that the text is not displayed 2 times?
users = [id1]
@bot.message_handler(func=lambda message: message.chat.id not in users)
def CheckUser(message):
bot.send_message(message.chat.id, "Привет.")
@bot.message_handler(func=lambda message: message.chat.id in users)
def CheckUser(message):
bot.send_message(message.chat.id, "Чтобы начать работу с программой введите /command ")
if message.text == '/command':
bot.send_message(message.chat.id, 'Все прошло успешно')
else:
bot.send_message(message.chat.id, 'Извините, я не понял команду. Чтобы начать работу с программой введите /command ')
bot.polling(none_stop=True, interval=0)
Answer the question
In order to leave comments, you need to log in
If you want to cram everything into one message, use variables and send everything at the very end. JS implementation:
function Checkuser(message) {
let answer = 'Чтобы начать работу с программой введите /command';
if (message.text === '/command') {
answer += '\nВсе прошло успешно';
} else{
answer += '\nИзвините, я не понял команду. Чтобы начать работу с программой введите /command';
}
bot.sendMessage(chatId, answer);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question