NextFunction¶
- class apitele.NextFunction[source]¶
You can return the instance of this class in a wrapped coroutine, to pass the
Updateto the next one.# myscript.py import asyncio from apitele import Client, NextFunction bot = Client('<your_api_token>') @bot.manage_message() async def foo(msg): print('I am foo!') return NextFunction() # you return this object and the # update is passed to the next coroutine. @bot.manage_message() async def bar(msg): print('I am bar!') # This coroutine will runs, because the # previous one returns a NextFunction object. @bot.manage_message() async def baz(msg): print('I am baz!') # This coroutine will never runs, because the # previous one doesn't return a NextFunction object. # Listen for updates... asyncio.run(bot.long_polling())
The following is the ouput in the shell when the bot receives a message
Update.$ python3 myscript.py I am foo! I am bar!
As you can see, foo() returns a
NextFunctionobject, so theUpdateis passed to bar().