forked from platypush/platypush
Set a plugin
argument on AssistantEvent
s besides assistant
.
`assistant` contains the assistant plugin object that triggered the event, but you can't create event hook conditions on attributes that are plugins. The event should also store a `plugin` attribute which contains the unique plugin name, so hooks like these can be built: ``` from platypush import hook from platypush.events.assistant import ConversationStartEvent @when(ConversationStartEvent, plugin="assistant.google") def on_google_conversation_start(): ... ``` It wouldn't be possible to construct a hook condition like the one above on the plugin object reported on the `assistant` attribute.
This commit is contained in:
parent
23e02de1d7
commit
4513bb9569
1 changed files with 1 additions and 3 deletions
|
@ -19,14 +19,12 @@ class AssistantEvent(Event):
|
||||||
"""
|
"""
|
||||||
assistant = assistant or kwargs.get('assistant')
|
assistant = assistant or kwargs.get('assistant')
|
||||||
if assistant:
|
if assistant:
|
||||||
assistant = (
|
kwargs['plugin'] = kwargs['_assistant'] = (
|
||||||
assistant
|
assistant
|
||||||
if isinstance(assistant, str)
|
if isinstance(assistant, str)
|
||||||
else get_plugin_name_by_class(assistant.__class__)
|
else get_plugin_name_by_class(assistant.__class__)
|
||||||
)
|
)
|
||||||
|
|
||||||
kwargs['_assistant'] = assistant
|
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in a new issue