From f21745305e6ef61538cd7ed2a20b7d2a8bc65011 Mon Sep 17 00:00:00 2001 From: thoso Date: Thu, 20 Feb 2014 06:32:46 +0100 Subject: [PATCH] Only known users can add quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit May not work due to callback inside dbot.users.api.isKnownUser(…) --- modules/quotes/commands.js | 8 ++++++++ modules/users/config.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index 83e596a..9a379d8 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -11,6 +11,10 @@ var commands = function(dbot) { var key = event.input[1].toLowerCase().trim(), quote = event.input[2]; + var server=event.server, + user=event.rUser; + if (dbot.users.api.isKnownUser(server,user,function(x) {return x})==true) + { this.api.addQuote(key, quote, event.user, function(newCount) { if(newCount) { dbot.api.event.emit('~qadd', [ key, quote ]); @@ -22,6 +26,10 @@ var commands = function(dbot) { event.reply(dbot.t('quote_exists')); } }); + } + else{ + event.reply(dbot.t('You have no permissions to add quotes. :(')); + } }, /*** Quote Retrieval ***/ diff --git a/modules/users/config.json b/modules/users/config.json index c9b6aa2..1a8c339 100644 --- a/modules/users/config.json +++ b/modules/users/config.json @@ -1,6 +1,6 @@ { "ignorable": false, - "dependencies": [ "event" ], + "dependencies": [ "event" , "users"], "dbKeys": [ "knownUsers" ], "dbType": "redis" }