Add option to ignore incoming blocked messages (#179)

This commit is contained in:
Berlin 2022-11-18 05:12:45 +01:00 committed by GitHub
parent 83b3b1f16b
commit 503a2ec517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,12 +17,16 @@
*/ */
import { Devs } from "../utils/constants"; 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({ export default definePlugin({
name: "NoBlockedMessages", name: "NoBlockedMessages",
description: "Hides all blocked messages from chat completely.", description: "Hides all blocked messages from chat completely.",
authors: [Devs.rushii], authors: [Devs.rushii, Devs.Samu],
patches: [ patches: [
{ {
find: 'safety_prompt:"DMSpamExperiment",response:"show_redacted_messages"', find: 'safety_prompt:"DMSpamExperiment",response:"show_redacted_messages"',
@ -32,6 +36,26 @@ export default definePlugin({
replace: ".collapsedReason;return null;return;" 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)
}); });