From 98cfa090d4fcdf5ed934cf7435df9423fbe58932 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Tue, 4 Oct 2022 20:45:35 -0600 Subject: feat(plugin): add webhookTags (#46) * feat(plugin): add webhookTags * fix(plugin): merge same find patches in webhookTags --- src/plugins/webhookTags.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/plugins/webhookTags.ts (limited to 'src') diff --git a/src/plugins/webhookTags.ts b/src/plugins/webhookTags.ts new file mode 100644 index 0000000..70a1010 --- /dev/null +++ b/src/plugins/webhookTags.ts @@ -0,0 +1,33 @@ +import definePlugin from "../utils/types"; +import { Devs } from "../utils/constants"; + +export default definePlugin({ + name: "Webhook Tags", + description: "Changes the bot tag to say webhook for webhooks", + authors: [Devs.Cyn], + patches: [ + { + find: '.BOT=0]="BOT"', + replacement: [ + { + match: /(.)\[.\.BOT=0\]="BOT";/, + replace: (orig, types) => + `${types}[${types}.WEBHOOK=99]="WEBHOOK";${orig}`, + }, + { + match: /case (.)\.BOT:default:(.)=/, + replace: (orig, types, text) => + `case ${types}.WEBHOOK:${text}="WEBHOOK";break;${orig}`, + }, + ], + }, + { + find: ".Types.ORIGINAL_POSTER", + replacement: { + match: /return null==(.)\?null:.\.createElement\((.)\.Z/, + replace: (orig, type, BotTag) => + `if(${type}==${BotTag}.Z.Types.BOT&&arguments[0].user.isNonUserBot()){${type}=${BotTag}.Z.Types.WEBHOOK}${orig}`, + }, + }, + ], +}); -- cgit