mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-20 20:07:03 -04:00
new-plugin (spoilerMessages) funny troll plugin (#217)
* Create index.tsx * Update index.tsx * fix credits / remove duplicate import * Create index.tsx * Delete src/equicordplugins/messageDeleter/index.tsx * Update README.md * Update Plugin Count * Update index.tsx * Cross Comp * Update index.tsx * Update SetColorModal.tsx * Update index.tsx * Add files via upload * Update README.md --------- Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
parent
1d995a393a
commit
2e85e598bf
4 changed files with 210 additions and 9 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
import { Upload } from "@api/MessageEvents";
|
||||
import { Settings } from "@api/Settings";
|
||||
import { spoiler } from "@equicordplugins/spoilerMessages";
|
||||
import { tarExtMatcher } from "@plugins/anonymiseFileNames";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { ReporterTestable } from "@utils/types";
|
||||
|
||||
|
@ -34,7 +36,7 @@ export default definePlugin({
|
|||
// Taken from AnonymiseFileNames
|
||||
{
|
||||
find: "instantBatchUpload:",
|
||||
predicate: () => !Settings.plugins.AnonymiseFileNames.enabled,
|
||||
predicate: () => !Settings.plugins.AnonymiseFileNames.enabled && !Settings.plugins.SpoilerMessages,
|
||||
replacement: {
|
||||
match: /uploadFiles:(\i),/,
|
||||
replace:
|
||||
|
@ -44,7 +46,7 @@ export default definePlugin({
|
|||
// Also taken from AnonymiseFileNames
|
||||
{
|
||||
find: 'addFilesTo:"message.attachments"',
|
||||
predicate: () => !Settings.plugins.AnonymiseFileNames.enabled,
|
||||
predicate: () => !Settings.plugins.AnonymiseFileNames.enabled && !Settings.plugins.SpoilerMessages,
|
||||
replacement: {
|
||||
match: /(\i.uploadFiles\((\i),)/,
|
||||
replace: "$2.forEach(f=>f.filename=$self.fixExt(f)),$1",
|
||||
|
@ -53,10 +55,14 @@ export default definePlugin({
|
|||
],
|
||||
fixExt(upload: ExtUpload) {
|
||||
const file = upload.filename;
|
||||
const extIdx = file.lastIndexOf(".");
|
||||
const fileName = extIdx !== -1 ? file.substring(0, extIdx) : "";
|
||||
const tarMatch = tarExtMatcher.exec(file);
|
||||
const extIdx = tarMatch?.index ?? file.lastIndexOf(".");
|
||||
let fileName = extIdx !== -1 ? file.substring(0, extIdx) : "";
|
||||
const ext = extIdx !== -1 ? file.slice(extIdx) : "";
|
||||
const newExt = reverseExtensionMap[ext] || ext;
|
||||
if (Settings.plugins.SpoilerMessages.enabled) {
|
||||
fileName = spoiler(upload);
|
||||
}
|
||||
|
||||
return fileName + newExt;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue