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) {
dbot.api.link.addHandler(this.StatusRegex[s], function(event, matches) {
this.lookup(event, matches[1], s);
dbot.api.link.addHandler(s, this.StatusRegex[s], function(event, matches, name) {
this.lookup(event, matches[1], name);
}.bind(this));
}
}.bind(this);

View File

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