Skip to content
This repository
file 30 lines (27 sloc) 0.73 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# Description:
# Grabs snippets of song lyrics
# Limited to snippets due to copyright stuff
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# hubot lyrics for <song> by <artist> - returns snippet of lyrics for this song
#
# Author:
# mportiz08

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']
Something went wrong with that request. Please try again.