mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 03:33:07 +01:00
entity decoding for link module
This commit is contained in:
parent
7bda956dbb
commit
5a6f6ad39e
@ -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)
|
||||
|
@ -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]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user