Skip to content

Commit

Permalink
Merge pull request #144 from destinygg/temp-logging
Browse files Browse the repository at this point in the history
Logging user url map
  • Loading branch information
11k authored Jan 22, 2024
2 parents 53e5d2e + 2d9fe59 commit cfa2e27
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions lib/services/dgg-rolling-chat-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const similarity = require('../chat-utils/string-similarity');
// and then a simple formula to get the change in %

class ChatCache {
constructor(config, messageMatching) {
this.messageMatching = messageMatching;
constructor(config, services) {
this.logger = services.logger;
this.messageMatching = services.messageMatching;
this.messsagesToKeepPerUser = config.messsagesToKeepPerUser || 2;
this.maxMessagesInList = config.maxMessagesInList || 2000;
this.timeToLive = config.timeToLiveSeconds || 1800;
Expand All @@ -22,6 +23,8 @@ class ChatCache {
this.runningMessageList = [];
this.tombStoneMap = {};
this.startTombStoneInterval();

this.logger.info('Config loaded for Chat Cache:', config);
}

startTombStoneInterval() {
Expand Down Expand Up @@ -83,6 +86,7 @@ class ChatCache {
return;
}
this.messageMatching.getLinks(message).forEach((link) => {
this.logger.info('Cached viewer url:', { user, url: link.hostname + link.pathname, message });
if (!_.has(this.viewerUrlMap, user)) this.viewerUrlMap[user] = [];
this.viewerUrlMap[user].push({
url: link.hostname + link.pathname,
Expand Down
7 changes: 2 additions & 5 deletions lib/services/service-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ class Services {
this.sql = new Sql(serviceConfigurations.sql);
this.commandRegistry = new CommandRegistry();
this.messageMatching = messageMatchingService;
this.chatCache = new ChatCache(serviceConfigurations.chatCache, this.messageMatching);
this.chatCache = new ChatCache(serviceConfigurations.chatCache, this);
this.punishmentCache = new PunishmentCache(serviceConfigurations.punishmentCache);
this.roleCache = new RoleCache(serviceConfigurations.roleCache);
this.punishmentStream = new PunishmentStream(this);
this.spamDetection = new SpamDetection(
serviceConfigurations.spamDetection,
this.messageMatching,
);
this.spamDetection = new SpamDetection(serviceConfigurations.spamDetection, this);
this.scheduledCommands = new ScheduledCommands(serviceConfigurations.schedule);
this.gulag = gulagService;
this.lastfm = new LastFm(serviceConfigurations.lastFm);
Expand Down
7 changes: 5 additions & 2 deletions lib/services/spam-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const matchStringOrRegex = (message, phrase) => {
return _.includes(cleanMessage, cleanPhrase.toLowerCase());
};
class SpamDetection {
constructor(config, messageMatching) {
this.messageMatching = messageMatching;
constructor(config, services) {
this.logger = services.logger;
this.messageMatching = services.messageMatching;
this.asciiArtThreshold = config.asciiArtThreshold || 20;
this.asciiPunctuationCount = config.asciiPunctuationCount || 40;
this.matchPercentPerUserThreshold = config.matchPercentPerUserThreshold || 0.9;
Expand All @@ -28,6 +29,8 @@ class SpamDetection {
this.longWordThreshold = 90;
this.longWordAllowedSpaces = 4;
this.messageUrlSpamCount = config.messageUrlSpamCount || 3;

this.logger.info('Config loaded for Spam Detection:', config);
}

// Checks whether there's a large number of non ascii characters
Expand Down

0 comments on commit cfa2e27

Please sign in to comment.