3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 11:42:36 +01:00

entity decoding for link module

This commit is contained in:
Thomas Menari 2013-03-09 17:02:33 +00:00
parent 7bda956dbb
commit 5a6f6ad39e
2 changed files with 6 additions and 2 deletions

View File

@ -23,3 +23,6 @@ which was posted in the current channel.
Returns the first [Urban Dictionary](http://www.urbandictionary.com) definition for the headword provided.
#### ~xkcd <comic ID>
Returns a link to the [xkcd](http://xkcd.com) comic specified, or the latest one if a comic is not given. Use '*' to return a link to a random comic.
### Requirements
* [node-ent](https://github.com/substack/node-ent)

View File

@ -4,7 +4,8 @@
* information about links.
*/
var request = require('request'),
_ = require('underscore')._;
_ = require('underscore')._,
ent = require('ent');
var link = function(dbot) {
this.urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
@ -15,7 +16,7 @@ var link = function(dbot) {
body = body.replace(/(\r\n|\n\r|\n)/gm, " ");
var title = body.valMatch(/<title>(.*)<\/title>/, 2);
if(title && title.length < 140) {
event.reply(title[1]);
event.reply(ent.decode(title[1]));
}
}
});