         robot.respond /pastebin (.+)/i, (msg) ->
             service = new Pastebin msg
             service.create msg.match[1]
+    else
+        robot.logger.warning "Missing PASTEBIN_API_KEY in environment. Pastebin services will not be available."

#   Universal Paste API (Dpaste.com and Pastebin.com)
#
# Configuration:
#   
#
# Commands:
#   hubot dpaste <content> - Creates a new paste with <content> on Dpaste.com


DPASTE_API_URL = "http://dpaste.com/api/v2/"
PASTEBIN_API_URL = "http://pastebin.com/api/api_post.php"

DEF_SERVER_ERROR = "We are unable to process your request at this time due to a server error. Please try again later."
DEF_CREDIT = "Generated by ClaudeBot's hubot-paste"

class Paste
    constructor: (@msg) ->

    create: (err, link) ->
        if err
            @msg.reply DEF_SERVER_ERROR
            return @msg.robot.logger.error err
        @msg.reply link

class Dpaste extends Paste
    create: (text, expire = 1) ->
        data = "content=#{encodeURI(text)}&expiry_days=#{expire}"
        data += "&poster=#{@msg.robot.name}&title=#{encodeURI(DEF_CREDIT)}"

        @msg.http(DPASTE_API_URL)
            .header("content-type", "application/x-www-form-urlencoded")
