Skip to content

Commit

Permalink
added lyrics script
Browse files Browse the repository at this point in the history
  • Loading branch information
mportiz08 committed Nov 11, 2011
1 parent 504e3f9 commit 55905fe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/scripts/lyrics.coffee
@@ -0,0 +1,19 @@
# Grabs snippets of song lyrics.
# Limited to snippets due to copyright stuff.
#
# lyrics for <song> by <artist> - returns snippet of lyrics for this song
#
# Example: lyrics for purple haze by jimi hendrix
module.exports = (robot) ->
robot.respond /lyrics for (.*) by (.*)/i, (msg) ->
song = msg.match[1]
artist = msg.match[2]
getLyrics msg, song, artist

getLyrics = (msg, song, artist) ->
msg.http("http://lyrics.wikia.com/api.php")
.query(artist: artist, song: song, fmt: "json")
.get() (err, res, body) ->
result = eval body # can't use JSON.parse :(
msg.send result['url']
msg.send result['lyrics']

0 comments on commit 55905fe

Please sign in to comment.