Enclosing DEBUG statements in dbot.config.debugMode

Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
Georg Pfuetzenreuter 2021-08-29 20:24:53 +02:00
parent ac3d2761bc
commit 20582defd5
Signed by: Georg
GPG Key ID: 1DAF57F49F8E8F22
4 changed files with 20 additions and 0 deletions

View File

@ -6,12 +6,14 @@ var api = function(dbot) {
* Does the user have the correct access level to use the command?
*/
'hasAccess': function(event, command, callback) {
if(dbot.config.debugMode) {
console.log('DEBUG: command -> api -> hasAccess called')
var accessNeeded = dbot.commands[command].access,
allowedNicks,
user = event.rUser;
console.log('DEBUG: command: ' + command);
console.log('DEBUG: accessNeeded: ' + accessNeeded);
}
//var accessNeeded = null;
if(_.isUndefined(accessNeeded) || accessNeeded == null || accessNeeded == 'user') {
return callback(true);

View File

@ -13,7 +13,9 @@ var command = function(dbot) {
*/
this.listener = function(event) {
var commandName = event.params[0];
if(dbot.config.debugMode) {
console.log('DEBUG: listener commandName: ' + commandName)
}
if(commandName.charAt(0) != this.config.commandPrefix || this.config.passiveMode == true) {
return;
} else
@ -66,8 +68,10 @@ var command = function(dbot) {
this.api.hasAccess(event, commandName, function(hasAccess) {
if(dbot.config.debugMode) {
console.log('DEBUG: command -> api.hasAccess initiated')
console.log('DEBUG: commandName: ' + commandName)
}
dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) {
dbot.api.ignore.isUserBanned(event.rUser, commandName, function(isBanned) {

View File

@ -213,7 +213,9 @@ var link = function(dbot) {
var urlMatches = event.message.match(this.urlRegex);
if(urlMatches !== null) {
this.links[event.channel.name] = urlMatches[0];
if(dbot.config.debugMode) {
console.log('DEBUG: got a link');
}
if(this.config.autoTitle == true) {
this.api.parseLink(urlMatches[0], function(result) {
event.reply(result);

View File

@ -105,7 +105,9 @@ var quotes = function(dbot) {
if(removeRefs) {
quotes = _.filter(quotes, function(q) {
if(dbot.config.debugMode) {
console.log('DEBUG (if removeRefs): ' + removeRefs + quotes + key)
}
return !q.match('~~'+key+'~~');
});
}
@ -119,7 +121,9 @@ var quotes = function(dbot) {
},
'getInterpolatedQuote': function(server, channel, username, key, callback) {
if(dbot.config.debugMode) {
console.log('DEBUG: ' + channel + ' ' + username + ' ' + key)
}
key = key.trim().toLowerCase(),
this.api.getQuote(key, function(quote) {
@ -127,19 +131,25 @@ var quotes = function(dbot) {
this.internalAPI.interpolatedQuote(server, channel,
username, key, quote, callback);
} else {
if(dbot.config.debugMode) {
console.log('DEBUG (else callback quote): ' + quote)
}
callback(quote);
}
}.bind(this));
},
'getQuoteCategory': function(key, callback) {
if(dbot.config.debugMode) {
console.log('DEBUG: ' + key)
}
var category = false,
key = key.trim().toLowerCase();
this.db.search('quote_category', { 'name': key }, function(result) {
if(dbot.config.debugMode) {
console.log('DEBUG: ' + key + ' ' + result)
}
category = result;
}, function(err) {
callback(category);
@ -149,7 +159,9 @@ var quotes = function(dbot) {
'getCategoryKeys': function(callback) {
var keys = [];
this.db.scan('quote_category', function(result) {
if(dbot.config.debugMode) {
console.log('DEBUG: ' + result)
}
if(result) keys.push(result.name);
}, function(err) {
callback(keys);