From 36131de800a43d729bc8d04e9bd8a2e5ee5f28ee Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:01:37 -0400 Subject: [PATCH 01/43] Womp Womp --- src/plugins/_core/supportHelper.tsx | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index cba19f1e..08b30eac 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -17,6 +17,7 @@ */ import { addAccessory } from "@api/MessageAccessories"; +import { MessageObject } from "@api/MessageEvents"; import { definePluginSettings } from "@api/Settings"; import { getUserSettingLazy } from "@api/UserSettings"; import ErrorBoundary from "@components/ErrorBoundary"; @@ -24,10 +25,10 @@ import { Flex } from "@components/Flex"; import { Link } from "@components/Link"; import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab"; import { Devs, EquicordDevs, SUPPORT_CHANNEL_ID, SUPPORT_CHANNEL_IDS, VC_SUPPORT_CHANNEL_ID } from "@utils/constants"; -import { sendMessage } from "@utils/discord"; +import { getCurrentChannel, sendMessage } from "@utils/discord"; import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; -import { isEquicordPluginDev, isPluginDev, tryOrElse } from "@utils/misc"; +import { isEquicordPluginDev, isPluginDev, sleep, tryOrElse } from "@utils/misc"; import { relaunch } from "@utils/native"; import { onlyOnce } from "@utils/onlyOnce"; import { makeCodeblock } from "@utils/text"; @@ -135,6 +136,26 @@ function generatePluginList() { return content; } +function intoChunks(): string[] { + const messageContent: string = generatePluginList(); + if (messageContent.length <= 2000) return [messageContent]; + + let chunks: string[] = []; + for (let idx = 0; idx < messageContent.length; idx += 2000) { + chunks.push(messageContent.slice(idx, idx + 2000)); + } + chunks = chunks.map(e => e.trimStart().trimEnd()); + return chunks; +} + +async function sendMessages(channelId: string, messageContents: string[], delay: number) { + for (const messageContent of messageContents) { + const messageObject: Partial = { content: messageContent }; + sendMessage(channelId, messageObject); + await sleep(delay); + } +} + const checkForUpdatesOnce = onlyOnce(checkForUpdates); const settings = definePluginSettings({}).withPrivateSettings<{ @@ -171,7 +192,9 @@ export default definePlugin({ name: "equicord-plugins", description: "Send Equicord plugin list", predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || isEquicordPluginDev(UserStore.getCurrentUser()?.id) || AllowedChannelIds.includes(ctx.channel.id), - execute: () => ({ content: generatePluginList() }) + execute: (_, ctx) => { + sendMessages(ctx.channel.id, intoChunks(), Math.max(2000, getCurrentChannel().rateLimitPerUser ?? 0)); + } } ], From 740d6857d20f8aef15eb7dfbc1ea5f994589b747 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:06:11 -0400 Subject: [PATCH 02/43] Revert "Womp Womp" This reverts commit 36131de800a43d729bc8d04e9bd8a2e5ee5f28ee. --- src/plugins/_core/supportHelper.tsx | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index 08b30eac..cba19f1e 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -17,7 +17,6 @@ */ import { addAccessory } from "@api/MessageAccessories"; -import { MessageObject } from "@api/MessageEvents"; import { definePluginSettings } from "@api/Settings"; import { getUserSettingLazy } from "@api/UserSettings"; import ErrorBoundary from "@components/ErrorBoundary"; @@ -25,10 +24,10 @@ import { Flex } from "@components/Flex"; import { Link } from "@components/Link"; import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab"; import { Devs, EquicordDevs, SUPPORT_CHANNEL_ID, SUPPORT_CHANNEL_IDS, VC_SUPPORT_CHANNEL_ID } from "@utils/constants"; -import { getCurrentChannel, sendMessage } from "@utils/discord"; +import { sendMessage } from "@utils/discord"; import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; -import { isEquicordPluginDev, isPluginDev, sleep, tryOrElse } from "@utils/misc"; +import { isEquicordPluginDev, isPluginDev, tryOrElse } from "@utils/misc"; import { relaunch } from "@utils/native"; import { onlyOnce } from "@utils/onlyOnce"; import { makeCodeblock } from "@utils/text"; @@ -136,26 +135,6 @@ function generatePluginList() { return content; } -function intoChunks(): string[] { - const messageContent: string = generatePluginList(); - if (messageContent.length <= 2000) return [messageContent]; - - let chunks: string[] = []; - for (let idx = 0; idx < messageContent.length; idx += 2000) { - chunks.push(messageContent.slice(idx, idx + 2000)); - } - chunks = chunks.map(e => e.trimStart().trimEnd()); - return chunks; -} - -async function sendMessages(channelId: string, messageContents: string[], delay: number) { - for (const messageContent of messageContents) { - const messageObject: Partial = { content: messageContent }; - sendMessage(channelId, messageObject); - await sleep(delay); - } -} - const checkForUpdatesOnce = onlyOnce(checkForUpdates); const settings = definePluginSettings({}).withPrivateSettings<{ @@ -192,9 +171,7 @@ export default definePlugin({ name: "equicord-plugins", description: "Send Equicord plugin list", predicate: ctx => isPluginDev(UserStore.getCurrentUser()?.id) || isEquicordPluginDev(UserStore.getCurrentUser()?.id) || AllowedChannelIds.includes(ctx.channel.id), - execute: (_, ctx) => { - sendMessages(ctx.channel.id, intoChunks(), Math.max(2000, getCurrentChannel().rateLimitPerUser ?? 0)); - } + execute: () => ({ content: generatePluginList() }) } ], From 6398dbd716838e585de4fee9b3c321e5e26bc3c0 Mon Sep 17 00:00:00 2001 From: pan <93918332+Panniku@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:01:03 +0530 Subject: [PATCH 03/43] fix: background-primary (#30) * feat: plugin information in plugins tab * feat(equicordCSS): remove if hell and simplify * feat(Demonstration): notif reminder * fix(Demonstration): improvement * add devs * Updates And Fixes * Revert "Updates And Fixes" This reverts commit d84b833bc4acb84e332270c9880eedd17c1b09cd. * feat(ServerListIndicators): toggle compact and optimization * fix: background-primary --------- Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com> --- src/equicordplugins/serverSearch/styles.css | 2 +- src/plugins/serverListIndicators/styles.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/equicordplugins/serverSearch/styles.css b/src/equicordplugins/serverSearch/styles.css index 196d9535..db2e745a 100644 --- a/src/equicordplugins/serverSearch/styles.css +++ b/src/equicordplugins/serverSearch/styles.css @@ -11,7 +11,7 @@ flex-direction: column; align-items: center; justify-content: center; - background-color: var(--background-secondary); + background-color: var(--background-primary); height: 48px; width: 48px; border-radius: 100%; diff --git a/src/plugins/serverListIndicators/styles.css b/src/plugins/serverListIndicators/styles.css index 6fe2ef3b..d6fb68a5 100644 --- a/src/plugins/serverListIndicators/styles.css +++ b/src/plugins/serverListIndicators/styles.css @@ -12,7 +12,7 @@ flex-direction: column; align-items: center; justify-content: center; - background-color: var(--background-secondary); + background-color: var(--background-primary); height: 48px; width: 48px; border-radius: 100%; From 5ac9d0bc4c756e385ec0a3a6e143618641569b3f Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:59:03 -0400 Subject: [PATCH 04/43] Womp Womp --- src/equicordplugins/keywordNotify/index.tsx | 265 +++++++++++++++++--- src/utils/constants.ts | 4 + 2 files changed, 240 insertions(+), 29 deletions(-) diff --git a/src/equicordplugins/keywordNotify/index.tsx b/src/equicordplugins/keywordNotify/index.tsx index cadce33a..bd535b0f 100644 --- a/src/equicordplugins/keywordNotify/index.tsx +++ b/src/equicordplugins/keywordNotify/index.tsx @@ -7,23 +7,37 @@ import "./style.css"; import { DataStore } from "@api/index"; -import { showNotification } from "@api/Notifications"; import { definePluginSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import { Flex } from "@components/Flex"; import { DeleteIcon } from "@components/Icons"; import { EquicordDevs } from "@utils/constants"; import { Margins } from "@utils/margins"; +import { classes } from "@utils/misc"; import { useForceUpdater } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, ChannelStore, Forms, NavigationRouter, Select, Switch, TextInput, useState } from "@webpack/common"; -import { Message } from "discord-types/general/index.js"; +import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { Button, ChannelStore, Forms, Select, SelectedChannelStore, Switch, TabBar, TextInput, Tooltip, UserStore, useState } from "@webpack/common"; +import { Message, User } from "discord-types/general/index.js"; +import type { PropsWithChildren } from "react"; + +type IconProps = JSX.IntrinsicElements["svg"]; type KeywordEntry = { regex: string, listIds: Array, listType: ListType, ignoreCase: boolean; }; let keywordEntries: Array = []; +let currentUser: User; +let keywordLog: Array = []; +const recentMentionsPopoutClass = findByPropsLazy("recentMentionsPopout"); +const tabClass = findByPropsLazy("tab"); +const buttonClass = findByPropsLazy("size36"); + +const MenuHeader = findByCodeLazy(".getMessageReminders()).length"); +const Popout = findByCodeLazy("e.get(e.jumpTargetId"); +const createMessageRecord = findByCodeLazy(".createFromServer(", ".isBlockedForMessage", "messageReference:"); const KEYWORD_ENTRIES_KEY = "KeywordNotify_keywordEntries"; +const KEYWORD_LOG_KEY = "KeywordNotify_log"; const cl = classNameFactory("vc-keywordnotify-"); @@ -52,6 +66,32 @@ enum ListType { Whitelist = "Whitelist" } +interface BaseIconProps extends IconProps { + viewBox: string; +} + +function highlightKeywords(str: string, entries: Array) { + let regexes: Array; + try { + regexes = entries.map(e => new RegExp(e.regex, "g" + (e.ignoreCase ? "i" : ""))); + } catch (err) { + return [str]; + } + + const matches = regexes.map(r => str.match(r)).flat().filter(e => e != null) as Array; + if (matches.length === 0) { + return [str]; + } + + const idx = str.indexOf(matches[0]); + + return [ + {str.substring(0, idx)}, + {matches[0]}, + {str.substring(idx + matches[0].length)} + ]; +} + function Collapsible({ title, children }) { const [isOpen, setIsOpen] = useState(false); @@ -115,7 +155,7 @@ function ListedIds({ listIds, setListIds }) { ); } -function ListTypeSelector({ listType, setListType }) { +function ListTypeSelector({ listType, setListType }: { listType: ListType, setListType: (v: ListType) => void; }) { return (