From 98d2325101d5f6829dd237c34fa9e9aaa8f8d2a3 Mon Sep 17 00:00:00 2001
From: Matheus Faria <matheus.sousa.faria@gmail.com>
Date: Tue, 6 Mar 2018 11:07:56 -0300
Subject: [PATCH] Fix crash with missing error nodes and high trust value

---
 scripts/bot/action-handler.coffee | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/bot/action-handler.coffee b/scripts/bot/action-handler.coffee
index 5680826..c52523f 100644
--- a/scripts/bot/action-handler.coffee
+++ b/scripts/bot/action-handler.coffee
@@ -21,10 +21,17 @@ actionHandler.registerActions = (config) ->
     if name.substr(0, 5) == "error"
       err_nodes++
 
+  if err_nodes == 0
+    console.log("WARNING! You don't have any error nodes, you need at least " +
+                "one to garantee that the bot always will respond something")
+
 actionHandler.errorNodesCount = () ->
   return err_nodes
 
 actionHandler.takeAction = (name, res) ->
-  nodes[name].process(res)
+  if not name?
+    res.sendWithNaturalDelay "I'm sorry Dave, I'm afraid I can't do that =/"
+  else
+    nodes[name].process(res)
 
 module.exports = actionHandler
-- 
GitLab