I have this code..
import telebot
#telegram API
api_key = os.environ['Tele_API_key']
bot = telebot.TeleBot(api_key)
@bot.message_handler(commands=['start'])
def help_command(message):
bot.send_message(chat.id,"send a message")
@bot.message_handler(func = lambda msg: msg.text is not None and '/' not in msg.text)
if message.text == "Hi":
bot.send_message(chat.id,"Hello!")
It sends me "Hello" Everytime I send "Hi"
I want it to be like,
after I do /start
it should ask "send a message"
and when I send "Hello"
it should send "Hi"
But the problem is, it sends "Hi" everytime I send "Hello"
But I only want it to say "Hello" after I send /start and then the "Hi" message
I am beginner, Thanks for the help
2
Answers
You was created object msg inside @message_handler , But haven’t used it.
These are silly mistakes
Correct ✅
Final code
You can do like this
You can reply a message with
reply_to(message, "your reply text")