python-telegram
python-telegram copied to clipboard
async/await syntax
is it possible to use async/await with the library? if it is, does any have examples of usage? it will be greate for me)
Hi,
No, the library officially doesn't support async/await syntax, you'll have to write a wrapper if you want to use it.
After seeing this, I thought it should be possible to use async/await with tdlib. So I tried it and I managed to get a low-level async tdjson wrapper working; by low-level I mean:
await tdlib.send_request({'@type': 'sendMessage', ...})
However, looking at the current API of python-telegram and how it's implemented, I don't think it would be possible to support async/await and keep compatibility with the existing API...
Probably, it should be possible to have both the current synchronous client and a new async API, and the synchronous client could be migrated to use the new async-await API under the hood
This is what I wrote, in case it helps: https://gist.github.com/nicolas17/c8330da13512c9743a3da4b7c7688a3b