From e4c26e282fe423e6c57bf7dd79e5e80fac6952f8 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 11 Feb 2020 19:20:12 +0100 Subject: [PATCH] . --- .idea/workspace.xml | 34 +++++++++++++++++----------------- scripts/lib/jarvis.php | 22 +++++++++++----------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 30c7cc4..42dd302 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,8 @@ - - + @@ -1198,11 +1198,11 @@ - - + + - + @@ -1217,11 +1217,11 @@ - - + + - + diff --git a/scripts/lib/jarvis.php b/scripts/lib/jarvis.php index 1e68639..578f5c5 100644 --- a/scripts/lib/jarvis.php +++ b/scripts/lib/jarvis.php @@ -2,18 +2,18 @@ function jarvisCmd($question) { - $c = sshCommand('/usr/local/bin/jarvis -j -x "' . addcslashes($question, '"') . '"', 'jarvis'); + $c = sshCommand('/usr/local/bin/jarvis -j -x "' . addcslashes($question, '"') . '"', 'jarvis'); - $o=preg_replace('/[\x00-\x1F\x7F]/', '', $c['output']); - $j = json_decode(trim($o), true); + $o = preg_replace('/[\x00-\x1F\x7F]/', '', $c['output']); + $j = json_decode(trim($o), true); - if (!count($j)) { - return 'Désolé, il y a eu un problème !'; - } - foreach ($j as $k => $v) { - if (isset($v['answer'])) { - return $v['answer']; - } - } + if (!is_countable($j) || !count($j)) { + return 'Désolé, il y a eu un problème ! '.$c['output']; + } + foreach ($j as $k => $v) { + if (isset($v['answer'])) { + return $v['answer']; + } + } return 'Désolé, je crois qu\'il y a eu un affreux malentendu entre nous :('; } \ No newline at end of file -- 2.39.5