mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 03:33:07 +01:00
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];
|
||||
|
||||
this.api.addQuote(key, quote, event.user, function(newCount) {
|
||||
dbot.api.event.emit('~qadd', [ key, quote ]);
|
||||
event.reply(dbot.t('quote_saved', {
|
||||
'category': key,
|
||||
'count': newCount
|
||||
}));
|
||||
if(newCount) {
|
||||
dbot.api.event.emit('~qadd', [ key, quote ]);
|
||||
event.reply(dbot.t('quote_saved', {
|
||||
'category': key,
|
||||
'count': newCount
|
||||
}));
|
||||
} else {
|
||||
event.reply(dbot.t('quote_exists'));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -76,11 +76,15 @@ var quotes = function(dbot) {
|
||||
};
|
||||
}
|
||||
|
||||
newCount = category.quotes.push(quote);
|
||||
this.db.save('quote_category', category.id, category, function(err) {
|
||||
this.rmAllowed = true;
|
||||
callback(newCount);
|
||||
}.bind(this));
|
||||
if(_.include(category.quotes, quote)) {
|
||||
callback(false);
|
||||
} else {
|
||||
newCount = category.quotes.push(quote);
|
||||
this.db.save('quote_category', category.id, category, function(err) {
|
||||
this.rmAllowed = true;
|
||||
callback(newCount);
|
||||
}.bind(this));
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user