fxTwitter (plugin) (#80)

Co-authored-by: splatterxl <splatterxl@outlook.ie>
Co-authored-by: Ven <vendicated@riseup.net>
This commit is contained in:
Berlin 2022-10-10 22:45:54 +02:00 committed by GitHub
parent 124d1ad9c7
commit 54198b1a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

22
src/plugins/fxTwitter.ts Normal file

@ -0,0 +1,22 @@
import definePlugin from "../utils/types";
import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents";
import { Devs } from "../utils/constants";
export default definePlugin({
name: "FxTwitter",
description: "Uses FxTwitter to improve embeds from twitter on send",
authors: [Devs.Samu],
dependencies: ["MessageEventsAPI"],
addPrefix(msg: MessageObject) {
msg.content = msg.content.replace(/https?:\/\/twitter\.com(?=\/.*?\/)/g, "https://fxtwitter.com");
},
start() {
this.preSend = addPreSendListener((_, msg) => this.addPrefix(msg));
},
stop() {
removePreSendListener(this.preSend);
}
});

@ -1,10 +1,11 @@
import definePlugin from "../utils/types"; import definePlugin from "../utils/types";
import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents"; import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents";
import { Devs } from "../utils/constants";
export default definePlugin({ export default definePlugin({
name: "NoCanaryMessageLinks", name: "NoCanaryMessageLinks",
description: "Removes the canary and ptb prefix from message links", description: "Removes the canary and ptb prefix from message links",
authors: [{ name: "ICodeInAssembly", id: 702973430449832038n }], authors: [Devs.Samu],
dependencies: ["MessageEventsAPI"], dependencies: ["MessageEventsAPI"],
removeBetas(msg: MessageObject) { removeBetas(msg: MessageObject) {

@ -34,5 +34,9 @@ export const Devs = Object.freeze({
Glitch: { Glitch: {
name: "Glitchy", name: "Glitchy",
id: 269567451199569920n id: 269567451199569920n
},
Samu: {
name: "Samu",
id: 702973430449832038n
} }
}); });