mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-21 04:17:01 -04:00
Fixes For Canary
This commit is contained in:
parent
760d34ddc4
commit
d0a47aa602
7 changed files with 45 additions and 214 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
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";
|
||||
|
@ -36,33 +35,30 @@ export default definePlugin({
|
|||
// Taken from AnonymiseFileNames
|
||||
{
|
||||
find: "instantBatchUpload:",
|
||||
predicate: () => !Settings.plugins.AnonymiseFileNames.enabled && !Settings.plugins.SpoilerMessages,
|
||||
replacement: {
|
||||
match: /uploadFiles:(\i),/,
|
||||
replace:
|
||||
"uploadFiles:(...args)=>(args[0].uploads.forEach(f=>f.filename=$self.fixExt(f)),$1(...args)),",
|
||||
},
|
||||
predicate: () => !Settings.plugins.AnonymiseFileNames.enabled,
|
||||
},
|
||||
// Also taken from AnonymiseFileNames
|
||||
{
|
||||
find: 'addFilesTo:"message.attachments"',
|
||||
predicate: () => !Settings.plugins.AnonymiseFileNames.enabled && !Settings.plugins.SpoilerMessages,
|
||||
replacement: {
|
||||
match: /(\i.uploadFiles\((\i),)/,
|
||||
replace: "$2.forEach(f=>f.filename=$self.fixExt(f)),$1",
|
||||
},
|
||||
predicate: () => !Settings.plugins.AnonymiseFileNames.enabled,
|
||||
}
|
||||
],
|
||||
fixExt(upload: ExtUpload) {
|
||||
const file = upload.filename;
|
||||
const tarMatch = tarExtMatcher.exec(file);
|
||||
const extIdx = tarMatch?.index ?? file.lastIndexOf(".");
|
||||
let fileName = extIdx !== -1 ? file.substring(0, extIdx) : "";
|
||||
const 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