forked from GitHub/dbot
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
|
* Description: Stores recent channel links, with commands to retrieve
|
||||||
* information about links.
|
* information about links.
|
||||||
*/
|
*/
|
||||||
var request = require('request');
|
var request = require('request'),
|
||||||
|
_ = require('underscore')._;
|
||||||
|
|
||||||
var link = function(dbot) {
|
var link = function(dbot) {
|
||||||
var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
||||||
var links = {};
|
var links = {};
|
||||||
@ -22,7 +24,7 @@ var link = function(dbot) {
|
|||||||
var commands = {
|
var commands = {
|
||||||
'~title': function(event) {
|
'~title': function(event) {
|
||||||
var link = links[event.channel.name];
|
var link = links[event.channel.name];
|
||||||
if(event.params[1] !== undefined) {
|
if(_.isUndefined(event.params[1])) {
|
||||||
var urlMatches = event.params[1].match(urlRegex);
|
var urlMatches = event.params[1].match(urlRegex);
|
||||||
if(urlMatches !== null) {
|
if(urlMatches !== null) {
|
||||||
link = urlMatches[0];
|
link = urlMatches[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user