I get this exception: "Exception has occurred: AttributeError __aenter__" in line async with bot:. (I entered the token). Please help
import asyncio
import telegram
async def main():
bot = telegram.Bot("token")
async with bot:
print(await bot.get_me())
if __name__ == '__main__':
asyncio.run(main())
I found this code here: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Introduction-to-the-API
Think that's because you installed v13 (pip install python-telegram-bot) and the example you are looking at is from the v20 Github wiki.
Head over here for a quick start guide for v13 wrapper: https://github.com/python-telegram-bot/v13.x-wiki/wiki/Extensions-%E2%80%93-Your-first-Bot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With