From a44d68f6ef933120b158e7188067725c4a000da8 Mon Sep 17 00:00:00 2001 From: vyneer Date: Thu, 11 Apr 2024 22:17:53 +0300 Subject: [PATCH 1/2] chore: redirect !addban and !removeban to native versions --- lib/commands/implementations/banphrase.js | 7 ++----- lib/commands/implementations/unbanphrase.js | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/commands/implementations/banphrase.js b/lib/commands/implementations/banphrase.js index ef88a10..0e48f54 100644 --- a/lib/commands/implementations/banphrase.js +++ b/lib/commands/implementations/banphrase.js @@ -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.'); }; } diff --git a/lib/commands/implementations/unbanphrase.js b/lib/commands/implementations/unbanphrase.js index 2949de9..a629d24 100644 --- a/lib/commands/implementations/unbanphrase.js +++ b/lib/commands/implementations/unbanphrase.js @@ -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.'); }; } From d0c7d64714b8a652eccb89b6a9a23d84a52135d6 Mon Sep 17 00:00:00 2001 From: vyneer Date: Thu, 11 Apr 2024 22:48:39 +0300 Subject: [PATCH 2/2] chore: remove other phrases integration stuff --- index.js | 1 - lib/chat-utils/parse-commands-from-chat.js | 10 ---------- lib/message-routing/chat-service-router.js | 15 --------------- lib/services/banned-phrase-emitter.js | 17 ----------------- lib/services/destinychat.js | 10 ---------- lib/services/service-index.js | 2 -- 6 files changed, 55 deletions(-) delete mode 100644 lib/services/banned-phrase-emitter.js diff --git a/index.js b/index.js index 2468eab..1000875 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,6 @@ services services.scheduledCommands, services.fakeScheduler, services.messageRelay, - services.bannedPhrases, ); chatServiceRouter.create(); }) diff --git a/lib/chat-utils/parse-commands-from-chat.js b/lib/chat-utils/parse-commands-from-chat.js index 3716815..4d6be2b 100644 --- a/lib/chat-utils/parse-commands-from-chat.js +++ b/lib/chat-utils/parse-commands-from-chat.js @@ -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, @@ -79,6 +71,4 @@ module.exports = { formatPoll, parseWhisper, formatWhisper, - formatAddPhrase, - formatRemovePhrase, }; diff --git a/lib/message-routing/chat-service-router.js b/lib/message-routing/chat-service-router.js index c8b3a20..70905ca 100644 --- a/lib/message-routing/chat-service-router.js +++ b/lib/message-routing/chat-service-router.js @@ -11,7 +11,6 @@ class ChatServiceRouter { messageSchedulerStream, fakeScheduler, messageRelay, - bannedPhrases, ) { this.messageRouter = messageRouter; this.commandRouter = commandRouter; @@ -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() { @@ -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; - } - }) } } diff --git a/lib/services/banned-phrase-emitter.js b/lib/services/banned-phrase-emitter.js deleted file mode 100644 index 5eb1f09..0000000 --- a/lib/services/banned-phrase-emitter.js +++ /dev/null @@ -1,17 +0,0 @@ -const EventEmitter = require('events'); - -class BannedPhrases extends EventEmitter { - constructor() { - super(); - } - - addBannedPhrase(phrase) { - this.emit('data', { action: 'add', phrase }); - } - - removeBannedPhrase(phrase) { - this.emit('data', { action: 'remove', phrase }); - } -} - -module.exports = BannedPhrases; diff --git a/lib/services/destinychat.js b/lib/services/destinychat.js index d1b5771..4c2ccc2 100644 --- a/lib/services/destinychat.js +++ b/lib/services/destinychat.js @@ -12,8 +12,6 @@ const { formatUnmute, formatBan, formatUnban, - formatAddPhrase, - formatRemovePhrase, formatPoll, } = require('../chat-utils/parse-commands-from-chat'); @@ -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); } diff --git a/lib/services/service-index.js b/lib/services/service-index.js index f5d21c1..4721582 100644 --- a/lib/services/service-index.js +++ b/lib/services/service-index.js @@ -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) { @@ -50,7 +49,6 @@ class Services { if (chatConnectedTo === 'dgg') { this.redditVote = new RedditVote(serviceConfigurations.redditVote, this.logger); } - this.bannedPhrases = new BannedPhrases(); } prepareAsyncServices() {