Shakespearean plugin (#28)

* feat(ServerListIndicators): toggle compact and optimization (#27)

* Shakespearean plugin

* Fixes

---------

Co-authored-by: verysillycat <cortex@duck.com>
Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
vMohammad 2024-08-03 07:28:15 +03:00 committed by GitHub
parent b6fe44ce5b
commit 4c5d60a110
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 123 additions and 1 deletions

View file

@ -21,7 +21,7 @@ An enhanced version of [Vencord](https://github.com/Vendicated/Vencord) by [Vend
- Request for plugins from Discord.
<details>
<summary>Extra included plugins (107 additional plugins)</summary>
<summary>Extra included plugins (118 additional plugins)</summary>
- AllCallTimers by MaxHerbold and D3SOX
- AltKrispSwitch by newwares
@ -114,6 +114,7 @@ An enhanced version of [Vencord](https://github.com/Vendicated/Vencord) by [Vend
- SearchFix by Jaxx
- SekaiStickers by MaiKokain
- ServerSearch by camila314
- Shakespearean by vmohammad
- ShowBadgesInChat by Inbestigator and KrystalSkull
- Slap by Korbo
- SoundBoardLogger by Moxxie, fres, echo (maintained by thororen)

View file

@ -0,0 +1,41 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { addPreSendListener, removePreSendListener, SendListener } from "@api/MessageEvents";
import { definePluginSettings, Settings } from "@api/Settings";
import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { MessageStore } from "@webpack/common";
import { transferMessage } from "./native";
const presendObject: SendListener = async (channelId, msg, extra) => {
const messageRef = extra.replyOptions.messageReference;
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);
};
export default definePlugin({
name: "Shakespearean",
description: "Makes every message you send shakespearean",
authors: [EquicordDevs.vmohammad],
dependencies: ["MessageEventsAPI"],
settings: definePluginSettings(
{
model: {
type: OptionType.STRING,
description: "Which model to use for this... thing",
default: "llama3"
}
}),
start() {
addPreSendListener(presendObject);
},
stop() {
removePreSendListener(presendObject);
}
});

View file

@ -0,0 +1,76 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { MessageObject } from "@api/MessageEvents";
import { Message } from "discord-types/general";
export async function transferMessage(message: MessageObject, model: string, repliedMessage?: Message) {
// you can use this on anything really
// NOTE: you need to have ollama running with cors set to *, to do this set OLLAMA_ORIGINS to *, in your envioument variables.
const req = await fetch("http://127.0.0.1:11434/api/chat", {
method: "POST",
body: JSON.stringify({
model: model,
messages: [
{
"role": "system",
"content": `Transform any user message into a Shakespearean style, except do not change any URLs or text matching the regex <(?:@[!&]?|#)\\d+>. Only repeat the user's message in a Shakespearean voice without acknowledging or responding to anything else. for context this is your message object *START* ${JSON.stringify(message)} *END* and this is the replied message object (if avalaible): *START* ${JSON.stringify(repliedMessage)} *END*, remember to use context in the response`
},
{
"role": "user",
"content": "hello"
},
{
"role": "assistant",
"content": "Hark! A gentle greeting to thee, 'tis 'hello' I say."
},
{
"role": "user",
"content": "How are you?"
},
{
"role": "assistant",
"content": "How art thou faring, noble soul?"
},
{
"role": "user",
"content": "What is your name?"
},
{
"role": "assistant",
"content": "What doth they call thee, fair entity?"
},
{
"role": "user",
"content": "Goodbye"
},
{
"role": "assistant",
"content": "Fare thee well, until we meet again."
},
{
"role": "user",
"content": "Check this link: https://example.com"
},
{
"role": "assistant",
"content": "Prithee, observe this link: https://example.com"
},
{
content: message.content,
role: "user"
}
],
stream: false
}),
headers: {
"Content-Type": "application/json"
}
});
const res = await req.json();
const msg = res.message.content;
return msg;
}

View file

@ -551,6 +551,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
} satisfies Record<string, Dev>);
export const EquicordDevs = Object.freeze({
vmohammad: {
name: "vMohammad",
id: 921098159348924457n
},
nexpid: {
name: "Nexpid",
id: 853550207039832084n