Skip to content

Commit 141003a

Browse files
authored
Merge pull request #156 from destinygg/chore/redirect-dgg-addban
chore: redirect !addban and !removeban to native versions
2 parents 6c20d1e + d0c7d64 commit 141003a

File tree

8 files changed

+4
-64
lines changed

8 files changed

+4
-64
lines changed

index.js

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ services
7070
services.scheduledCommands,
7171
services.fakeScheduler,
7272
services.messageRelay,
73-
services.bannedPhrases,
7473
);
7574
chatServiceRouter.create();
7675
})

lib/chat-utils/parse-commands-from-chat.js

-10
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ function parseCommand(message) {
6060
return { commandString: commandString.toLowerCase(), input };
6161
}
6262

63-
function formatAddPhrase(phrase) {
64-
return `ADDPHRASE ${JSON.stringify({ data: phrase })}`;
65-
}
66-
67-
function formatRemovePhrase(phrase) {
68-
return `REMOVEPHRASE ${JSON.stringify({ data: phrase })}`;
69-
}
70-
7163
module.exports = {
7264
parseMessage,
7365
parseCommand,
@@ -79,6 +71,4 @@ module.exports = {
7971
formatPoll,
8072
parseWhisper,
8173
formatWhisper,
82-
formatAddPhrase,
83-
formatRemovePhrase,
8474
};

lib/commands/implementations/banphrase.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ function banPhraseTwitch(defaultPunishmentDuration, punishmentType) {
5151
}
5252

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

lib/commands/implementations/unbanphrase.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ function unbanPhraseTwitch() {
2020
}
2121

2222
function unbanPhraseDGG() {
23-
return (input, services) => {
24-
const bannedPhrase = input;
25-
services.bannedPhrases.removeBannedPhrase(bannedPhrase);
26-
return new CommandOutput(null, 'Phrase unbanned! AngelThump');
23+
return () => {
24+
return new CommandOutput(null, 'This command has been removed, use native /removeban instead.');
2725
};
2826
}
2927

lib/message-routing/chat-service-router.js

-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class ChatServiceRouter {
1111
messageSchedulerStream,
1212
fakeScheduler,
1313
messageRelay,
14-
bannedPhrases,
1514
) {
1615
this.messageRouter = messageRouter;
1716
this.commandRouter = commandRouter;
@@ -23,7 +22,6 @@ class ChatServiceRouter {
2322
this.fakeScheduler = fakeScheduler;
2423
// TODO just refactor other things to use the message relay
2524
this.messageRelay = messageRelay;
26-
this.bannedPhrases = bannedPhrases;
2725
}
2826

2927
create() {
@@ -162,19 +160,6 @@ class ChatServiceRouter {
162160
this.bot.sendMessage(punishmentObject.reason);
163161
}
164162
});
165-
166-
this.bannedPhrases.on('data', (obj) => {
167-
switch (obj.action) {
168-
case 'add':
169-
this.bot.sendAddPhrase(obj.phrase);
170-
break;
171-
case 'remove':
172-
this.bot.sendRemovePhrase(obj.phrase);
173-
break;
174-
default:
175-
break;
176-
}
177-
})
178163
}
179164
}
180165

lib/services/banned-phrase-emitter.js

-17
This file was deleted.

lib/services/destinychat.js

-10
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const {
1212
formatUnmute,
1313
formatBan,
1414
formatUnban,
15-
formatAddPhrase,
16-
formatRemovePhrase,
1715
formatPoll,
1816
} = require('../chat-utils/parse-commands-from-chat');
1917

@@ -121,14 +119,6 @@ class DestinyChat extends EventEmitter {
121119
});
122120
}
123121

124-
sendAddPhrase(phrase) {
125-
this.ws.send(formatAddPhrase(phrase));
126-
}
127-
128-
sendRemovePhrase(phrase) {
129-
this.ws.send(formatRemovePhrase(phrase));
130-
}
131-
132122
handleError(event) {
133123
this.emit('error', event);
134124
}

lib/services/service-index.js

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const RedditVote = require('./reddit-vote');
1919
const MessageRelay = require('./message-relay');
2020
const messageMatchingService = require('./message-matching');
2121
const HTMLMetadata = require('./html-metadata');
22-
const BannedPhrases = require('./banned-phrase-emitter')
2322

2423
class Services {
2524
constructor(serviceConfigurations, chatConnectedTo) {
@@ -50,7 +49,6 @@ class Services {
5049
if (chatConnectedTo === 'dgg') {
5150
this.redditVote = new RedditVote(serviceConfigurations.redditVote, this.logger);
5251
}
53-
this.bannedPhrases = new BannedPhrases();
5452
}
5553

5654
prepareAsyncServices() {

0 commit comments

Comments
 (0)