This is the code for the Telegram bot that I'm testing:
from typing import Finalfrom telegram import Updatefrom telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypesimport sys# function that implements the message handlerTOKEN: Final = 'BOT_TOKEN'BOT_USERNAME: Final = '@flissi_bot'# commandasync def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE): await update.message.reply_text("Hi! I'm pizza_bot . I can help you with your shopping needs.")async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE): await update.message.reply_text("Hi! I'm pizza_bot. tape somthing so i can help you.")async def custom_command(update: Update, context: ContextTypes.DEFAULT_TYPE): await update.message.reply_text("the a custon command.")# reponsesdef handel_responses(text: str) -> str: processed: str = text.lower() if 'hello' in processed: return 'hello' if 'how are you' in processed: return 'I am fine, thank you' if 'goodbye' in processed: return 'goodbye' if 'thank you' in processed: return 'you are welcome' return 'I do not understand you'async def handel_message(update: Update, context: ContextTypes.DEFAULT_TYPE): message_type: str = update.message.chat.type text: str = update.message.text print(f'User ({update.message.chat_id})in {message_type}: "{text}"') if message_type == 'group': if BOT_USERNAME in text: new_text: str = text.replace(BOT_USERNAME, '').strip() response: str = handel_responses(new_text) else: return else: response: str = handel_responses(text) print('Bot', response) await update.message.reply_text(response)async def error(update: Update, context: ContextTypes.DEFAULT_TYPE): print(f'Update "{update}" caused error "{context.error}"')if __name__ == '__main__': print('starting bot...') app = Application.builder().token(TOKEN).build() # commands app.add_handler(CommandHandler('start', start_command)) app.add_handler(CommandHandler('custom', custom_command)) app.add_handler(CommandHandler('help', help_command)) # Messages app.add_handler(MessageHandler(filters.Text, handel_message)) # Errors app.add_error_handler(error) # Poll the bot print('polling bot...') app.run_polling(poll_interval=3)I get the following error:
"Update(message=Message(channel_chat_created=False, chat=Chat(first_name='Flissi', id=6143267777, last_name='Hamed', type=<ChatType.PRIVATE>), date=datetime.datetime(2024, 5, 10, 2, 22, 59, tzinfo=datetime.timezone.utc), delete_chat_photo=False, from_user=User(first_name='Flissi', id=6143267777, is_bot=False, language_code='en', last_name='Hamed'), group_chat_created=False, message_id=28, supergroup_chat_created=False, text='hello'), update_id=589857240)" caused error "MessageFilter.check_update() missing 1 required positional argument: 'update'"can any one help?