Skip to content

Instantly share code, notes, and snippets.

@tel
Created November 10, 2012 01:33
Show Gist options
  • Save tel/4049424 to your computer and use it in GitHub Desktop.
Save tel/4049424 to your computer and use it in GitHub Desktop.
tags = parse_hashtags body
[200, {}, tags.join(' ')]
else
404 # What happened? Not Twilio, apparently
end
end
private
# Looks for all the command words in the message
def parse_commands com, body
# Accumulate our command dictionary
dict = com.report + com.clean + com.follow + com.stop
# Get the words from the body
words = body.downcase.split(/\W+/)
words & dict
end
# Looks for hashtags like #bang! ==> ['bang!']
def parse_hashtags body
body.downcase.split(/\W+/).delete_if do |w|
not (w[0,1] == "#")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment