luckydonald / pytg

Python package that wraps around Telegram messenger CLI. Send and receive messages, and more.
MIT License
369 stars 76 forks source link

Usage with asyncio #123

Open dendendd opened 7 years ago

dendendd commented 7 years ago

Working on a project where we want to both receive telegram messages and respond to user inputs

Wanted to see if there's a good way to incorporate this using coroutines / asyncio i.e. maybe wrap both the message_loop and user input polling in asyncio.async functions to manage concurrency

asyncio.async(user_input()) asyncio.async(message_loop()) asyncio.get_event_loop().run_forever()

Have done a bunch of test programs but getting stuck on reworking the stacked calls with receiver.message(message_loop(sender))... doesn't seem to like yielding control so far

Any ideas?

luckydonald commented 7 years ago

The message_loop function is a coroutine, if that helps you?