diff --git a/scripts/example.coffee b/scripts/example.coffee index 1194784..a082500 100644 --- a/scripts/example.coffee +++ b/scripts/example.coffee @@ -8,8 +8,6 @@ # # These are from the scripting documentation: https://github.com/github/hubot/blob/master/docs/scripting.md # -# Commands: -# sneakybot request - Make a sneaker request. module.exports = (robot) -> diff --git a/scripts/sneakybot-requests.coffee b/scripts/sneakybot-requests.coffee new file mode 100644 index 0000000..b80cb40 --- /dev/null +++ b/scripts/sneakybot-requests.coffee @@ -0,0 +1,36 @@ +# Description: +# A request system for slack. +# +# Dependencies: +# None +# +# Configuration: +# None +# +# Commands: +# request - Make a sneaker request. +# who is - Return who is the user. +# +# Notes: +# +# Author: +# mrbernnz + +module.exports = (robot) -> + + robot.respond /request (.*) (.*)$/i, (msg) -> + shoeRequest = msg.match[1] + shoeSize = msg.match[2] + + robot.brain.set 'totalShoeRequests', shoeRequest + msg.reply "We received your request for #{shoeRequest}" + + robot.respond /who is @?([\w .\-]+)\?*$/i, (res) -> + name = res.match[1].trim() + + users = robot.brain.usersForFuzzyName(name) + if users.length is 1 + user = users[0] + # Do something interesting here.. + + res.send "#{name} is user - #{user}" diff --git a/scripts/welcome.coffee b/scripts/welcome.coffee deleted file mode 100644 index 373dbad..0000000 --- a/scripts/welcome.coffee +++ /dev/null @@ -1,34 +0,0 @@ -# Description: -# Sends a welcome message to the first thing someone new says something -# -# Dependencies: -# None -# -# Configuration: -# None -# -# Commands: -# welcome - Update the welcome message -# -# Author: -# jjasghar - -module.exports = (robot) -> - robot.brain.on 'loaded', => - robot.brain.data.welcome ||= {} - robot.brain.data.users ||= [ ] - - robot.enter (msg) -> - welcome = robot.brain.get('data.welcome') # pull out the welcome message - stored_users = robot.brain.get('data.users') # get a list of the known stored users - users = robot.brain.usersForFuzzyName("#{msg.message.user.name}") # get the user name of someone saying something - if users in stored_users # if the user above is in the stored_users do nothing - else - msg.send "Welcome, #{msg.message.user.name}, #{welcome}, #{msg.message.user.name}" # if it's the first time you're seeing them give them the welcome message - robot.brain.set 'data.users', msg.message.user.name # add the user name to the stored_users - - - robot.respond /welcome (.*)$/i, (msg) -> - welcome = msg.match[1] - robot.brain.set 'data.welcome', welcome.trim() - msg.send "Updated the welcome to: #{welcome}"