From 84f3718ae441ab804142052ccb89e0eefe68bce6 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 6 Jul 2019 20:03:46 +0200 Subject: [PATCH] . --- .idea/workspace.xml | 113 ++++++++++++++++++++------------------- scripts/lib/jarvis.php | 1 + tools/jarvis/commands | 7 ++- tools/jarvis/console.php | 30 +++++++++++ 4 files changed, 93 insertions(+), 58 deletions(-) create mode 100644 tools/jarvis/console.php diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 54d8905..a4acf10 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,10 @@ + - - + + - @@ -1352,20 +1353,6 @@ - - - - - - - - - - - - - - @@ -1670,24 +1657,38 @@ + + + + + + + + + + + + + + - - + + - - + + - + - - + + diff --git a/scripts/lib/jarvis.php b/scripts/lib/jarvis.php index 2491246..1e68639 100644 --- a/scripts/lib/jarvis.php +++ b/scripts/lib/jarvis.php @@ -15,4 +15,5 @@ function jarvisCmd($question) return $v['answer']; } } + return 'Désolé, je crois qu\'il y a eu un affreux malentendu entre nous :('; } \ No newline at end of file diff --git a/tools/jarvis/commands b/tools/jarvis/commands index 9e26a08..f802ed3 100644 --- a/tools/jarvis/commands +++ b/tools/jarvis/commands @@ -1,5 +1,5 @@ *AIDE*==jv_display_commands -*BONJOUR*|*SALUT*==say "Bonjour $username" +*BONJOUR*|*SALUT*==say "Bonjour" *COMMENT*APPELLE*==say "Je m'appelle $trigger" *MERCI*==say "De rien" *AU REVOIR*|*BYE*==say "Au revoir $username"; jv_exit @@ -10,11 +10,14 @@ ENCORE*==jv_repeat_last_command *REPETE (*) ET (*)==say "(1) (2)" *WIFI*|*WI-FI*==say "Le nom du wifi est Tortuga et le mot de passe est z31a8bmd10kk6fqid3v0hq577z" *CA VA*==say "Très bien et toi ça va?" ->*OUI*==say "ravi de l'entendre" +>*OUI*|*SUPER*==say "ravi de l'entendre" +>*PAS MAL*==say "ouais, pareil, ça pourrait aller mieux !" >*NON*|*PAS*==say "j'en suis navré" *AU*LIT*==say "Bonne nuit" && jv_curl "https://entree.home.tortuga.enhydra.fr/scripts/light.php?scene=home/aulit&im" *ALLUME*LUMIERE*==say "J'allume tout" && jv_curl "https://entree.home.tortuga.enhydra.fr/scripts/light.php?scene=home/welcome&im" *ETEIN*MAISON*==say "J'éteins tout, à la prochaine" && jv_curl "https://entree.home.tortuga.enhydra.fr/scripts/light.php?scene=home/off&im" *SENS*VIE*==say "42" *RADIO*SALON*==say "D'accord, je mets FIP" && jv_curl "https://entree.home.tortuga.enhydra.fr/scripts/squeeze.php?player=Salon&name=FIP" +*INFO*==say "D'accord, j'allume franceinfo: (BFM, j'aime pas trop)" && jv_curl "https://entree.home.tortuga.enhydra.fr/scripts/squeeze.php?player=Salon&name=France%20Info" *ALERTE*==say "J'ai envoyé une notification lumineuse dans la maison" && jv_curl "https://entree.home.tortuga.enhydra.fr/scripts/light.php?scene=home/alert&im" +*REPLAY*==say "Ok, par contre, seul celui d'Arte passe des choses intéressantes. Je dis ça ..." && jv_curl "https://entree.home.tortuga.enhydra.fr/scripts/light.php?scene=home/alert&im" diff --git a/tools/jarvis/console.php b/tools/jarvis/console.php new file mode 100644 index 0000000..fb2713d --- /dev/null +++ b/tools/jarvis/console.php @@ -0,0 +1,30 @@ +#!/usr/bin/php +>> '; +cls(); +while (true) { + $stdin = fopen('php://stdin', 'r'); + $question = fread($stdin, 10000); + if (preg_match('/efface/', $question, $matches)) { + cls(); + continue; + } + if (preg_match('/exit/', $question, $matches)) { + echo getAnswer('bye'); + exit; + } + echo getAnswer($question) . "\n" . $input; +} + +function cls() +{ + global $input; + system('clear'); + echo $input; +} + +function getAnswer($question) +{ + $res = mb_strtoupper(file_get_contents('https://entree.home.tortuga.enhydra.fr/scripts/jarvis.php?question=' . rawurlencode($question))); + return $res; +} \ No newline at end of file -- 2.39.5