I’m making a telegram bot, that attempting to find other bots, channels, etc.
But i have got this error:
<code>Traceback (most recent call last):
File "/data/data/com.termux/files/home/programs/antiscamer.py", line 29, in <module>
main()
File "/data/data/com.termux/files/home/programs/antiscamer.py", line 24, in main
dispatcher.add_handler(CommandHandler(filters.TEXT & ~filters.command, find_bot))
^^^^^^^^^^^^
AttributeError: module 'telegram.ext.filters' has no attribute 'TEXT'
</code>
<code>Traceback (most recent call last):
File "/data/data/com.termux/files/home/programs/antiscamer.py", line 29, in <module>
main()
File "/data/data/com.termux/files/home/programs/antiscamer.py", line 24, in main
dispatcher.add_handler(CommandHandler(filters.TEXT & ~filters.command, find_bot))
^^^^^^^^^^^^
AttributeError: module 'telegram.ext.filters' has no attribute 'TEXT'
</code>
Traceback (most recent call last):
File "/data/data/com.termux/files/home/programs/antiscamer.py", line 29, in <module>
main()
File "/data/data/com.termux/files/home/programs/antiscamer.py", line 24, in main
dispatcher.add_handler(CommandHandler(filters.TEXT & ~filters.command, find_bot))
^^^^^^^^^^^^
AttributeError: module 'telegram.ext.filters' has no attribute 'TEXT'
Its not a first error. With other errors i was fixing easily. But I have no idea how to fix this
Here’s my code:
<code>from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, filters, CallbackContext
import requests
from telegram.ext import *
TOKEN = '7138699736:AAH3JUCxwy8jApWOqojGRZ7wFmC1CfVkG3A'
def start(update: Update, context: CallbackContext) -> None:
update.message.reply_text('???? Привет, это AnstiScammer_bot!nВведите имя бота, которого нужно снести:')
def find_bot(update: Update, context: CallbackContext) -> None:
bot_name = update.message.text
response = requestsnget(f'https://api.telegram.org{TOKEN}/getChat?chat_id=@{bot_name}')
bot_data = response.json()
if bot_data.get('ok'):
update.message.reply_text(f'Информация о боте:n{bot_data["result"]}')
else:
update.message.reply_text('???? К сожалению, не удалось найти бота.nПроверьте правильность в названии бота или введите другое имя.')
def main() -> None:
updater = Updater(TOKEN)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandlr('start', start))
dispatcher.add_handler(CommandHandlr(filters.TEXT, filters.command, find_bot))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
</code>
<code>from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, filters, CallbackContext
import requests
from telegram.ext import *
TOKEN = '7138699736:AAH3JUCxwy8jApWOqojGRZ7wFmC1CfVkG3A'
def start(update: Update, context: CallbackContext) -> None:
update.message.reply_text('???? Привет, это AnstiScammer_bot!nВведите имя бота, которого нужно снести:')
def find_bot(update: Update, context: CallbackContext) -> None:
bot_name = update.message.text
response = requestsnget(f'https://api.telegram.org{TOKEN}/getChat?chat_id=@{bot_name}')
bot_data = response.json()
if bot_data.get('ok'):
update.message.reply_text(f'Информация о боте:n{bot_data["result"]}')
else:
update.message.reply_text('???? К сожалению, не удалось найти бота.nПроверьте правильность в названии бота или введите другое имя.')
def main() -> None:
updater = Updater(TOKEN)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandlr('start', start))
dispatcher.add_handler(CommandHandlr(filters.TEXT, filters.command, find_bot))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
</code>
from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, filters, CallbackContext
import requests
from telegram.ext import *
TOKEN = '7138699736:AAH3JUCxwy8jApWOqojGRZ7wFmC1CfVkG3A'
def start(update: Update, context: CallbackContext) -> None:
update.message.reply_text('???? Привет, это AnstiScammer_bot!nВведите имя бота, которого нужно снести:')
def find_bot(update: Update, context: CallbackContext) -> None:
bot_name = update.message.text
response = requestsnget(f'https://api.telegram.org{TOKEN}/getChat?chat_id=@{bot_name}')
bot_data = response.json()
if bot_data.get('ok'):
update.message.reply_text(f'Информация о боте:n{bot_data["result"]}')
else:
update.message.reply_text('???? К сожалению, не удалось найти бота.nПроверьте правильность в названии бота или введите другое имя.')
def main() -> None:
updater = Updater(TOKEN)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandlr('start', start))
dispatcher.add_handler(CommandHandlr(filters.TEXT, filters.command, find_bot))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
I was changing python-telegram-bot and telegram versions, and it’s all not worked. I have no idea what need to do 🙁
New contributor
Drttn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.