From 503a2ec517dbcd6c2514629bbe67a31d2ddeec89 Mon Sep 17 00:00:00 2001 From: Berlin <39058370+somerandomcloud@users.noreply.github.com> Date: Fri, 18 Nov 2022 05:12:45 +0100 Subject: [PATCH] Add option to ignore incoming blocked messages (#179) --- src/plugins/noBlockedMessages.ts | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/plugins/noBlockedMessages.ts b/src/plugins/noBlockedMessages.ts index 6c7a4968..f6f226f2 100644 --- a/src/plugins/noBlockedMessages.ts +++ b/src/plugins/noBlockedMessages.ts @@ -17,12 +17,16 @@ */ import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import { lazyWebpack } from "../utils/misc"; +import definePlugin, { OptionType } from "../utils/types"; +import { Settings } from "../Vencord"; +import { filters } from "../webpack"; +const RelationshipStore = lazyWebpack(filters.byProps("getRelationships", "isBlocked")); export default definePlugin({ name: "NoBlockedMessages", description: "Hides all blocked messages from chat completely.", - authors: [Devs.rushii], + authors: [Devs.rushii, Devs.Samu], patches: [ { find: 'safety_prompt:"DMSpamExperiment",response:"show_redacted_messages"', @@ -32,6 +36,26 @@ export default definePlugin({ replace: ".collapsedReason;return null;return;" } ] + }, + { + find: "displayName=\"MessageStore\"", + predicate: () => Settings.plugins.NoBlockedMessages.ignoreBlockedMessages === true, + replacement: [ + { + match: /(?<=MESSAGE_CREATE:function\((\w)\){var \w=\w\.channelId,\w=\w\.message,\w=\w\.isPushNotification,\w=\w\.\w\.getOrCreate\(\w\));/, + replace: ";if(Vencord.Plugins.plugins.IgnoreBlockedUsers.isBlocked(n))return;" + } + ] } - ] + ], + options: { + ignoreBlockedMessages: { + description: "Completely ignores (recent) incoming messages from blocked users (locally).", + type: OptionType.BOOLEAN, + default: false, + restartNeeded: true, + }, + }, + isBlocked: message => + RelationshipStore.isBlocked(message.author.id) });