Answer the question
In order to leave comments, you need to log in
Why does Python only respond to the second message to the bot?
import telebot
import random
import pymorphy2
lst_1 = ["ПРИВЕТ", "КУ", "ЗДАРОВ", "ЗДАРОВА", "КУ-КУ", "КУ_КУ", "GHBDTN", "RE", "PLFHJD", "PLFHJDF","RE_RE", "RE-RE"]
lst_2 = ["Привет", "Здарова", "Ку-ку", "Хай", "Привет-привет", "Какая вствеча", "Приветствую вас", "Рад вас видеть", "Какая встреча"]
name = ""
guard = 0
bot = telebot.TeleBot("###")
@bot.message_handler(content_types = ["text", "document", "audio"])
def get_name(message):
global name
name = message.from_user.username
bot.register_next_step_handler(message, get_text_message)
def get_text_message(message):
global guard
if message.text.upper() in lst_1 or guard == 0:
guard = 1
bot.send_message(message.from_user.id, f"{lst_2[random.randint(0, len(lst_2))]}, {name}!")
else:
bot.send_message(message.from_user.id, "Придумайте что-нибудь другое, я вас не понимаю!")
bot.register_next_step_handler(message, get_text_message)
bot.polling(none_stop = True, interval = 0)
Answer the question
In order to leave comments, you need to log in
It is not entirely clear what you are sending him, would explain.
But you are using register_next_step_handler . If you use it, then you should understand what it is. And in that case your whole question seems very strange.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question