Last Updated: February 25, 2016
·
905
· btv

Hubot Script to Verify and Retrieve Python Libarary Links

At work we decided to play around with Github's Hubot. If you haven't had a chance to explore this project, I highly recommend that you do.

I've been on the look out for coming up with things my could benefit from having quicker acccess to and quick access to the various python libraries seemed like a good idea. Here is my Hubot script to check and get Python libraries by name:

module.exports = (robot) ->
  robot.respond /python(2|3) library (.*)/i, (msg) ->
      matches = msg.match
      libraryMe robot, matches[1], matches[2], (text) ->
          msg.send text

libraryMe = (robot, version, lib, callback) ->
    url = "http://docs.python.org/#{version}/library/#{lib}.html"
    robot.http(url)
         .get() (err,res,body) ->
             if res.statusCode != 200
                 callback "MERP! The library #{lib} does not exist!"
             else
                 callback url

If you curious about Hubot or wish to see what else that it can do, I recommend visiting the github like above and the Github repo of community contributed scripts here which the one above is a recent addition to :).