- 
      
- 
        Save JerrySievert/3647230 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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
    
  
  
    
  | function(msg) { | |
| if(/^taps/.test(msg.message)) { | |
| var match = msg.message.match(/^taps\s+(.+)/); | |
| var tap; | |
| var taps = [ ]; | |
| json = http.get("http://visualizeapi.com/api/baileys"); | |
| feed = JSON.parse(json); | |
| var tap_list = "Bailey's Taps: "; | |
| if (match && feed.data[match[1]]) { | |
| tap = feed.data[match[1]]; | |
| return tap_list + "Tap " + match[1] + " - " + tap.brewery + " / " + tap.beer + " (" + tap.prices.join(", ") + ") " + parseInt(tap.fill*100) + "% full, served in a " + tap.glass + " glass"; | |
| } else { | |
| for(var tap_id in feed.data) { | |
| tap = feed.data[tap_id]; | |
| if (match) { | |
| if (tap.beer.toUpperCase().match(match[1].toUpperCase()) || tap.brewery.toUpperCase().match(match[1].toUpperCase()) || tap.glass.toUpperCase().match(match[1].toUpperCase()) || tap.style.toUpperCase().match(match[1].toUpperCase())) { | |
| taps.push("Tap " + tap_id + " - " + tap.brewery + " / " + tap.beer + " (" + tap.prices.join(", ") + ") " + parseInt(tap.fill*100) + "% full, served in a " + tap.glass + " glass"); | |
| } | |
| } else { | |
| taps.push(tap_id + "-" + tap.beer); | |
| } | |
| } | |
| } | |
| if (taps.length === 0) { | |
| tap_list += " none found"; | |
| } else { | |
| tap_list += taps.join(", "); | |
| } | |
| return tap_list; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment