2018-06-23 01:00:43 +02:00
|
|
|
"""
|
|
|
|
.. moduleauthor:: Fabio Manganiello <blacklight86@gmail.com>
|
|
|
|
"""
|
|
|
|
|
2018-03-21 23:21:41 +01:00
|
|
|
from platypush.context import get_backend
|
2020-01-19 16:21:29 +01:00
|
|
|
from platypush.plugins import action
|
|
|
|
from platypush.plugins.assistant import AssistantPlugin
|
2018-03-21 23:21:41 +01:00
|
|
|
|
2020-01-19 16:21:29 +01:00
|
|
|
|
|
|
|
class AssistantGooglePlugin(AssistantPlugin):
|
2018-06-23 01:00:43 +02:00
|
|
|
"""
|
|
|
|
Google assistant plugin.
|
|
|
|
It acts like a wrapper around the :mod:`platypush.backend.assistant.google`
|
|
|
|
backend to programmatically control the conversation status.
|
|
|
|
"""
|
|
|
|
|
2020-01-19 16:21:29 +01:00
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super().__init__(**kwargs)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _get_assistant():
|
|
|
|
return get_backend('assistant.google')
|
2018-07-06 02:08:38 +02:00
|
|
|
|
|
|
|
@action
|
2018-03-21 23:21:41 +01:00
|
|
|
def start_conversation(self):
|
2018-06-23 01:00:43 +02:00
|
|
|
"""
|
|
|
|
Programmatically start a conversation with the assistant
|
|
|
|
"""
|
2020-01-19 16:21:29 +01:00
|
|
|
assistant = self._get_assistant()
|
2018-03-21 23:21:41 +01:00
|
|
|
assistant.start_conversation()
|
|
|
|
|
2018-07-06 02:08:38 +02:00
|
|
|
@action
|
2018-03-21 23:21:41 +01:00
|
|
|
def stop_conversation(self):
|
2018-06-23 01:00:43 +02:00
|
|
|
"""
|
|
|
|
Programmatically stop a running conversation with the assistant
|
|
|
|
"""
|
2020-01-19 16:21:29 +01:00
|
|
|
assistant = self._get_assistant()
|
2018-03-21 23:21:41 +01:00
|
|
|
assistant.stop_conversation()
|
2018-07-06 02:08:38 +02:00
|
|
|
|
2020-01-19 16:21:29 +01:00
|
|
|
@action
|
|
|
|
def pause_detection(self):
|
|
|
|
assistant = self._get_assistant()
|
|
|
|
assistant.pause_detection()
|
|
|
|
|
|
|
|
@action
|
|
|
|
def resume_detection(self):
|
|
|
|
assistant = self._get_assistant()
|
|
|
|
assistant.resume_detection()
|
|
|
|
|
|
|
|
@action
|
|
|
|
def is_detecting(self) -> bool:
|
|
|
|
assistant = self._get_assistant()
|
|
|
|
return assistant.is_detecting()
|
|
|
|
|
2018-03-21 23:21:41 +01:00
|
|
|
|
|
|
|
# vim:sw=4:ts=4:et:
|