mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-14 17:13:03 -04:00
Fix Some Issues With WriteUpperCase
This commit is contained in:
parent
7110405ef6
commit
c58f76afa4
2 changed files with 17 additions and 22 deletions
|
@ -12,13 +12,12 @@ import { MessageStore } from "@webpack/common";
|
||||||
|
|
||||||
import { transferMessage } from "./native";
|
import { transferMessage } from "./native";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const presendObject: SendListener = async (channelId, msg, extra) => {
|
const presendObject: SendListener = async (channelId, msg, extra) => {
|
||||||
const messageRef = extra.replyOptions.messageReference;
|
const messageRef = extra.replyOptions.messageReference;
|
||||||
const repliedMessage = ((messageRef?.message_id && messageRef.channel_id) && MessageStore.getMessage(messageRef?.channel_id, messageRef?.message_id)) || undefined;
|
const repliedMessage = ((messageRef?.message_id && messageRef.channel_id) && MessageStore.getMessage(messageRef?.channel_id, messageRef?.message_id)) || undefined;
|
||||||
msg.content = await transferMessage(msg, Settings.plugins.Shakespearean.model, repliedMessage);
|
msg.content = await transferMessage(msg, Settings.plugins.Shakespearean.model, repliedMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "Shakespearean",
|
name: "Shakespearean",
|
||||||
description: "Makes every message you send shakespearean",
|
description: "Makes every message you send shakespearean",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
|
import { addPreSendListener, removePreSendListener, SendListener } from "@api/MessageEvents";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs, EquicordDevs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
@ -19,6 +19,19 @@ const settings = definePluginSettings(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const presendObject: SendListener = (_, msg) => {
|
||||||
|
const sentences = msg.content.split(/(?<=\w\.)\s/);
|
||||||
|
const blockedWordsArray: string[] = settings.store.blockedWords.split(", ");
|
||||||
|
|
||||||
|
msg.content = sentences.map(element => {
|
||||||
|
if (!blockedWordsArray.some(word => element.toLowerCase().startsWith(word.toLocaleLowerCase()))) {
|
||||||
|
return element.charAt(0).toUpperCase() + element.slice(1);
|
||||||
|
} else {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}).join(" ");
|
||||||
|
};
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "WriteUpperCase",
|
name: "WriteUpperCase",
|
||||||
description: "Changes the first Letter of each Sentence in Message Inputs to Uppercase",
|
description: "Changes the first Letter of each Sentence in Message Inputs to Uppercase",
|
||||||
|
@ -26,26 +39,9 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
this.preSend = addPreSendListener(async (_, message) => {
|
addPreSendListener(presendObject);
|
||||||
message.content = textProcessing(message.content);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
stop() {
|
stop() {
|
||||||
this.preSend = removePreSendListener(async (_, message) => {
|
removePreSendListener(presendObject);
|
||||||
message.content = textProcessing(message.content);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function textProcessing(textInput: string): string {
|
|
||||||
const sentences = textInput.split(/(?<=\w\.)\s/);
|
|
||||||
const blockedWordsArray: string[] = settings.store.blockedWords.split(", ");
|
|
||||||
|
|
||||||
return sentences.map(element => {
|
|
||||||
if (!blockedWordsArray.some(word => element.toLowerCase().startsWith(word.toLocaleLowerCase()))) {
|
|
||||||
return element.charAt(0).toUpperCase() + element.slice(1);
|
|
||||||
} else {
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
}).join(" ");
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue