forked from GitHub/dbot
dont add quotes that already exist [#331]
This commit is contained in:
parent
f905c58877
commit
099d278cbc
@ -12,11 +12,15 @@ var commands = function(dbot) {
|
|||||||
quote = event.input[2];
|
quote = event.input[2];
|
||||||
|
|
||||||
this.api.addQuote(key, quote, event.user, function(newCount) {
|
this.api.addQuote(key, quote, event.user, function(newCount) {
|
||||||
dbot.api.event.emit('~qadd', [ key, quote ]);
|
if(newCount) {
|
||||||
event.reply(dbot.t('quote_saved', {
|
dbot.api.event.emit('~qadd', [ key, quote ]);
|
||||||
'category': key,
|
event.reply(dbot.t('quote_saved', {
|
||||||
'count': newCount
|
'category': key,
|
||||||
}));
|
'count': newCount
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('quote_exists'));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -76,11 +76,15 @@ var quotes = function(dbot) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
newCount = category.quotes.push(quote);
|
if(_.include(category.quotes, quote)) {
|
||||||
this.db.save('quote_category', category.id, category, function(err) {
|
callback(false);
|
||||||
this.rmAllowed = true;
|
} else {
|
||||||
callback(newCount);
|
newCount = category.quotes.push(quote);
|
||||||
}.bind(this));
|
this.db.save('quote_category', category.id, category, function(err) {
|
||||||
|
this.rmAllowed = true;
|
||||||
|
callback(newCount);
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user