From be1cd97916a522267ba1790dcd47c7c3eed24228 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sat, 30 Apr 2022 19:22:10 +0200 Subject: [PATCH] Begin add search module --- brain.yml | 4 +++- brains/kill.yml | 7 +++++++ brains/search.yml | 9 +++++++++ resources/neurons/.gitignore | 4 ---- resources/neurons/search/.gitignore | 1 + resources/neurons/search/__init__.py | 1 + resources/neurons/search/search.py | 15 +++++++++++++++ 7 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 brains/kill.yml create mode 100644 brains/search.yml delete mode 100644 resources/neurons/.gitignore create mode 100644 resources/neurons/search/.gitignore create mode 100644 resources/neurons/search/__init__.py create mode 100644 resources/neurons/search/search.py diff --git a/brain.yml b/brain.yml index a411861..694145e 100755 --- a/brain.yml +++ b/brain.yml @@ -4,6 +4,8 @@ - brains/say.yml - brains/systemdate.yml - brains/neurotransmitter.yml + - brains/kill.yml + - brains/search.yml - name: "order-not-found-synapse" signals: [] @@ -32,6 +34,6 @@ signals: [] neurons: - say: - message: "je suis prête" + message: "je suis prêt" diff --git a/brains/kill.yml b/brains/kill.yml new file mode 100644 index 0000000..8dfbed4 --- /dev/null +++ b/brains/kill.yml @@ -0,0 +1,7 @@ +- name: "stop-kalliope" + signals: + - order: "stop" + neurons: + - say: + message: "Au revoir" + - kill_switch \ No newline at end of file diff --git a/brains/search.yml b/brains/search.yml new file mode 100644 index 0000000..d37488b --- /dev/null +++ b/brains/search.yml @@ -0,0 +1,9 @@ +- name: "search-fr" + signals: + - order: "recherche {{ search }}" + neurons: + - say: + message: + - "Recherche effectuée" + - search: + search: "{{search}}" \ No newline at end of file diff --git a/resources/neurons/.gitignore b/resources/neurons/.gitignore deleted file mode 100644 index 86d0cb2..0000000 --- a/resources/neurons/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore \ No newline at end of file diff --git a/resources/neurons/search/.gitignore b/resources/neurons/search/.gitignore new file mode 100644 index 0000000..ed8ebf5 --- /dev/null +++ b/resources/neurons/search/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/resources/neurons/search/__init__.py b/resources/neurons/search/__init__.py new file mode 100644 index 0000000..f8a70f7 --- /dev/null +++ b/resources/neurons/search/__init__.py @@ -0,0 +1 @@ +from .search import Search \ No newline at end of file diff --git a/resources/neurons/search/search.py b/resources/neurons/search/search.py new file mode 100644 index 0000000..ca8bc32 --- /dev/null +++ b/resources/neurons/search/search.py @@ -0,0 +1,15 @@ +import logging +import subprocess + +from kalliope.core import NeuronModule +from kalliope.core.NeuronModule import MissingParameterException + +class Search(NeuronModule): + def __init__(self, **kwargs): + super(Search, self).__init__(**kwargs) + + self.query = kwargs.get('search', None) + + if self.query is not None: + command = "xdg-open \"https://www.google.fr/search?q="+self.query+"&ie=utf-8&oe=utf-8\" &" + p = subprocess.Popen(command, shell=True)