2022-10-10 16:45:54 -04:00
|
|
|
import definePlugin from "../utils/types";
|
|
|
|
import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents";
|
|
|
|
import { Devs } from "../utils/constants";
|
|
|
|
|
2022-10-14 12:13:13 -04:00
|
|
|
const re = /https?:\/\/twitter\.com(?=\/\w+?\/status\/)/g;
|
|
|
|
|
2022-10-10 16:45:54 -04:00
|
|
|
export default definePlugin({
|
|
|
|
name: "FxTwitter",
|
|
|
|
description: "Uses FxTwitter to improve embeds from twitter on send",
|
|
|
|
authors: [Devs.Samu],
|
|
|
|
dependencies: ["MessageEventsAPI"],
|
|
|
|
|
|
|
|
addPrefix(msg: MessageObject) {
|
2022-10-14 12:13:13 -04:00
|
|
|
msg.content = msg.content.replace(re, "https://fxtwitter.com");
|
2022-10-10 16:45:54 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
start() {
|
|
|
|
this.preSend = addPreSendListener((_, msg) => this.addPrefix(msg));
|
|
|
|
},
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
removePreSendListener(this.preSend);
|
|
|
|
}
|
|
|
|
});
|