Hubot: a universal Bot on CoffeeScript from Github developers



    Github developers at work are engaged not only in the main business, but also in extraneous projects . One such project is the Hubot bot , a program for automating various online activities (originally a chat bot).

    The unique features of Hubot are support for any Javascript libraries through the npm package manager and bot scripts that are laid out on github for general use (see the CoffeeScript script directory ).

    Chatbot programming is done with simple commands.

    robot.hear /problem\??/i, (msg) ->
      msg.send "http://cl.ly/BG7R/trollface.jpg"

    For example, this script expects the word “problems?” To appear in the chat and publishes a classic picture in response .



    Or, such a script searches Google Image Search for a picture for a given keyword and publishes the first result from the search results page in the chat.

    imageMe = (msg, query, cb) ->
      msg.http('http://ajax.googleapis.com/ajax/services/search/images')
        .query(v: "1.0", rsz: '8', q: query)
        .get() (err, res, body) ->
          images = JSON.parse(body)
          images = images.responseData.results
          image  = msg.random images
          cb "#{image.unescapedUrl}#.png"

    Hubot can be connected to any IRC channel and customized to your taste. However, this is not the end of his possibilities. For example, inside Github, he was taught to unlock the doors in the office, make a list of employees in the room based on their WiFi status, find rental housing according to the given parameters, install Github, speak arbitrary phrases through speakers in the office, etc.

    Also popular now: