mirror of
https://github.com/reality/dbot.git
synced 2024-12-25 12:12:35 +01:00
Merge pull request #304 from tmenari/master
Add entity decoding to link.js <title>
This commit is contained in:
commit
a3cd2bc3ea
@ -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.
|
Returns the first [Urban Dictionary](http://www.urbandictionary.com) definition for the headword provided.
|
||||||
#### ~xkcd <comic ID>
|
#### ~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.
|
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.
|
* information about links.
|
||||||
*/
|
*/
|
||||||
var request = require('request'),
|
var request = require('request'),
|
||||||
_ = require('underscore')._;
|
_ = require('underscore')._,
|
||||||
|
ent = require('ent');
|
||||||
|
|
||||||
var link = function(dbot) {
|
var link = function(dbot) {
|
||||||
this.urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
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, " ");
|
body = body.replace(/(\r\n|\n\r|\n)/gm, " ");
|
||||||
var title = body.valMatch(/<title>(.*)<\/title>/, 2);
|
var title = body.valMatch(/<title>(.*)<\/title>/, 2);
|
||||||
if(title && title.length < 140) {
|
if(title && title.length < 140) {
|
||||||
event.reply(title[1]);
|
event.reply(ent.decode(title[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user