Created
November 10, 2012 01:33
-
-
Save tel/4049424 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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