import logging
from telegram.ext import Updater, CommandHandler, MessageHandler , Filters
logging.basicConfig(format = ‘%(asctime)s - %(name)s - %(levelname)s - %(message)s’, level = logging.INFO)
logger = logging.getLogger(name)
TOKEN = “1361877057:AAG9TySjrEKBIV9k3feY2WJZXcbsd7ToZqo”
def start(bot,update):
print(update)
author = update.message.from_user.first_name
reply = “Hi! {}”.format(author)
bot.send_message(chat_id = update.message.chat_id, text = reply)
def _help(bot,update):
help_text = “Hey! This is a help text. This chatbot is created by Srishti Jhunthra.”
bot.send_message(chat_id = update.message.chat_id, text = help_text)
def echo(bot,update):
reply = update.message.text
bot.send_message(chat_id = update.message.chat_id, text = reply)
def echo_sticker(bot,update):
bot.send_sticker(chat_id = update.message.chat_id, sticker = update.message.sticker.file_id)
def error(bot,update):
logger.error(“Update ‘%s’ has caused error ‘%s’”,update,update.error)
def main():
updater = Updater(TOKEN)
dp = updater.dispatcher
dp.add_handler(CommandHandler(“start”,start))
dp.add_handler(CommandHandler(“help”, _help)
dp.add_handler(MessageHandler(Filters.sticker, echo_sticker))
dp.add_handler(MessageHandler(Filters.text,echo))
dp.add_error_handler(error)
update.start_polling()
logger.info("Started polling....")
updater.idle()
if name == “main”:
main()
This is my telegram bot code. When I am running this code on my virtual machine. It says that there is a syntax error in:
dp.add_handler(MessageHandler(Filters.text,echo))
Can you please tell me why there is a syntax error here?