Skip to content

Commit

Permalink
Merge pull request pickhardt#8 from remixz/whats-playing
Browse files Browse the repository at this point in the history
Add "whats playing" command to Betty
  • Loading branch information
pickhardt committed May 5, 2014
2 parents 4996230 + 6d8ae3f commit 7b34a7a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/itunes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ def self.prev(command)
nil
end
end

def self.playing(command)
matching = command.match(/^what\'?s?\s+((songs?|musics?|tracks?|iTunes)\s+)?(is)?\s?+play(?:ing)?$/i)

if matching
{
:command => "osascript -e 'tell application \"iTunes\" to get name of current track'",
:explanation => "Gets the name of the playing track on iTunes."
}
else
nil
end
end

def self.interpret(command)
responses = []
Expand All @@ -98,6 +111,9 @@ def self.interpret(command)
prev_command = self.prev(command)
responses << prev_command if prev_command

playing_command = self.playing(command)
responses << playing_command if playing_command

responses
end
end
Expand Down

0 comments on commit 7b34a7a

Please sign in to comment.