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

View File

@ -13,7 +13,9 @@ var command = function(dbot) {
*/ */
this.listener = function(event) { this.listener = function(event) {
var commandName = event.params[0]; var commandName = event.params[0];
if(dbot.config.debugMode) {
console.log('DEBUG: listener commandName: ' + commandName) console.log('DEBUG: listener commandName: ' + commandName)
}
if(commandName.charAt(0) != this.config.commandPrefix || this.config.passiveMode == true) { if(commandName.charAt(0) != this.config.commandPrefix || this.config.passiveMode == true) {
return; return;
} else } else
@ -66,8 +68,10 @@ var command = function(dbot) {
this.api.hasAccess(event, commandName, function(hasAccess) { this.api.hasAccess(event, commandName, function(hasAccess) {
if(dbot.config.debugMode) {
console.log('DEBUG: command -> api.hasAccess initiated') console.log('DEBUG: command -> api.hasAccess initiated')
console.log('DEBUG: commandName: ' + commandName) console.log('DEBUG: commandName: ' + commandName)
}
dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) { dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) {
dbot.api.ignore.isUserBanned(event.rUser, commandName, function(isBanned) { 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); var urlMatches = event.message.match(this.urlRegex);
if(urlMatches !== null) { if(urlMatches !== null) {
this.links[event.channel.name] = urlMatches[0]; this.links[event.channel.name] = urlMatches[0];
if(dbot.config.debugMode) {
console.log('DEBUG: got a link'); console.log('DEBUG: got a link');
}
if(this.config.autoTitle == true) { if(this.config.autoTitle == true) {
this.api.parseLink(urlMatches[0], function(result) { this.api.parseLink(urlMatches[0], function(result) {
event.reply(result); event.reply(result);

View File

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