|
@@ -12,6 +12,7 @@ class Neurotransmitter(NeuronModule):
|
|
|
|
|
|
# get links
|
|
|
self.links = kwargs.get('links', None)
|
|
|
+ self.default = kwargs.get('default', None)
|
|
|
# do some check
|
|
|
if self._links_content_ok():
|
|
|
# the brain seems fine, we call the stt to get an audio
|
|
@@ -19,13 +20,18 @@ class Neurotransmitter(NeuronModule):
|
|
|
|
|
|
def callback(self, audio):
|
|
|
logger.debug("Neurotransmitter, receiver audio from STT: %s" % audio)
|
|
|
- print self.links
|
|
|
+ # print self.links
|
|
|
+ # set a bool to know if we have found a valid answer
|
|
|
+ found = False
|
|
|
for el in self.links:
|
|
|
if audio in el["answers"]:
|
|
|
- print "found"
|
|
|
+ found = True
|
|
|
self.run_synapse_ny_name(el["synapse"])
|
|
|
# we don't need to check to rest of answer
|
|
|
break
|
|
|
+ if not found:
|
|
|
+ # the answer do not correspond to any answer. We run the default synapse
|
|
|
+ self.run_synapse_ny_name(self.default)
|
|
|
|
|
|
def _links_content_ok(self):
|
|
|
"""
|
|
@@ -34,6 +40,8 @@ class Neurotransmitter(NeuronModule):
|
|
|
"""
|
|
|
if self.links is None:
|
|
|
raise MissingParameterException("links parameter required and must contain at least one link")
|
|
|
+ if self.default is None:
|
|
|
+ raise MissingParameterException("default parameter is required and must contain a valid synapse name")
|
|
|
for el in self.links:
|
|
|
if "synapse" not in el:
|
|
|
raise MissingParameterException("Links must contain a synapse name: %s" % el)
|