mirror of
https://github.com/reality/dbot.git
synced 2024-12-25 04:02:39 +01:00
double derp
This commit is contained in:
parent
f6b8ff9030
commit
b3a558d81c
@ -74,13 +74,11 @@ var sstats = function(dbot) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.listener = function(event) {
|
this.listener = function(event) {
|
||||||
if(event.message.charAt(0) != '~') return;
|
|
||||||
|
|
||||||
event.cStats.lines++;
|
event.cStats.lines++;
|
||||||
event.uStats.lines++;
|
event.uStats.lines++;
|
||||||
|
|
||||||
event.message = event.message.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()]/g, "");
|
var message = event.message.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()]/g, "");
|
||||||
var words = event.message.split(' '),
|
var words = message.split(' '),
|
||||||
wCount = words.length,
|
wCount = words.length,
|
||||||
capitals = 0,
|
capitals = 0,
|
||||||
curses = 0;
|
curses = 0;
|
||||||
@ -115,24 +113,26 @@ var sstats = function(dbot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Look for tracked words.
|
// Look for tracked words.
|
||||||
var wMap = {}; // Why reduce isn't working idk
|
if(event.message.charAt(0) != '~') return;
|
||||||
_.each(words, function(word) {
|
var wMap = {}; // Why reduce isn't working idk
|
||||||
word = word.toLowerCase();
|
_.each(words, function(word) {
|
||||||
if(!_.has(wMap, word)) wMap[word] = 0;
|
word = word.toLowerCase();
|
||||||
wMap[word]++;
|
if(!_.has(wMap, word)) wMap[word] = 0;
|
||||||
});
|
wMap[word]++;
|
||||||
_.each(wMap, function(count, word) {
|
});
|
||||||
this.api.getTrackedWord(word, function(tWord) {
|
_.each(wMap, function(count, word) {
|
||||||
if(tWord) {
|
this.api.getTrackedWord(word, function(tWord) {
|
||||||
tWord.total += count;
|
if(tWord) {
|
||||||
if(!_.has(tWord.channels, event.rChannel.id)) tWord.channels[event.rChannel.id] = 0;
|
tWord.total += count;
|
||||||
if(!_.has(tWord.users, event.rUser.id)) tWord.users[event.rUser.id] = 0;
|
if(!_.has(tWord.channels, event.rChannel.id)) tWord.channels[event.rChannel.id] = 0;
|
||||||
tWord.channels[event.rChannel.id] += count;
|
if(!_.has(tWord.users, event.rUser.id)) tWord.users[event.rUser.id] = 0;
|
||||||
tWord.users[event.rUser.id] += count;
|
tWord.channels[event.rChannel.id] += count;
|
||||||
this.db.save('tracked_words', word, tWord, function() {});
|
tWord.users[event.rUser.id] += count;
|
||||||
}
|
this.db.save('tracked_words', word, tWord, function() {});
|
||||||
}.bind(this));
|
}
|
||||||
}, this);
|
}.bind(this));
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
this.db.save('channel_stats', event.cStats.id, event.cStats, function() {});
|
this.db.save('channel_stats', event.cStats.id, event.cStats, function() {});
|
||||||
this.db.save('user_stats', event.uStats.id, event.uStats, function() {});
|
this.db.save('user_stats', event.uStats.id, event.uStats, function() {});
|
||||||
|
Loading…
Reference in New Issue
Block a user