2022-10-29 22:53:23 +02:00
|
|
|
/*
|
|
|
|
* Vencord, a modification for Discord's desktop app
|
|
|
|
* Copyright (c) 2022 Vendicated and contributors
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2023-10-25 19:47:29 +02:00
|
|
|
import { definePluginSettings } from "@api/Settings";
|
2022-11-28 13:37:55 +01:00
|
|
|
import { Devs } from "@utils/constants";
|
2024-05-27 09:36:09 -07:00
|
|
|
import { Logger } from "@utils/Logger";
|
2023-10-25 19:47:29 +02:00
|
|
|
import definePlugin, { OptionType } from "@utils/types";
|
2024-05-27 09:36:09 -07:00
|
|
|
import presetQuotesText from "file://quotes.txt";
|
2022-10-29 22:53:23 +02:00
|
|
|
|
2024-05-27 09:36:09 -07:00
|
|
|
const presetQuotes = presetQuotesText.split("\n").map(quote => /^\s*[^#\s]/.test(quote) && quote.trim()).filter(Boolean) as string[];
|
|
|
|
const noQuotesQuote = "Did you really disable all loading quotes? What a buffoon you are...";
|
2022-10-29 22:53:23 +02:00
|
|
|
|
2023-10-25 19:47:29 +02:00
|
|
|
const settings = definePluginSettings({
|
|
|
|
replaceEvents: {
|
2024-05-27 09:36:09 -07:00
|
|
|
description: "Should this plugin also apply during events with special event themed quotes? (e.g. Halloween)",
|
2023-10-25 19:47:29 +02:00
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: true
|
2024-05-27 09:36:09 -07:00
|
|
|
},
|
|
|
|
enablePluginPresetQuotes: {
|
|
|
|
description: "Enable the quotes preset by this plugin",
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: true
|
|
|
|
},
|
|
|
|
enableDiscordPresetQuotes: {
|
|
|
|
description: "Enable Discord's preset quotes (including event quotes, during events)",
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
additionalQuotes: {
|
|
|
|
description: "Additional custom quotes to possibly appear, separated by the below delimiter",
|
|
|
|
type: OptionType.STRING,
|
|
|
|
default: "",
|
|
|
|
},
|
|
|
|
additionalQuotesDelimiter: {
|
|
|
|
description: "Delimiter for additional quotes",
|
|
|
|
type: OptionType.STRING,
|
|
|
|
default: "|",
|
|
|
|
},
|
2023-10-25 19:47:29 +02:00
|
|
|
});
|
|
|
|
|
2022-10-29 22:53:23 +02:00
|
|
|
export default definePlugin({
|
|
|
|
name: "LoadingQuotes",
|
|
|
|
description: "Replace Discords loading quotes",
|
2024-05-27 09:36:09 -07:00
|
|
|
authors: [Devs.Ven, Devs.KraXen72, Devs.UlyssesZhan],
|
2023-10-25 19:47:29 +02:00
|
|
|
|
|
|
|
settings,
|
|
|
|
|
2022-10-29 22:53:23 +02:00
|
|
|
patches: [
|
|
|
|
{
|
2024-05-27 09:36:09 -07:00
|
|
|
find: ".LOADING_DID_YOU_KNOW",
|
2023-10-25 19:47:29 +02:00
|
|
|
replacement: [
|
|
|
|
{
|
2024-05-27 09:36:09 -07:00
|
|
|
match: /"_loadingText".+?(?=(\i)\[.{0,10}\.random)/,
|
|
|
|
replace: "$&$self.mutateQuotes($1),"
|
2023-10-25 19:47:29 +02:00
|
|
|
},
|
|
|
|
{
|
2024-05-27 09:36:09 -07:00
|
|
|
match: /"_eventLoadingText".+?(?=(\i)\[.{0,10}\.random)/,
|
|
|
|
replace: "$&$self.mutateQuotes($1),",
|
2023-10-25 19:47:29 +02:00
|
|
|
predicate: () => settings.store.replaceEvents
|
|
|
|
}
|
2024-05-27 09:36:09 -07:00
|
|
|
]
|
2022-10-29 22:53:23 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2024-05-27 09:36:09 -07:00
|
|
|
mutateQuotes(quotes: string[]) {
|
|
|
|
try {
|
|
|
|
const { enableDiscordPresetQuotes, additionalQuotes, additionalQuotesDelimiter, enablePluginPresetQuotes } = settings.store;
|
|
|
|
|
|
|
|
if (!enableDiscordPresetQuotes)
|
|
|
|
quotes.length = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (enablePluginPresetQuotes)
|
|
|
|
quotes.push(...presetQuotes);
|
|
|
|
|
|
|
|
quotes.push(...additionalQuotes.split(additionalQuotesDelimiter).filter(Boolean));
|
2022-10-29 22:53:23 +02:00
|
|
|
|
2024-05-27 09:36:09 -07:00
|
|
|
if (!quotes.length)
|
|
|
|
quotes.push(noQuotesQuote);
|
|
|
|
} catch (e) {
|
|
|
|
new Logger("LoadingQuotes").error("Failed to mutate quotes", e);
|
|
|
|
}
|
2022-10-29 22:53:23 +02:00
|
|
|
}
|
|
|
|
});
|