mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
link underscorised (easy) [#81]
This commit is contained in:
parent
f6d69fe137
commit
35e34874af
@ -3,7 +3,9 @@
|
||||
* Description: Stores recent channel links, with commands to retrieve
|
||||
* information about links.
|
||||
*/
|
||||
var request = require('request');
|
||||
var request = require('request'),
|
||||
_ = require('underscore')._;
|
||||
|
||||
var link = function(dbot) {
|
||||
var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
||||
var links = {};
|
||||
@ -22,7 +24,7 @@ var link = function(dbot) {
|
||||
var commands = {
|
||||
'~title': function(event) {
|
||||
var link = links[event.channel.name];
|
||||
if(event.params[1] !== undefined) {
|
||||
if(_.isUndefined(event.params[1])) {
|
||||
var urlMatches = event.params[1].match(urlRegex);
|
||||
if(urlMatches !== null) {
|
||||
link = urlMatches[0];
|
||||
|
Loading…
Reference in New Issue
Block a user