diff --git a/modules/sstats/sstats.js b/modules/sstats/sstats.js index 9f1f984..d10a037 100644 --- a/modules/sstats/sstats.js +++ b/modules/sstats/sstats.js @@ -74,6 +74,8 @@ var sstats = function(dbot) { }; this.listener = function(event) { + if(event.message.charAt(0) != '~') return; + event.cStats.lines++; event.uStats.lines++; @@ -113,26 +115,24 @@ var sstats = function(dbot) { } // Look for tracked words. - if(event.message.charAt(0) != '~') { - var wMap = {}; // Why reduce isn't working idk - _.each(words, function(word) { - word = word.toLowerCase(); - if(!_.has(wMap, word)) wMap[word] = 0; - wMap[word]++; - }); - _.each(wMap, function(count, word) { - this.api.getTrackedWord(word, function(tWord) { - if(tWord) { - tWord.total += count; - if(!_.has(tWord.channels, event.rChannel.id)) tWord.channels[event.rChannel.id] = 0; - if(!_.has(tWord.users, event.rUser.id)) tWord.users[event.rUser.id] = 0; - tWord.channels[event.rChannel.id] += count; - tWord.users[event.rUser.id] += count; - this.db.save('tracked_words', word, tWord, function() {}); - } - }.bind(this)); - }, this); - } + var wMap = {}; // Why reduce isn't working idk + _.each(words, function(word) { + word = word.toLowerCase(); + if(!_.has(wMap, word)) wMap[word] = 0; + wMap[word]++; + }); + _.each(wMap, function(count, word) { + this.api.getTrackedWord(word, function(tWord) { + if(tWord) { + tWord.total += count; + if(!_.has(tWord.channels, event.rChannel.id)) tWord.channels[event.rChannel.id] = 0; + if(!_.has(tWord.users, event.rUser.id)) tWord.users[event.rUser.id] = 0; + tWord.channels[event.rChannel.id] += count; + tWord.users[event.rUser.id] += count; + this.db.save('tracked_words', word, tWord, function() {}); + } + }.bind(this)); + }, this); this.db.save('channel_stats', event.cStats.id, event.cStats, function() {}); this.db.save('user_stats', event.uStats.id, event.uStats, function() {});