CactusDev / CactusBot

An open source, community-written service-agnostic chat bot
MIT License
30 stars 6 forks source link

Generator handlers #254

Closed 2Cubed closed 6 years ago

2Cubed commented 7 years ago

The ability to yield in handle methods. Requires asynchronous generators in Python 3.6.

In [1]: class FutureHandler(Handler):
   ...:     async def on_message(self, packet):
   ...:         if "future" in packet:
   ...:             yield "See you in the future!"
   ...:             await asyncio.sleep(60)
   ...:             yield "Hey, look, it's the future!"
Innectic commented 7 years ago

Merging #253 to here.