From 24a0949b667404c456f091c48b63fe921ce0b709 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Fri, 24 Apr 2015 11:26:28 +0200 Subject: [PATCH] fixed case sensitive memory --- scripts/memoria.coffee | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/memoria.coffee b/scripts/memoria.coffee index 95df8b7..d167dee 100644 --- a/scripts/memoria.coffee +++ b/scripts/memoria.coffee @@ -1,7 +1,7 @@ module.exports = (robot) -> robot.respond /ricorda(?:ti)? (?:che )?(.+) [=è] (.+)/i, (res) -> mem = robot.brain.get('memoria') or {} - name = res.match[1]; definition = res.match[2] + name = res.match[1].toLowerCase(); definition = res.match[2] if mem[name]? res.send 'pensavo che '+name+' fosse '+mem[name]+'. Mi ricorderò che invece è '+definition else @@ -10,15 +10,17 @@ module.exports = (robot) -> robot.brain.set 'memoria', mem robot.respond /dimentica(?:ti)? (.+)/i, (res) -> mem = robot.brain.get('memoria') or {} - if mem[res.match[1]]? + m = res.match[1].toLowerCase() + if mem[m]? res.send 'cancellazione neuronale in corso...' - delete mem[res.match[1]] + delete mem[m] robot.brain.set 'memoria', mem # necessary? else res.send 'non so cosa sia' robot.respond /(?:che )?cos(?:\')?è (.+)/i, (res) -> mem = robot.brain.get('memoria') or {} - if mem[res.match[1]] - res.send res.match[1]+' è '+mem[res.match[1]] + m = res.match[1].toLowerCase() + if mem[m] + res.send m+' è '+mem[m] else res.send 'boh' robot.respond /memoria/i, (res) -> m = JSON.stringify robot.brain.get 'memoria'