From 060cc55ff7d58f073ebbf04506954d055b2d4e5c Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Fri, 21 Feb 2020 10:12:00 +0530 Subject: [PATCH 01/16] Update keys.coffee --- scripts/keys.coffee | 290 +++++++++++++++++++++++++++++++++----------- 1 file changed, 221 insertions(+), 69 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index 39237b0..d4d0bc1 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -10,95 +10,247 @@ # bot xyz has keys : sets xyz as the holder of keys # # Examples: -# :bot who has keys -# :bot i have keys -# :bot i dont have keys -# :bot who has keys -# :bot ravi has keys +# :bot who has keys +# :bot i have keys +# :bot i dont have keys +# :bot who has keys +# :bot ravi has keys # # Author: # Punit Dhoot (@pdhoot) -# Developer at SDSLabs (@sdslabs) +# Developer at SDSLabs (@sdslabs +# Edit: +# prakhar gupta + module.exports = (robot)-> - key = ()-> - Key = robot.brain.get("key") or "" - robot.brain.set("key" ,Key) - Key + keyRed = ()-> + Key1 = robot.brain.get("keyRed") or "" + robot.brain.set("keyRed",Key1) + Key1 + keyBlue = ()-> + Key1 = robot.brain.get("keyBlue") or "" + robot.brain.set("keyBlue",Key2) + Key2 + keyYellow = ()-> + Key1 = robot.brain.get("keyYellow") or "" + robot.brain.set("keyYellow",Key3) + Key3 + keyGreen = ()-> + Key1 = robot.brain.get("keyGreen") or "" + robot.brain.set("keyGreen",Key4) + Key4 + keyOrange = ()-> + Key1 = robot.brain.get("keyOrange") or "" + robot.brain.set("keyOrange",Key5) + Key5 - - robot.respond /i have (a key|the key|key|keys)/i, (msg)-> + #1this section belongs to "i have keys" + robot.respond /i (have the|have) (.+) (key|keys)/i, (msg)-> + keyname = msg.match[2] name = msg.message.user.name user = robot.brain.userForName name - k = key() - if typeof user is 'object' - msg.send "Okay #{name} has keys" - k = user.name - robot.brain.set("key",k) - + unless keyname not in ["red", "blue", "yellow", "green", "orange"] + if keyname is 'red' + key_holder = keyRed() + key_holder = user.name + robot.brain.set("keyRed",key_holder) + else if keyname is 'blue' + key_holder = keyBlue() + key_holder = user.name + robot.brain.set("keyBlue",key_holder) + else if keyname is 'Yellow' + key_holder = keyYellow() + key_holder = user.name + robot.brain.set("keyYellow",key_holder) + else if keyname is 'Green' + key_holder = keyGreen() + key_holder = user.name + robot.brain.set("keyGreen",key_holder) + else if keyname is 'orange' + key_holder = keyOrange() + key_holder = user.name + robot.brain.set("keyOrange",key_holder) + if typeof user is 'object' + msg.send "Okay #{name} has #{keyname} keys" - robot.respond /i (don\'t|dont|do not) (has|have) (the key|key|keys|a key)/i , (msg)-> + #2this section belongs to "i dont have key" + robot.respond /i (do not|don\'t|dont) (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> + keyname = msg.match[3] name = msg.message.user.name user = robot.brain.userForName name - k = key() - if k is name - k = "" - if typeof user is 'object' - if k is "" - msg.send "Okay #{name} doesn't have keys. Who got the keys then?" - else - msg.send "Yes , i know buddy, its because #{k} has got the keys" - robot.brain.set("key",k) - + unless keyname not in ["red", "blue", "yellow", "green", "orange"] + if keyname is 'red' + key_holder = keyRed() + if key_holder is name + key_holder = "" + robot.brain.set("keyRed",key_holder) + else if keyname is 'blue' + key_holder = keyBlue() + if key_holder is name + key_holder = "" + robot.brain.set("keyBlue",key_holder) + else if keyname is 'yellow' + key_holder = keyYellow() + if key_holder is name + key_holder = "" + robot.brain.set("keyYellow",key_holder) + else if keyname is 'green' + key_holder = keyGreen() + if key_holder is name + key_holder = "" + robot.brain.set("keyGreen",key_holder) + else if keyname is 'orange' + key_holder = keyOrange() + if key_holder is name + key_holder = "" + robot.brain.set("keyOrange",key_holder) + if typeof user is 'object' + if key_holder is "" + msg.send "Okay #{name} doesn't have #{keyname} keys. Who got the #{keyname} keys then?" + else + msg.send "Yes , I know buddy, its because #{key_holder} has got the #{keyname} keys" - robot.respond /(.+) (has|have) (the key|key|keys|a key)/i , (msg)-> + #3this section belongs to "$name has keys" + robot.respond /(.+) (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> othername = msg.match[1] + keyname = msg.match[3] name = msg.message.user.name - k = key() unless othername in ["who", "who all","Who", "Who all" , "i" , "I" , "i don't" , "i dont" , "i do not" , "I don't" , "I dont" , "I do not"] - if othername is 'you' - msg.send "How am I supposed to take those keys? #{name} is a liar!" - else if othername is robot.name - msg.send "How am I supposed to take those keys? #{name} is a liar!" - else - users = robot.brain.usersForFuzzyName othername - if users.length is 1 - robot.brain.set "key", users[0].name - msg.send "Okay, so now the keys are with #{users[0].name}" - else if users.length > 1 - msg.send getAmbiguousUserText users + unless keyname not in ["red", "blue", "yellow", "green", "orange"] + users = robot.brain.userForName othername + if users is null + key_holder = null else - msg.send "#{othername}? Never heard of 'em" - - robot.respond /(i|I) (have given|gave|had given) (the key|key|keys|a key|the keys) to (.+)/i , (msg)-> - othername = msg.match[4] + key_holder = users.name + if key_holder is null + if othername is 'you' + msg.send "How am I supposed to take those #{keyname} keys? #{name} is a liar!" + else if othername is robot.name + msg.send "That's utter lies! How can you blame a bot to have the keys?" + else + msg.send "I don't know anyone by the name #{othername}" + else + if keyname is 'red' + robot.brain.set("keyRed",key_holder) + else if keyname is 'blue' + robot.brain.set("keyBlue",key_holder) + else if keyname is 'yellow' + robot.brain.set("keyYellow",key_holder) + else if keyname is 'green' + robot.brain.set("keyGreen",key_holder) + else if keyname is 'orange' + robot.brain.set("keyOrange",key_holder) + msg.send "Okay, so now the #{keyname} keys are with #{othername}" + #4this section belongs to "i gave the keys to $name" + robot.respond /(i|I) (have given the|had given the|have given|gave the|had given|gave) (.+) (key|keys) to (.+)/i , (msg)-> + othername = msg.match[5] + keyname = msg.match[3] name = msg.message.user.name - k = key() - if othername is 'you' - msg.send "That's utter lies! How can you blame a bot to have the keys?" - else if othername is robot.name - msg.send "That's utter lies! How can you blame a bot to have the keys?" - else + unless keyname not in ["red", "blue", "yellow", "green", "orange"] users = robot.brain.userForName othername if users is null - msg.send "I don't know anyone by the name #{othername}" + key_holder = null else - k = users.name - msg.send "Okay, so now the keys are with #{users.name}" - - robot.brain.set("key",k) - - robot.respond /(who|who all) (has|have) (the key|key|keys|a key)/i , (msg)-> - k = key() - msgText = k + key_holder = users.name + if key_holder is null + if othername is 'you' + msg.send "That's utter lies! How can you blame a bot to have the keys? #{name} is a liar!" + else if othername is robot.name + msg.send "That's utter lies! How can you blame a bot to have the keys?" + else + msg.send "I don't know anyone by the name #{othername}" + else + if keyname is 'red' + robot.brain.set("keyRed",key_holder) + else if keyname is 'blue' + robot.brain.set("keyBlue",key_holder) + else if keyname is 'yellow' + robot.brain.set("keyYellow",key_holder) + else if keyname is 'green' + robot.brain.set("keyGreen",key_holder) + else if keyname is 'orange' + robot.brain.set("keyOrange",key_holder) + msg.send "Okay, so now the #{keyname} keys are with #{users.name}" + + #5this section is to print the details about the key holder. + robot.respond /who (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> + keyname = msg.match[2] + if keyname is 'red' + key_holder = keyRed() + msgText = key_holder + if msgText is "" + msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" + else + msgText+=" has red keys" + msg.send msgText + robot.brain.set("keyRed" ,key_holder) + else if keyname is 'blue' + key_holder = keyBlue() + msgText = key_holder + if msgText is "" + msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" + else + msgText+=" has blue keys" + msg.send msgText + robot.brain.set("keyBlue" ,key_holder) + else if keyname is 'yellow' + key_holder = keyYellow() + msgText = key_holder + if msgText is "" + msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" + else + msgText+=" has yellow keys" + msg.send msgText + robot.brain.set("keyYellow" ,key_holder) + else if keyname is 'green' + key_holder = keyGreen() + msgText = key_holder + if msgText is "" + msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" + else + msgText+=" has green keys" + msg.send msgText + robot.brain.set("keyGreen" ,key_holder) + else if keyname is 'orange' + key_holder = keyOrange() + msgText = key_holder + if msgText is "" + msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" + else + msgText+=" has orange keys" + msg.send msgText + robot.brain.set("keyOrange" ,key_holder) + robot.respond /who (has the|have the|has|have) (key|keys)/i , (msg)-> + key_holder1 = keyRed() + key_holder2 = keyBlue() + key_holder3 = keyYellow() + key_holder4 = keyGreen() + key_holder5 = keyOrange() + msgText="" + if key_holder1 != "" + msgText+=key_holder1 + msgText+=" has red keys.\n" + if key_holder2 != "" + msgText+=key_holder2 + msgText+=" has blue keys.\n" + if key_holder3 != "" + msgText+=key_holder3 + msgText+=" has yellow keys.\n" + if key_holder4 != "" + msgText+=key_holder3 + msgText+=" has green keys.\n" + if key_holder5 != "" + msgText+=key_holder3 + msgText+=" has orange keys.\n" if msgText is "" - msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" + msg.send "Ah! Nobody informed me about any keys. Don't hold me responsible for this :expressionless:" else - msgText+=" has keys" - msg.send msgText - robot.brain.set("key" ,k) - -getAmbiguousUserText = (users) -> - "Be more specific, I know #{users.length} people named like that: #{(user.name for user in users).join(", ")}" - + msg.send msgText + robot.brain.set("keyRed" ,key_holder1) + robot.brain.set("keyBlue" ,key_holder2) + robot.brain.set("keyYellow" ,key_holder3) + robot.brain.set("keyGreen" ,key_holder2) + robot.brain.set("keyOrange" ,key_holder2) + From f72ee0ec0f7406aa9bace9ae09e4a234d9e7c5a9 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Fri, 21 Feb 2020 10:18:43 +0530 Subject: [PATCH 02/16] Update keys.coffee --- scripts/keys.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index d4d0bc1..134a022 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -30,19 +30,19 @@ module.exports = (robot)-> robot.brain.set("keyRed",Key1) Key1 keyBlue = ()-> - Key1 = robot.brain.get("keyBlue") or "" + Key2 = robot.brain.get("keyBlue") or "" robot.brain.set("keyBlue",Key2) Key2 keyYellow = ()-> - Key1 = robot.brain.get("keyYellow") or "" + Key3 = robot.brain.get("keyYellow") or "" robot.brain.set("keyYellow",Key3) Key3 keyGreen = ()-> - Key1 = robot.brain.get("keyGreen") or "" + Key4 = robot.brain.get("keyGreen") or "" robot.brain.set("keyGreen",Key4) Key4 keyOrange = ()-> - Key1 = robot.brain.get("keyOrange") or "" + Key5 = robot.brain.get("keyOrange") or "" robot.brain.set("keyOrange",Key5) Key5 From 9aed8d7474112dcafe0a0fb53e15638b6721897c Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Fri, 21 Feb 2020 19:44:42 +0530 Subject: [PATCH 03/16] Update keys.coffee --- scripts/keys.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index 134a022..804f777 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -239,10 +239,10 @@ module.exports = (robot)-> msgText+=key_holder3 msgText+=" has yellow keys.\n" if key_holder4 != "" - msgText+=key_holder3 + msgText+=key_holder4 msgText+=" has green keys.\n" if key_holder5 != "" - msgText+=key_holder3 + msgText+=key_holder5 msgText+=" has orange keys.\n" if msgText is "" msg.send "Ah! Nobody informed me about any keys. Don't hold me responsible for this :expressionless:" From 253da753fd707cb7b13764b62e865f3281b3dd12 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Sun, 23 Feb 2020 00:06:54 +0530 Subject: [PATCH 04/16] Update keys.coffee --- scripts/keys.coffee | 182 +++++++++++++++++++++++++++++--------------- 1 file changed, 122 insertions(+), 60 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index 804f777..40a6e76 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -30,19 +30,19 @@ module.exports = (robot)-> robot.brain.set("keyRed",Key1) Key1 keyBlue = ()-> - Key2 = robot.brain.get("keyBlue") or "" + Key1 = robot.brain.get("keyBlue") or "" robot.brain.set("keyBlue",Key2) Key2 keyYellow = ()-> - Key3 = robot.brain.get("keyYellow") or "" + Key1 = robot.brain.get("keyYellow") or "" robot.brain.set("keyYellow",Key3) Key3 keyGreen = ()-> - Key4 = robot.brain.get("keyGreen") or "" + Key1 = robot.brain.get("keyGreen") or "" robot.brain.set("keyGreen",Key4) Key4 keyOrange = ()-> - Key5 = robot.brain.get("keyOrange") or "" + Key1 = robot.brain.get("keyOrange") or "" robot.brain.set("keyOrange",Key5) Key5 @@ -76,41 +76,45 @@ module.exports = (robot)-> msg.send "Okay #{name} has #{keyname} keys" #2this section belongs to "i dont have key" - robot.respond /i (do not|don\'t|dont) (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> - keyname = msg.match[3] + robot.respond /i (do not|don\'t|dont) (has the|have the|has|have) (key|keys)/i , (msg)-> name = msg.message.user.name user = robot.brain.userForName name - unless keyname not in ["red", "blue", "yellow", "green", "orange"] - if keyname is 'red' - key_holder = keyRed() - if key_holder is name - key_holder = "" - robot.brain.set("keyRed",key_holder) - else if keyname is 'blue' - key_holder = keyBlue() - if key_holder is name - key_holder = "" - robot.brain.set("keyBlue",key_holder) - else if keyname is 'yellow' - key_holder = keyYellow() - if key_holder is name - key_holder = "" - robot.brain.set("keyYellow",key_holder) - else if keyname is 'green' - key_holder = keyGreen() - if key_holder is name - key_holder = "" - robot.brain.set("keyGreen",key_holder) - else if keyname is 'orange' - key_holder = keyOrange() - if key_holder is name - key_holder = "" - robot.brain.set("keyOrange",key_holder) - if typeof user is 'object' - if key_holder is "" - msg.send "Okay #{name} doesn't have #{keyname} keys. Who got the #{keyname} keys then?" - else - msg.send "Yes , I know buddy, its because #{key_holder} has got the #{keyname} keys" + key_holder1 = keyRed() + key_holder2 = keyBlue() + key_holder3 = keyYellow() + key_holder4 = keyGreen() + key_holder5 = keyOrange() + if name is key_holder1 + key_holder1 = "" + robot.brain.set("keyRed",key_holder1) + msg.send "Okay #{name} doesn't have Red keys. Who got the Red keys then?" + else if name is key_holder2 + key_holder2 = "" + robot.brain.set("keyBlue",key_holder2) + msg.send "Okay #{name} doesn't have Blue keys. Who got the Blue keys then?" + else if name is key_holder3 + key_holder3 = "" + robot.brain.set("keyYellow",key_holder3) + msg.send "Okay #{name} doesn't have Yellow keys. Who got the Yellow keys then?" + else if name is key_holder4 + key_holder4 = "" + robot.brain.set("keyGreen",key_holder4) + msg.send "Okay #{name} doesn't have Green keys. Who got the green keys then?" + else if name is key_holder5 + key_holder5 = "" + robot.brain.set("keyOrange",key_holder5) + msg.send "Okay #{name} doesn't have orange keys. Who got the orange keys then?" + else if typeof user is 'object' + if key_holder1 is not "" + msg.send "Yes , I know buddy, its because #{key_holder1} has got the Red keys\n" + if key_holder2 is not "" + msg.send "Yes , I know buddy, its because #{key_holder2} has got the Blue keys\n" + if key_holder3 is not "" + msg.send "Yes , I know buddy, its because #{key_holder3} has got the yellow keys\n" + if key_holder4 is not "" + msg.send "Yes , I know buddy, its because #{key_holder4} has got the green keys\n" + if key_holder5 is not "" + msg.send "Yes , I know buddy, its because #{key_holder5} has got the orange keys\n" #3this section belongs to "$name has keys" robot.respond /(.+) (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> @@ -144,37 +148,95 @@ module.exports = (robot)-> robot.brain.set("keyOrange",key_holder) msg.send "Okay, so now the #{keyname} keys are with #{othername}" #4this section belongs to "i gave the keys to $name" - robot.respond /(i|I) (have given the|had given the|have given|gave the|had given|gave) (.+) (key|keys) to (.+)/i , (msg)-> - othername = msg.match[5] - keyname = msg.match[3] + robot.respond /(i|I) (have given the|had given the|have given|gave the|had given|gave) (key|keys) to (.+)/i , (msg)-> + othername = msg.match[4] name = msg.message.user.name - unless keyname not in ["red", "blue", "yellow", "green", "orange"] - users = robot.brain.userForName othername + key_holder1 = keyRed() + key_holder2 = keyBlue() + key_holder3 = keyYellow() + key_holder4 = keyGreen() + key_holder5 = keyOrange() + keyname="" + users = robot.brain.userForName othername + if name is key_holder1 + if users is null + key_holder1 = null + robot.brain.set("keyRed",key_holder1) + keyname="Red" + else + key_holder1 = users.name + robot.brain.set("keyRed",key_holder1) + keyname="Red" + else if name is key_holder2 if users is null - key_holder = null + key_holder2 = null + robot.brain.set("keyBlue",key_holder2) + keyname="Blue" else - key_holder = users.name - if key_holder is null + key_holder2 = users.name + robot.brain.set("keyBlue",key_holder2) + keyname="Blue" + else if name is key_holder3 + if users is null + key_holder3 = null + robot.brain.set("keyYellow",key_holder3) + keyname="yellow" + else + key_holder3 = users.name + robot.brain.set("keyYellow",key_holder3) + keyname="yellow" + else if name is key_holder4 + if users is null + key_holder4 = null + robot.brain.set("keyGreen",key_holder4) + keyname="green" + else + key_holder4 = users.name + robot.brain.set("keyGreen",key_holder4) + keyname="green" + else if name is key_holder5 + if users is null + key_holder5 = null + robot.brain.set("keyOrange",key_holder5) + keyname="orange" + else + key_holder5 = users.name + robot.brain.set("keyOrange",key_holder5) + keyname="orange" + if key_holder1 is null or key_holder2 is null or key_holder3 is null or key_holder4 is null or key_holder5 is null if othername is 'you' msg.send "That's utter lies! How can you blame a bot to have the keys? #{name} is a liar!" else if othername is robot.name msg.send "That's utter lies! How can you blame a bot to have the keys?" else msg.send "I don't know anyone by the name #{othername}" - else - if keyname is 'red' - robot.brain.set("keyRed",key_holder) - else if keyname is 'blue' - robot.brain.set("keyBlue",key_holder) - else if keyname is 'yellow' - robot.brain.set("keyYellow",key_holder) - else if keyname is 'green' - robot.brain.set("keyGreen",key_holder) - else if keyname is 'orange' - robot.brain.set("keyOrange",key_holder) + robot.brain.set("keyOrange",key_holder5) + else msg.send "Okay, so now the #{keyname} keys are with #{users.name}" - - #5this section is to print the details about the key holder. + #5this section is for commands -> {i} dont have the keys + robot.respond /(.+) (do not|don\'t|dont) (has the|have the|has|have) (key|keys)/i , (msg)-> + othername = msg.match[1] + key_holder1 = keyRed() + key_holder2 = keyBlue() + key_holder3 = keyYellow() + key_holder4 = keyGreen() + key_holder5 = keyOrange() + if othername is key_holder1 + robot.brain.set("keyRed" ,key_holder1) + msg.send "Okay, so now the Red keys are with #{othername}" + else if othername is key_holder2 + robot.brain.set("keyBlue" ,key_holder1) + msg.send "Okay, so now the Blue keys are with #{othername}" + else if othername is key_holder3 + robot.brain.set("keyYellow" ,key_holder1) + msg.send "Okay, so now the yellow keys are with #{othername}" + else if othername is key_holder4 + robot.brain.set("keyGreen" ,key_holder1) + msg.send "Okay, so now the green keys are with #{othername}" + else if othername is key_holder5 + robot.brain.set("keyOrange" ,key_holder1) + msg.send "Okay, so now the orange keys are with #{othername}" + #6this section is to print the details about the key holder. robot.respond /who (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> keyname = msg.match[2] if keyname is 'red' @@ -239,10 +301,10 @@ module.exports = (robot)-> msgText+=key_holder3 msgText+=" has yellow keys.\n" if key_holder4 != "" - msgText+=key_holder4 + msgText+=key_holder3 msgText+=" has green keys.\n" if key_holder5 != "" - msgText+=key_holder5 + msgText+=key_holder3 msgText+=" has orange keys.\n" if msgText is "" msg.send "Ah! Nobody informed me about any keys. Don't hold me responsible for this :expressionless:" From 2e01bef121f07c8840f70fca25b98a0b93a9007d Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Wed, 26 Feb 2020 08:42:47 +0530 Subject: [PATCH 05/16] Update keys.coffee --- scripts/keys.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index 40a6e76..cee3a48 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -20,7 +20,7 @@ # Punit Dhoot (@pdhoot) # Developer at SDSLabs (@sdslabs # Edit: -# prakhar gupta +# Prakhar Gupta at Mdg module.exports = (robot)-> @@ -30,19 +30,19 @@ module.exports = (robot)-> robot.brain.set("keyRed",Key1) Key1 keyBlue = ()-> - Key1 = robot.brain.get("keyBlue") or "" + Key2 = robot.brain.get("keyBlue") or "" robot.brain.set("keyBlue",Key2) Key2 keyYellow = ()-> - Key1 = robot.brain.get("keyYellow") or "" + Key3 = robot.brain.get("keyYellow") or "" robot.brain.set("keyYellow",Key3) Key3 keyGreen = ()-> - Key1 = robot.brain.get("keyGreen") or "" + Key4 = robot.brain.get("keyGreen") or "" robot.brain.set("keyGreen",Key4) Key4 keyOrange = ()-> - Key1 = robot.brain.get("keyOrange") or "" + Key5 = robot.brain.get("keyOrange") or "" robot.brain.set("keyOrange",Key5) Key5 From bc58f2e732b6ac1522d6d3a47707575235873fc7 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Wed, 26 Feb 2020 09:35:52 +0530 Subject: [PATCH 06/16] Update keys.coffee --- scripts/keys.coffee | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index cee3a48..8a475b7 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -46,7 +46,7 @@ module.exports = (robot)-> robot.brain.set("keyOrange",Key5) Key5 - #1this section belongs to "i have keys" + #this section belongs to "i have keys" robot.respond /i (have the|have) (.+) (key|keys)/i, (msg)-> keyname = msg.match[2] name = msg.message.user.name @@ -60,11 +60,11 @@ module.exports = (robot)-> key_holder = keyBlue() key_holder = user.name robot.brain.set("keyBlue",key_holder) - else if keyname is 'Yellow' + else if keyname is 'yellow' key_holder = keyYellow() key_holder = user.name robot.brain.set("keyYellow",key_holder) - else if keyname is 'Green' + else if keyname is 'green' key_holder = keyGreen() key_holder = user.name robot.brain.set("keyGreen",key_holder) @@ -75,7 +75,7 @@ module.exports = (robot)-> if typeof user is 'object' msg.send "Okay #{name} has #{keyname} keys" - #2this section belongs to "i dont have key" + #this section belongs to "i dont have key" robot.respond /i (do not|don\'t|dont) (has the|have the|has|have) (key|keys)/i , (msg)-> name = msg.message.user.name user = robot.brain.userForName name @@ -87,28 +87,28 @@ module.exports = (robot)-> if name is key_holder1 key_holder1 = "" robot.brain.set("keyRed",key_holder1) - msg.send "Okay #{name} doesn't have Red keys. Who got the Red keys then?" + msg.send "Okay #{name} doesn't have red keys. Who got the red keys then?" else if name is key_holder2 key_holder2 = "" robot.brain.set("keyBlue",key_holder2) - msg.send "Okay #{name} doesn't have Blue keys. Who got the Blue keys then?" + msg.send "Okay #{name} doesn't have blue keys. Who got the blue keys then?" else if name is key_holder3 key_holder3 = "" robot.brain.set("keyYellow",key_holder3) - msg.send "Okay #{name} doesn't have Yellow keys. Who got the Yellow keys then?" + msg.send "Okay #{name} doesn't have yellow keys. Who got the yellow keys then?" else if name is key_holder4 key_holder4 = "" robot.brain.set("keyGreen",key_holder4) - msg.send "Okay #{name} doesn't have Green keys. Who got the green keys then?" + msg.send "Okay #{name} doesn't have green keys. Who got the green keys then?" else if name is key_holder5 key_holder5 = "" robot.brain.set("keyOrange",key_holder5) msg.send "Okay #{name} doesn't have orange keys. Who got the orange keys then?" else if typeof user is 'object' if key_holder1 is not "" - msg.send "Yes , I know buddy, its because #{key_holder1} has got the Red keys\n" + msg.send "Yes , I know buddy, its because #{key_holder1} has got the red keys\n" if key_holder2 is not "" - msg.send "Yes , I know buddy, its because #{key_holder2} has got the Blue keys\n" + msg.send "Yes , I know buddy, its because #{key_holder2} has got the blue keys\n" if key_holder3 is not "" msg.send "Yes , I know buddy, its because #{key_holder3} has got the yellow keys\n" if key_holder4 is not "" @@ -116,7 +116,7 @@ module.exports = (robot)-> if key_holder5 is not "" msg.send "Yes , I know buddy, its because #{key_holder5} has got the orange keys\n" - #3this section belongs to "$name has keys" + #this section belongs to "$name has keys" robot.respond /(.+) (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> othername = msg.match[1] keyname = msg.match[3] @@ -147,7 +147,7 @@ module.exports = (robot)-> else if keyname is 'orange' robot.brain.set("keyOrange",key_holder) msg.send "Okay, so now the #{keyname} keys are with #{othername}" - #4this section belongs to "i gave the keys to $name" + #this section belongs to "i gave the keys to $name" robot.respond /(i|I) (have given the|had given the|have given|gave the|had given|gave) (key|keys) to (.+)/i , (msg)-> othername = msg.match[4] name = msg.message.user.name @@ -162,20 +162,20 @@ module.exports = (robot)-> if users is null key_holder1 = null robot.brain.set("keyRed",key_holder1) - keyname="Red" + keyname="red" else key_holder1 = users.name robot.brain.set("keyRed",key_holder1) - keyname="Red" + keyname="red" else if name is key_holder2 if users is null key_holder2 = null robot.brain.set("keyBlue",key_holder2) - keyname="Blue" + keyname="blue" else key_holder2 = users.name robot.brain.set("keyBlue",key_holder2) - keyname="Blue" + keyname="blue" else if name is key_holder3 if users is null key_holder3 = null @@ -213,7 +213,7 @@ module.exports = (robot)-> robot.brain.set("keyOrange",key_holder5) else msg.send "Okay, so now the #{keyname} keys are with #{users.name}" - #5this section is for commands -> {i} dont have the keys + #this section is for commands -> {i} dont have the keys robot.respond /(.+) (do not|don\'t|dont) (has the|have the|has|have) (key|keys)/i , (msg)-> othername = msg.match[1] key_holder1 = keyRed() @@ -223,10 +223,10 @@ module.exports = (robot)-> key_holder5 = keyOrange() if othername is key_holder1 robot.brain.set("keyRed" ,key_holder1) - msg.send "Okay, so now the Red keys are with #{othername}" + msg.send "Okay, so now the red keys are with #{othername}" else if othername is key_holder2 robot.brain.set("keyBlue" ,key_holder1) - msg.send "Okay, so now the Blue keys are with #{othername}" + msg.send "Okay, so now the blue keys are with #{othername}" else if othername is key_holder3 robot.brain.set("keyYellow" ,key_holder1) msg.send "Okay, so now the yellow keys are with #{othername}" @@ -236,7 +236,7 @@ module.exports = (robot)-> else if othername is key_holder5 robot.brain.set("keyOrange" ,key_holder1) msg.send "Okay, so now the orange keys are with #{othername}" - #6this section is to print the details about the key holder. + #this section is to print the details about the key holder. robot.respond /who (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> keyname = msg.match[2] if keyname is 'red' From 3fb6519037c95551fdaa9ca29f7f0189f023d787 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Wed, 26 Feb 2020 09:41:05 +0530 Subject: [PATCH 07/16] Update keys.coffee --- scripts/keys.coffee | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index 8a475b7..a0e099e 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -245,7 +245,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText+=" has red keys" + msgText + = " has red keys" msg.send msgText robot.brain.set("keyRed" ,key_holder) else if keyname is 'blue' @@ -254,7 +254,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText+=" has blue keys" + msgText + = " has blue keys" msg.send msgText robot.brain.set("keyBlue" ,key_holder) else if keyname is 'yellow' @@ -263,7 +263,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText+=" has yellow keys" + msgText + = " has yellow keys" msg.send msgText robot.brain.set("keyYellow" ,key_holder) else if keyname is 'green' @@ -272,7 +272,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText+=" has green keys" + msgText + = " has green keys" msg.send msgText robot.brain.set("keyGreen" ,key_holder) else if keyname is 'orange' @@ -281,7 +281,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText+=" has orange keys" + msgText + = " has orange keys" msg.send msgText robot.brain.set("keyOrange" ,key_holder) robot.respond /who (has the|have the|has|have) (key|keys)/i , (msg)-> @@ -291,21 +291,21 @@ module.exports = (robot)-> key_holder4 = keyGreen() key_holder5 = keyOrange() msgText="" - if key_holder1 != "" - msgText+=key_holder1 - msgText+=" has red keys.\n" - if key_holder2 != "" - msgText+=key_holder2 - msgText+=" has blue keys.\n" - if key_holder3 != "" - msgText+=key_holder3 - msgText+=" has yellow keys.\n" - if key_holder4 != "" - msgText+=key_holder3 - msgText+=" has green keys.\n" - if key_holder5 != "" - msgText+=key_holder3 - msgText+=" has orange keys.\n" + if key_holder1 ! = "" + msgText + = key_holder1 + msgText + = " has red keys.\n" + if key_holder2 ! = "" + msgText + = key_holder2 + msgText + = " has blue keys.\n" + if key_holder3 ! = "" + msgText + = key_holder3 + msgText + = " has yellow keys.\n" + if key_holder4 ! = "" + msgText + = key_holder3 + msgText + = " has green keys.\n" + if key_holder5 ! = "" + msgText + = key_holder3 + msgText + = " has orange keys.\n" if msgText is "" msg.send "Ah! Nobody informed me about any keys. Don't hold me responsible for this :expressionless:" else From 04cd5fafec4e8f490229024ecfb2504598e75420 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Mon, 16 Mar 2020 12:43:47 +0530 Subject: [PATCH 08/16] Update keys.coffee --- scripts/keys.coffee | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index a0e099e..377c9f1 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -245,7 +245,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText + = " has red keys" + msgText += " has red keys" msg.send msgText robot.brain.set("keyRed" ,key_holder) else if keyname is 'blue' @@ -254,7 +254,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText + = " has blue keys" + msgText += " has blue keys" msg.send msgText robot.brain.set("keyBlue" ,key_holder) else if keyname is 'yellow' @@ -263,7 +263,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText + = " has yellow keys" + msgText += " has yellow keys" msg.send msgText robot.brain.set("keyYellow" ,key_holder) else if keyname is 'green' @@ -272,7 +272,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText + = " has green keys" + msgText += " has green keys" msg.send msgText robot.brain.set("keyGreen" ,key_holder) else if keyname is 'orange' @@ -281,7 +281,7 @@ module.exports = (robot)-> if msgText is "" msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" else - msgText + = " has orange keys" + msgText += " has orange keys" msg.send msgText robot.brain.set("keyOrange" ,key_holder) robot.respond /who (has the|have the|has|have) (key|keys)/i , (msg)-> @@ -291,21 +291,21 @@ module.exports = (robot)-> key_holder4 = keyGreen() key_holder5 = keyOrange() msgText="" - if key_holder1 ! = "" - msgText + = key_holder1 - msgText + = " has red keys.\n" - if key_holder2 ! = "" - msgText + = key_holder2 - msgText + = " has blue keys.\n" - if key_holder3 ! = "" - msgText + = key_holder3 - msgText + = " has yellow keys.\n" - if key_holder4 ! = "" - msgText + = key_holder3 - msgText + = " has green keys.\n" - if key_holder5 ! = "" - msgText + = key_holder3 - msgText + = " has orange keys.\n" + if key_holder1 != "" + msgText += key_holder1 + msgText += " has red keys.\n" + if key_holder2 != "" + msgText += key_holder2 + msgText += " has blue keys.\n" + if key_holder3 != "" + msgText += key_holder3 + msgText += " has yellow keys.\n" + if key_holder4 != "" + msgText += key_holder3 + msgText += " has green keys.\n" + if key_holder5 != "" + msgText += key_holder3 + msgText += " has orange keys.\n" if msgText is "" msg.send "Ah! Nobody informed me about any keys. Don't hold me responsible for this :expressionless:" else @@ -315,4 +315,3 @@ module.exports = (robot)-> robot.brain.set("keyYellow" ,key_holder3) robot.brain.set("keyGreen" ,key_holder2) robot.brain.set("keyOrange" ,key_holder2) - From 34549ef87e13ee5eb2b2dee16ecf96c5bd551164 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Mon, 16 Mar 2020 15:05:25 +0530 Subject: [PATCH 09/16] Update keys.coffee --- scripts/keys.coffee | 80 +++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index 377c9f1..c02160e 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -203,39 +203,51 @@ module.exports = (robot)-> key_holder5 = users.name robot.brain.set("keyOrange",key_holder5) keyname="orange" - if key_holder1 is null or key_holder2 is null or key_holder3 is null or key_holder4 is null or key_holder5 is null - if othername is 'you' - msg.send "That's utter lies! How can you blame a bot to have the keys? #{name} is a liar!" - else if othername is robot.name - msg.send "That's utter lies! How can you blame a bot to have the keys?" - else - msg.send "I don't know anyone by the name #{othername}" - robot.brain.set("keyOrange",key_holder5) - else - msg.send "Okay, so now the #{keyname} keys are with #{users.name}" + else + msg.send "DEAR Sir,you dont even have a key\n" + if key_holder1 is null or key_holder2 is null or key_holder3 is null or key_holder4 is null or key_holder5 is null + if othername is 'you' + msg.send "That's utter lies! How can you blame a bot to have the keys? #{name} is a liar!" + else if othername is robot.name + msg.send "That's utter lies! How can you blame a bot to have the keys?" + else + msg.send "I don't know anyone by the name #{othername}" + else + msg.send "Okay, so now the #{keyname} keys are with #{users.name}" #this section is for commands -> {i} dont have the keys robot.respond /(.+) (do not|don\'t|dont) (has the|have the|has|have) (key|keys)/i , (msg)-> - othername = msg.match[1] + users = msg.match[1] + othername = robot.brain.userForName users key_holder1 = keyRed() key_holder2 = keyBlue() key_holder3 = keyYellow() key_holder4 = keyGreen() key_holder5 = keyOrange() if othername is key_holder1 + key_holder1="" robot.brain.set("keyRed" ,key_holder1) - msg.send "Okay, so now the red keys are with #{othername}" + msg.send "Okay, so now the red keys are not with #{othername}" else if othername is key_holder2 - robot.brain.set("keyBlue" ,key_holder1) - msg.send "Okay, so now the blue keys are with #{othername}" + key_holder2="" + robot.brain.set("keyBlue" ,key_holder2) + msg.send "Okay, so now the blue keys are not with #{othername}" else if othername is key_holder3 - robot.brain.set("keyYellow" ,key_holder1) - msg.send "Okay, so now the yellow keys are with #{othername}" + key_holder3="" + robot.brain.set("keyYellow" ,key_holder3) + msg.send "Okay, so now the yellow keys are not with #{othername}" else if othername is key_holder4 - robot.brain.set("keyGreen" ,key_holder1) - msg.send "Okay, so now the green keys are with #{othername}" + key_holder4="" + robot.brain.set("keyGreen" ,key_holder4) + msg.send "Okay, so now the green keys are not with #{othername}" else if othername is key_holder5 - robot.brain.set("keyOrange" ,key_holder1) - msg.send "Okay, so now the orange keys are with #{othername}" + key_holder5="" + robot.brain.set("keyOrange" ,key_holder5) + msg.send "Okay, so now the orange keys are not with #{othername}" + robot.brain.set("keyRed" ,key_holder1) + robot.brain.set("keyBlue" ,key_holder2) + robot.brain.set("keyYellow" ,key_holder3) + robot.brain.set("keyGreen" ,key_holder4) + robot.brain.set("keyOrange" ,key_holder5) #this section is to print the details about the key holder. robot.respond /who (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> keyname = msg.match[2] @@ -284,6 +296,7 @@ module.exports = (robot)-> msgText += " has orange keys" msg.send msgText robot.brain.set("keyOrange" ,key_holder) + #this section is for bro who has keys robot.respond /who (has the|have the|has|have) (key|keys)/i , (msg)-> key_holder1 = keyRed() key_holder2 = keyBlue() @@ -301,10 +314,10 @@ module.exports = (robot)-> msgText += key_holder3 msgText += " has yellow keys.\n" if key_holder4 != "" - msgText += key_holder3 + msgText += key_holder4 msgText += " has green keys.\n" if key_holder5 != "" - msgText += key_holder3 + msgText += key_holder5 msgText += " has orange keys.\n" if msgText is "" msg.send "Ah! Nobody informed me about any keys. Don't hold me responsible for this :expressionless:" @@ -313,5 +326,24 @@ module.exports = (robot)-> robot.brain.set("keyRed" ,key_holder1) robot.brain.set("keyBlue" ,key_holder2) robot.brain.set("keyYellow" ,key_holder3) - robot.brain.set("keyGreen" ,key_holder2) - robot.brain.set("keyOrange" ,key_holder2) + robot.brain.set("keyGreen" ,key_holder4) + robot.brain.set("keyOrange" ,key_holder5) + #this section is for bro reset all keys + robot.respond /(reset all) (key|keys)/i , (msg)-> + key_holder1 = keyRed() + key_holder2 = keyBlue() + key_holder3 = keyYellow() + key_holder4 = keyGreen() + key_holder5 = keyOrange() + key_holder1 = "" + key_holder2 = "" + key_holder3 = "" + key_holder4 = "" + key_holder5 = "" + msg.send "ALL KEYS RESET TO NULL" + robot.brain.set("keyRed" ,key_holder1) + robot.brain.set("keyBlue" ,key_holder2) + robot.brain.set("keyYellow" ,key_holder3) + robot.brain.set("keyGreen" ,key_holder4) + robot.brain.set("keyOrange" ,key_holder5) + From f519331f323b05e17951c1b0f5b3723bcea8e21c Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Mon, 16 Mar 2020 15:50:35 +0530 Subject: [PATCH 10/16] Update keys.coffee From ca3d71d76cb7ce846f9f1afa1e5ce8159f73bcdc Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Tue, 17 Mar 2020 13:40:46 +0530 Subject: [PATCH 11/16] Update keys.coffee --- scripts/keys.coffee | 65 ++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index c02160e..1b6374e 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -10,11 +10,11 @@ # bot xyz has keys : sets xyz as the holder of keys # # Examples: -# :bot who has keys -# :bot i have keys -# :bot i dont have keys -# :bot who has keys -# :bot ravi has keys +# :bro who has keys +# :bro i have keys +# :bro i dont have keys +# :bro who has keys +# :bro ravi has keys # # Author: # Punit Dhoot (@pdhoot) @@ -46,7 +46,7 @@ module.exports = (robot)-> robot.brain.set("keyOrange",Key5) Key5 - #this section belongs to "i have keys" + #this section belongs to "i have color keys" robot.respond /i (have the|have) (.+) (key|keys)/i, (msg)-> keyname = msg.match[2] name = msg.message.user.name @@ -104,19 +104,10 @@ module.exports = (robot)-> key_holder5 = "" robot.brain.set("keyOrange",key_holder5) msg.send "Okay #{name} doesn't have orange keys. Who got the orange keys then?" - else if typeof user is 'object' - if key_holder1 is not "" - msg.send "Yes , I know buddy, its because #{key_holder1} has got the red keys\n" - if key_holder2 is not "" - msg.send "Yes , I know buddy, its because #{key_holder2} has got the blue keys\n" - if key_holder3 is not "" - msg.send "Yes , I know buddy, its because #{key_holder3} has got the yellow keys\n" - if key_holder4 is not "" - msg.send "Yes , I know buddy, its because #{key_holder4} has got the green keys\n" - if key_holder5 is not "" - msg.send "Yes , I know buddy, its because #{key_holder5} has got the orange keys\n" + else + msg.send "Dear sir/mam, You dont even have a key,you Donkey" - #this section belongs to "$name has keys" + #this section belongs to "$name has color keys" robot.respond /(.+) (has the|have the|has|have) (.+) (key|keys)/i , (msg)-> othername = msg.match[1] keyname = msg.match[3] @@ -131,10 +122,10 @@ module.exports = (robot)-> if key_holder is null if othername is 'you' msg.send "How am I supposed to take those #{keyname} keys? #{name} is a liar!" - else if othername is robot.name - msg.send "That's utter lies! How can you blame a bot to have the keys?" else msg.send "I don't know anyone by the name #{othername}" + else if othername is robot.name + msg.send "That's utter lies! How can you blame a bot to have the keys?" else if keyname is 'red' robot.brain.set("keyRed",key_holder) @@ -158,62 +149,62 @@ module.exports = (robot)-> key_holder5 = keyOrange() keyname="" users = robot.brain.userForName othername - if name is key_holder1 + if name is key_holder1 and users.name is not "bro" if users is null key_holder1 = null robot.brain.set("keyRed",key_holder1) keyname="red" + msg.send "I don't know anyone by the name #{othername}" else key_holder1 = users.name robot.brain.set("keyRed",key_holder1) keyname="red" - else if name is key_holder2 + else if name is key_holder2 and users.name is not "bro" if users is null key_holder2 = null robot.brain.set("keyBlue",key_holder2) keyname="blue" + msg.send "I don't know anyone by the name #{othername}" else key_holder2 = users.name robot.brain.set("keyBlue",key_holder2) keyname="blue" - else if name is key_holder3 + else if name is key_holder3 and users.name is not "bro" if users is null key_holder3 = null robot.brain.set("keyYellow",key_holder3) keyname="yellow" + msg.send "I don't know anyone by the name #{othername}" else key_holder3 = users.name robot.brain.set("keyYellow",key_holder3) keyname="yellow" - else if name is key_holder4 + else if name is key_holder4 and users.name is not "bro" if users is null key_holder4 = null robot.brain.set("keyGreen",key_holder4) keyname="green" + msg.send "I don't know anyone by the name #{othername}" else key_holder4 = users.name robot.brain.set("keyGreen",key_holder4) keyname="green" - else if name is key_holder5 + else if name is key_holder5 and users.name is not "bro" if users is null key_holder5 = null robot.brain.set("keyOrange",key_holder5) keyname="orange" + msg.send "I don't know anyone by the name #{othername}" else key_holder5 = users.name robot.brain.set("keyOrange",key_holder5) keyname="orange" - else + else if users.name is not "bro" msg.send "DEAR Sir,you dont even have a key\n" - if key_holder1 is null or key_holder2 is null or key_holder3 is null or key_holder4 is null or key_holder5 is null - if othername is 'you' - msg.send "That's utter lies! How can you blame a bot to have the keys? #{name} is a liar!" - else if othername is robot.name - msg.send "That's utter lies! How can you blame a bot to have the keys?" - else - msg.send "I don't know anyone by the name #{othername}" - else - msg.send "Okay, so now the #{keyname} keys are with #{users.name}" + if othername is 'you' + msg.send "That's utter lies! How can you blame a bot to have the keys? #{name} is a liar!" + else if othername is robot.name + msg.send "That's utter lies! How can you blame a bot to have the keys?" #this section is for commands -> {i} dont have the keys robot.respond /(.+) (do not|don\'t|dont) (has the|have the|has|have) (key|keys)/i , (msg)-> users = msg.match[1] @@ -346,4 +337,6 @@ module.exports = (robot)-> robot.brain.set("keyYellow" ,key_holder3) robot.brain.set("keyGreen" ,key_holder4) robot.brain.set("keyOrange" ,key_holder5) - + #commands + robot.respond /(show key commands)/i , (msg)-> + msg.send "i have keys\n i gave keys to \n i dont have keys \n who has keys \n reset all keys \n THESE ARE ENOUGH \n " From 72781dee4196617d90e690d95bc4ae17c05c5327 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Tue, 17 Mar 2020 13:47:22 +0530 Subject: [PATCH 12/16] Update keys.coffee --- scripts/keys.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index 1b6374e..b41fee3 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -339,4 +339,4 @@ module.exports = (robot)-> robot.brain.set("keyOrange" ,key_holder5) #commands robot.respond /(show key commands)/i , (msg)-> - msg.send "i have keys\n i gave keys to \n i dont have keys \n who has keys \n reset all keys \n THESE ARE ENOUGH \n " + msg.send " I have keys \n I gave keys to \n have keys \n I dont have keys \n Who has keys \n Reset all keys \n " From 68f9b72530c709ef09bfd85968395b28cc155aca Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Tue, 17 Mar 2020 14:34:17 +0530 Subject: [PATCH 13/16] Update keys.coffee --- scripts/keys.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index b41fee3..28742aa 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -19,8 +19,8 @@ # Author: # Punit Dhoot (@pdhoot) # Developer at SDSLabs (@sdslabs -# Edit: -# Prakhar Gupta at Mdg +# Edit: +# Prakhar Gupta at Mdg module.exports = (robot)-> From 880d7aaedb1e274182414607efaec050d82994c2 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Tue, 17 Mar 2020 20:56:58 +0530 Subject: [PATCH 14/16] changes in part "print detail about keyholder" --- scripts/keys.coffee | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index 28742aa..c379f78 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -245,48 +245,23 @@ module.exports = (robot)-> if keyname is 'red' key_holder = keyRed() msgText = key_holder - if msgText is "" - msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" - else - msgText += " has red keys" - msg.send msgText - robot.brain.set("keyRed" ,key_holder) else if keyname is 'blue' key_holder = keyBlue() msgText = key_holder - if msgText is "" - msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" - else - msgText += " has blue keys" - msg.send msgText - robot.brain.set("keyBlue" ,key_holder) else if keyname is 'yellow' key_holder = keyYellow() msgText = key_holder - if msgText is "" - msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" - else - msgText += " has yellow keys" - msg.send msgText - robot.brain.set("keyYellow" ,key_holder) else if keyname is 'green' key_holder = keyGreen() msgText = key_holder - if msgText is "" - msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" - else - msgText += " has green keys" - msg.send msgText - robot.brain.set("keyGreen" ,key_holder) else if keyname is 'orange' key_holder = keyOrange() msgText = key_holder - if msgText is "" - msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" - else - msgText += " has orange keys" - msg.send msgText - robot.brain.set("keyOrange" ,key_holder) + if msgText is "" + msg.send "Ah! Nobody informed me about the keys. Don't hold me responsible for this :expressionless:" + else + msgText += " has #{keyname} keys" + msg.send msgText #this section is for bro who has keys robot.respond /who (has the|have the|has|have) (key|keys)/i , (msg)-> key_holder1 = keyRed() From 0aa2d0fa3c37393964190d9810c525792e10cd6e Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Tue, 17 Mar 2020 22:01:04 +0530 Subject: [PATCH 15/16] added confirmation msg to "gave key" --- scripts/keys.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index c379f78..f215253 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -159,6 +159,7 @@ module.exports = (robot)-> key_holder1 = users.name robot.brain.set("keyRed",key_holder1) keyname="red" + msg.send "Okay, so now you dont have red keys" else if name is key_holder2 and users.name is not "bro" if users is null key_holder2 = null @@ -169,6 +170,7 @@ module.exports = (robot)-> key_holder2 = users.name robot.brain.set("keyBlue",key_holder2) keyname="blue" + msg.send "Okay, so now you dont have blue keys" else if name is key_holder3 and users.name is not "bro" if users is null key_holder3 = null @@ -179,6 +181,7 @@ module.exports = (robot)-> key_holder3 = users.name robot.brain.set("keyYellow",key_holder3) keyname="yellow" + msg.send "Okay, so now you dont have yellow keys" else if name is key_holder4 and users.name is not "bro" if users is null key_holder4 = null @@ -189,6 +192,7 @@ module.exports = (robot)-> key_holder4 = users.name robot.brain.set("keyGreen",key_holder4) keyname="green" + msg.send "Okay, so now you dont have green keys" else if name is key_holder5 and users.name is not "bro" if users is null key_holder5 = null @@ -199,6 +203,7 @@ module.exports = (robot)-> key_holder5 = users.name robot.brain.set("keyOrange",key_holder5) keyname="orange" + msg.send "Okay, so now you dont have orange keys" else if users.name is not "bro" msg.send "DEAR Sir,you dont even have a key\n" if othername is 'you' From 6e9881981669bc520ba3a40f59e37b4d69ac1c74 Mon Sep 17 00:00:00 2001 From: guptaprakhariitr <58157064+guptaprakhariitr@users.noreply.github.com> Date: Tue, 17 Mar 2020 22:07:23 +0530 Subject: [PATCH 16/16] removed "is not bro" conditions in "gave key" part --- scripts/keys.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/keys.coffee b/scripts/keys.coffee index f215253..8166b67 100644 --- a/scripts/keys.coffee +++ b/scripts/keys.coffee @@ -149,7 +149,7 @@ module.exports = (robot)-> key_holder5 = keyOrange() keyname="" users = robot.brain.userForName othername - if name is key_holder1 and users.name is not "bro" + if name is key_holder1 if users is null key_holder1 = null robot.brain.set("keyRed",key_holder1) @@ -160,7 +160,7 @@ module.exports = (robot)-> robot.brain.set("keyRed",key_holder1) keyname="red" msg.send "Okay, so now you dont have red keys" - else if name is key_holder2 and users.name is not "bro" + else if name is key_holder2 if users is null key_holder2 = null robot.brain.set("keyBlue",key_holder2) @@ -171,7 +171,7 @@ module.exports = (robot)-> robot.brain.set("keyBlue",key_holder2) keyname="blue" msg.send "Okay, so now you dont have blue keys" - else if name is key_holder3 and users.name is not "bro" + else if name is key_holder3 if users is null key_holder3 = null robot.brain.set("keyYellow",key_holder3) @@ -182,7 +182,7 @@ module.exports = (robot)-> robot.brain.set("keyYellow",key_holder3) keyname="yellow" msg.send "Okay, so now you dont have yellow keys" - else if name is key_holder4 and users.name is not "bro" + else if name is key_holder4 if users is null key_holder4 = null robot.brain.set("keyGreen",key_holder4) @@ -193,7 +193,7 @@ module.exports = (robot)-> robot.brain.set("keyGreen",key_holder4) keyname="green" msg.send "Okay, so now you dont have green keys" - else if name is key_holder5 and users.name is not "bro" + else if name is key_holder5 if users is null key_holder5 = null robot.brain.set("keyOrange",key_holder5) @@ -204,7 +204,7 @@ module.exports = (robot)-> robot.brain.set("keyOrange",key_holder5) keyname="orange" msg.send "Okay, so now you dont have orange keys" - else if users.name is not "bro" + else msg.send "DEAR Sir,you dont even have a key\n" if othername is 'you' msg.send "That's utter lies! How can you blame a bot to have the keys? #{name} is a liar!"