I got this error in telegram simple bot written in python

Viewed 83

hi every body i have this error when trying to emplement simple telegram bot

import telegram
import asyncio


async def main():
    bot = telegram.Bot("token")
    async with bot:
        print(await bot.get_me())
asyncio.run(main())

and this is my error message :

Traceback (most recent call last):
  File "/home/atabarzega/main.py", line 10, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/atabarzega/main.py", line 7, in main
    async with bot:
AttributeError: __aenter__

please help me .

1 Answers

check your python-telegram-bot package version, seems like you have 13.xx and trying to use documentaion from 20

Related