diff --git a/modules/link/config.json b/modules/link/config.json new file mode 100644 index 0000000..d1a8210 --- /dev/null +++ b/modules/link/config.json @@ -0,0 +1,3 @@ +{ + "autoTitle": false +} diff --git a/modules/link/link.js b/modules/link/link.js index b9c5eaf..d0bf2d9 100644 --- a/modules/link/link.js +++ b/modules/link/link.js @@ -41,6 +41,18 @@ var link = function(dbot) { var urlMatches = event.message.match(urlRegex); if(urlMatches !== null) { links[event.channel.name] = urlMatches[0]; + + if(dbot.config.link.autoTitle == true) { + request(urlMatches[0], function (error, response, body) { + if(!error && response.statusCode == 200) { + body = body.replace(/(\r\n|\n\r|\n)/gm, " "); + var title = body.valMatch(/