Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that @app.on_topic() cannot be used for topics that have dedicated decorators #180

Open
janekbettinger opened this issue Jan 2, 2022 · 0 comments

Comments

@janekbettinger
Copy link

janekbettinger commented Jan 2, 2022

The callbacks registered by the on_topic() decorator are currently processed last.
See

If a message on a topic for which a corresponding decorator exists (e.g. the on_intent decorator for the topic hermes/intent/<intent_name>) the topic callback is not executed at all.

Example:

@app.on_topic("hermes/intent/myIntent")
async def topic_callback(intent: NluIntent):
    # do something
    pass

The topic_callback is never called as

elif NluIntent.is_topic(topic):
matches first. In this case the intended callback topic_callback won't be found as it is not included in the _callbacks_intent but only in the _callbacks_topic dictionary.

This can be considered an expected behavior, but is not intuitive nevertheless, imho. Please document this limitation at least.

It would be even better, to change the overall behavior to allow subscribing to arbitrary topics with the on_topic decorator. This would even allow subscriptions for multiple intents as requested in #13 via @app.on_topic("hermes/intent/+"). Some rework of the overall message processing would be required though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant