Fix for the Identica bit by allowing a name argument to be passed [#344]

This commit is contained in:
reality 2013-04-12 19:11:55 +00:00
parent 5d30261770
commit 0f298bd061
2 changed files with 9 additions and 5 deletions

View File

@ -66,8 +66,8 @@ var dent = function(dbot) {
} }
for(s in this.StatusRegex) { for(s in this.StatusRegex) {
dbot.api.link.addHandler(this.StatusRegex[s], function(event, matches) { dbot.api.link.addHandler(s, this.StatusRegex[s], function(event, matches, name) {
this.lookup(event, matches[1], s); this.lookup(event, matches[1], name);
}.bind(this)); }.bind(this));
} }
}.bind(this); }.bind(this);

View File

@ -33,8 +33,12 @@ var link = function(dbot) {
}; };
this.api = { this.api = {
'addHandler': function(regex, handler) { 'addHandler': function(name, regex, handler) {
this.handlers.push({ 'regex': regex, 'callback': handler }); this.handlers.push({
'name': name,
'regex': regex,
'callback': handler
});
} }
}; };
@ -111,7 +115,7 @@ var link = function(dbot) {
for(var i=0;i<this.handlers.length;i++) { for(var i=0;i<this.handlers.length;i++) {
var matches = this.handlers[i].regex.exec(urlMatches[0]); var matches = this.handlers[i].regex.exec(urlMatches[0]);
if(matches) { if(matches) {
this.handlers[i].callback(event, matches); this.handlers[i].callback(event, matches, this.handlers[i].name);
handlerFound = true; break; handlerFound = true; break;
} }
} }