I tried to implement the following line of code in python script for a telegram bot building using telebot.
@bot.message_handler(func=lambda msg:True if msg.text.startswith('/test'))
def test_start(message):
msg=bot.send_message(message.chat.id,'This is feature is under developement')
Above code gives me a syntax error.
@bot.message_handler(func=lambda msg:True if msg.text.startswith('/test') else False)
def test_start(message):
msg=bot.send_message(message.chat.id,'This is feature is under developement')
This code solves the syntax error, but still, it doesn't do what I want it to do. When a user sends '/test some text' I want to identify this and do some actions after that.
I am relatively new to python and this is my first time using telebot and lambda functions. So please help me in
- identifying why the 1st code gave me a syntax error.
- How to implement this startswith('/test') properly. Thank you so much in advance.
Aucun commentaire:
Enregistrer un commentaire