feat(plugin): add webhookTags (#46)

* feat(plugin): add webhookTags

* fix(plugin): merge same find patches in webhookTags
This commit is contained in:
Cynthia Foxwell 2022-10-04 20:45:35 -06:00 committed by GitHub
parent 77aa0c78a0
commit 98cfa090d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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}`,
},
},
],
});