Skip to content

Commit

Permalink
Merge pull request #156 from destinygg/chore/redirect-dgg-addban
Browse files Browse the repository at this point in the history
chore: redirect !addban and !removeban to native versions
  • Loading branch information
11k committed Apr 11, 2024
2 parents 6c20d1e + d0c7d64 commit 141003a
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 64 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ services
services.scheduledCommands,
services.fakeScheduler,
services.messageRelay,
services.bannedPhrases,
);
chatServiceRouter.create();
})
Expand Down
10 changes: 0 additions & 10 deletions lib/chat-utils/parse-commands-from-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ function parseCommand(message) {
return { commandString: commandString.toLowerCase(), input };
}

function formatAddPhrase(phrase) {
return `ADDPHRASE ${JSON.stringify({ data: phrase })}`;
}

function formatRemovePhrase(phrase) {
return `REMOVEPHRASE ${JSON.stringify({ data: phrase })}`;
}

module.exports = {
parseMessage,
parseCommand,
Expand All @@ -79,6 +71,4 @@ module.exports = {
formatPoll,
parseWhisper,
formatWhisper,
formatAddPhrase,
formatRemovePhrase,
};
7 changes: 2 additions & 5 deletions lib/commands/implementations/banphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ function banPhraseTwitch(defaultPunishmentDuration, punishmentType) {
}

function banPhraseDGG() {
return (input, services) => {
const matched = /(\d+[HMDSWwhmds])?\s?(.*)/.exec(input);
const bannedPhrase = _.get(matched, 2, '');
services.bannedPhrases.addBannedPhrase(bannedPhrase);
return new CommandOutput(null, 'Phrase banned!');
return () => {
return new CommandOutput(null, 'This command has been removed, use native /addban instead.');
};
}

Expand Down
6 changes: 2 additions & 4 deletions lib/commands/implementations/unbanphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ function unbanPhraseTwitch() {
}

function unbanPhraseDGG() {
return (input, services) => {
const bannedPhrase = input;
services.bannedPhrases.removeBannedPhrase(bannedPhrase);
return new CommandOutput(null, 'Phrase unbanned! AngelThump');
return () => {
return new CommandOutput(null, 'This command has been removed, use native /removeban instead.');
};
}

Expand Down
15 changes: 0 additions & 15 deletions lib/message-routing/chat-service-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class ChatServiceRouter {
messageSchedulerStream,
fakeScheduler,
messageRelay,
bannedPhrases,
) {
this.messageRouter = messageRouter;
this.commandRouter = commandRouter;
Expand All @@ -23,7 +22,6 @@ class ChatServiceRouter {
this.fakeScheduler = fakeScheduler;
// TODO just refactor other things to use the message relay
this.messageRelay = messageRelay;
this.bannedPhrases = bannedPhrases;
}

create() {
Expand Down Expand Up @@ -162,19 +160,6 @@ class ChatServiceRouter {
this.bot.sendMessage(punishmentObject.reason);
}
});

this.bannedPhrases.on('data', (obj) => {
switch (obj.action) {
case 'add':
this.bot.sendAddPhrase(obj.phrase);
break;
case 'remove':
this.bot.sendRemovePhrase(obj.phrase);
break;
default:
break;
}
})
}
}

Expand Down
17 changes: 0 additions & 17 deletions lib/services/banned-phrase-emitter.js

This file was deleted.

10 changes: 0 additions & 10 deletions lib/services/destinychat.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const {
formatUnmute,
formatBan,
formatUnban,
formatAddPhrase,
formatRemovePhrase,
formatPoll,
} = require('../chat-utils/parse-commands-from-chat');

Expand Down Expand Up @@ -121,14 +119,6 @@ class DestinyChat extends EventEmitter {
});
}

sendAddPhrase(phrase) {
this.ws.send(formatAddPhrase(phrase));
}

sendRemovePhrase(phrase) {
this.ws.send(formatRemovePhrase(phrase));
}

handleError(event) {
this.emit('error', event);
}
Expand Down
2 changes: 0 additions & 2 deletions lib/services/service-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const RedditVote = require('./reddit-vote');
const MessageRelay = require('./message-relay');
const messageMatchingService = require('./message-matching');
const HTMLMetadata = require('./html-metadata');
const BannedPhrases = require('./banned-phrase-emitter')

class Services {
constructor(serviceConfigurations, chatConnectedTo) {
Expand Down Expand Up @@ -50,7 +49,6 @@ class Services {
if (chatConnectedTo === 'dgg') {
this.redditVote = new RedditVote(serviceConfigurations.redditVote, this.logger);
}
this.bannedPhrases = new BannedPhrases();
}

prepareAsyncServices() {
Expand Down

0 comments on commit 141003a

Please sign in to comment.