I have written this code but it is not working
and I am getting an error
2021-03-03 18:08:35,602 - main - ERROR - Update ‘<telegram.ext.callbackcontext.CallbackContext object at 0x000001EC87D783A0>’ caused error ‘‘CallbackContext’ object has no attribute ‘message’’
import logging
from telegram.ext import Updater,CommandHandler,MessageHandler,Filters #filters for knowing what type of message is recieved
logging.basicConfig(level=logging.INFO,
format=’%(asctime)s - %(name)s - %(levelname)s - %(message)s’)
logger = logging.getLogger(name)
TOKEN = “1554677151:AAFN4A8TIVIMx2S00WhRBkDUe-iENeLSuJk”
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_txt = “hey! This is a help text.”
bot.send_message(chat_id=update.message.chat_id, text=help_txt)
def echo_text(bot,update):
bot.send_message(chat_id=update.message.chat_id, text=update.message.text)
bot.send_message(chat_id=update.message.chat_id, sticker=update.message.sticker.file_id)
def error(bot, update):
logger.error(“Update ‘%s’ caused error ‘%s’”, update, update.error)
def main():
#update will check is there any update in telegram and just pass it to dispatcher
#it requires the Token given by the bot father
updater=Updater(TOKEN)
#dispatcher will handle the updates
dp = updater.dispatcher
dp.add_handler(CommandHandler("start",start))
dp.add_handler(CommandHandler("help", _help))
#dp.add_handler(MessageHandler(Filters.text,echo_text))
#dp.add_handler(MessageHandler(Filters.sticker,echo_sticker))
dp.add_error_handler(error)
updater.start_polling()
logger.info("Started polling...")
updater.idle()
Creating a entry point for the program
if name == ‘main’:
main()