states={
MOB_NO: [MessageHandler(filters.text, reply_to)],
},
AttributeError: module ‘telegram.ext.filters’ has no attribute ‘text’
I install pip install python-telegram-bot.
And here we import module.
from telegram.ext import (Updater, CommandHandler, MessageHandler, filters,
ConversationHandler)
When we handle messages it says.
AttributeError: module ‘telegram.ext.filters’ has no attribute ‘text
3
Answers
try using this one
Most probably you are using the latest version package. Downgrade the python-telegram-bot version to 13.7.
And use "Filters" with capital F
From version 20 of python-telegram-bot, the filters library is lowercase and the single filters are written all uppercase.
So until v13.7 we had
Filters.text
, but from v20 it becamefilters.TEXT
.Maybe in your
requirements.txt
file you havepython-telegram-bot>=13.4
, so either you change it topython-telegram-bot==13.7
, or you need to update your code.Note that this applies also to the import, until v13.7: from
telegram.ext import Filters
becomestelegram.ext import filters
.Source: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Transition-guide-to-Version-20.0