mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-18 13:23:28 -05:00
Some Request Stuff
This commit is contained in:
parent
5e482418fd
commit
8be433bd72
3 changed files with 126 additions and 3 deletions
|
@ -7,9 +7,12 @@
|
|||
import { definePluginSettings, Settings } from "@api/Settings";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { MessageJSON } from "discord-types/general";
|
||||
|
||||
var blockedKeywords: Array<RegExp>;
|
||||
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
||||
|
||||
let blockedKeywords: Array<RegExp>;
|
||||
|
||||
const settings = definePluginSettings({
|
||||
blockedWords: {
|
||||
|
@ -29,7 +32,13 @@ const settings = definePluginSettings({
|
|||
description: "Whether to use a case sensitive search or not",
|
||||
default: false,
|
||||
restartNeeded: true
|
||||
}
|
||||
},
|
||||
ignoreBlockedMessages: {
|
||||
description: "Completely ignores (recent) new messages bar",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
restartNeeded: true,
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
|
@ -44,6 +53,18 @@ export default definePlugin({
|
|||
replace: "$&$1=$self.blockMessagesWithKeywords($1);"
|
||||
}
|
||||
},
|
||||
...[
|
||||
'"ReadStateStore"'
|
||||
].map(find => ({
|
||||
find,
|
||||
predicate: () => Settings.plugins.BlockKeywords.ignoreBlockedMessages && !Settings.plugins.NoBlockedMessages.ignoreBlockedMessages,
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<=MESSAGE_CREATE:function\((\i)\){)/,
|
||||
replace: (_, props) => `if($self.containsBlockedKeywords(${props}.message))return;`
|
||||
}
|
||||
]
|
||||
})),
|
||||
],
|
||||
|
||||
settings,
|
||||
|
|
98
src/equicordplugins/customTimestamps/index.tsx
Normal file
98
src/equicordplugins/customTimestamps/index.tsx
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Link } from "@components/Link";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Forms, moment } from "@webpack/common";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
cozyFormat: {
|
||||
type: OptionType.STRING,
|
||||
default: "[calendar]",
|
||||
description: "time format to use in messages on cozy mode",
|
||||
},
|
||||
compactFormat: {
|
||||
type: OptionType.STRING,
|
||||
default: "LT",
|
||||
description: "time format on compact mode and hovering messages",
|
||||
},
|
||||
tooltipFormat: {
|
||||
type: OptionType.STRING,
|
||||
default: "LLLL • [relative]",
|
||||
description: "time format to use on tooltips",
|
||||
},
|
||||
sameDayFormat: {
|
||||
type: OptionType.STRING,
|
||||
default: "HH:mm:ss",
|
||||
description: "[calendar] format for today"
|
||||
},
|
||||
lastDayFormat: {
|
||||
type: OptionType.STRING,
|
||||
default: "[yesterday] HH:mm:ss",
|
||||
description: "[calendar] format for yesterday"
|
||||
},
|
||||
lastWeekFormat: {
|
||||
type: OptionType.STRING,
|
||||
default: "ddd DD.MM.YYYY HH:mm:ss",
|
||||
description: "[calendar] format for last week"
|
||||
},
|
||||
sameElseFormat: {
|
||||
type: OptionType.STRING,
|
||||
default: "ddd DD.MM.YYYY HH:mm:ss",
|
||||
description: "[calendar] format for older dates"
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "CustomTimestamps",
|
||||
description: "Custom timestamps on messages and tooltips",
|
||||
authors: [Devs.Rini, EquicordDevs.nvhhr],
|
||||
settings,
|
||||
settingsAboutComponent: () => (
|
||||
<>
|
||||
<Forms.FormTitle tag="h3">How to use:</Forms.FormTitle>
|
||||
<Forms.FormText>
|
||||
<Link href="https://momentjs.com/docs/#/displaying/format/">Moment.js formatting documentation</Link>
|
||||
<p>
|
||||
Additionally you can use these in your inputs:<br />
|
||||
<b>[calendar]</b> enables dynamic date formatting (see options below),<br />
|
||||
<b>[relative]</b> gives you times such as "4 hours ago".<br />
|
||||
</p>
|
||||
</Forms.FormText>
|
||||
</>
|
||||
),
|
||||
patches: [{
|
||||
find: "MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format",
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<=\i=\i\?)\(0,\i\.\i\)\((\i),"LT"\):\(0,\i\.\i\)\(\i\)/,
|
||||
replace: '$self.format($1,"compactFormat","[calendar]"):$self.format($1,"cozyFormat","LT")',
|
||||
},
|
||||
{
|
||||
match: /(?<=text:)\(0,\i.\i\)\((\i),"LLLL"\)(?=,)/,
|
||||
replace: '$self.format($1,"tooltipFormat","LLLL")',
|
||||
},
|
||||
]
|
||||
}],
|
||||
|
||||
format(date: Date, key: string, fallback: string) {
|
||||
const t = moment(date);
|
||||
const sameDayFormat = settings.store.sameDayFormat || "HH:mm:ss";
|
||||
const lastDayFormat = settings.store.lastDayFormat || "[yesterday] HH:mm:ss";
|
||||
const lastWeekFormat = settings.store.lastWeekFormat || "ddd DD.MM.YYYY HH:mm:ss";
|
||||
const sameElseFormat = settings.store.sameElseFormat || "ddd DD.MM.YYYY HH:mm:ss";
|
||||
return t.format(settings.store[key] || fallback)
|
||||
.replace("relative", () => t.fromNow())
|
||||
.replace("calendar", () => t.calendar(null, {
|
||||
sameDay: sameDayFormat,
|
||||
lastDay: lastDayFormat,
|
||||
lastWeek: lastWeekFormat,
|
||||
sameElse: sameElseFormat
|
||||
}));
|
||||
},
|
||||
});
|
|
@ -945,7 +945,11 @@ export const EquicordDevs = Object.freeze({
|
|||
},
|
||||
SomeAspy: {
|
||||
name: "SomeAspy",
|
||||
id: 516750892372852754n,
|
||||
id: 516750892372852754n
|
||||
},
|
||||
nvhhr: {
|
||||
name: "nvhhr",
|
||||
id: 165098921071345666n
|
||||
},
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
|
|
Loading…
Reference in a new issue