no impersonating :)

This commit is contained in:
Skye 2023-03-11 11:18:54 +09:00
parent af36301c5e
commit 8b668d82bb
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -33,9 +33,8 @@ const openai = new OpenAIApi(configuration);
client.on("ready", async () => {
console.log(`Logged in as ${client.user?.tag}!`);
const channel = await client.channels.fetch(process.env.CHANNEL ?? '');
if (channel?.type != ChannelType.GuildText)
return
const channel = await client.channels.fetch(process.env.CHANNEL ?? "");
if (channel?.type != ChannelType.GuildText) return;
channel.send("\\Smolhaj Reset");
});
@ -50,7 +49,6 @@ client.on("messageCreate", async (message) => {
if (message.channel.type != ChannelType.GuildText) return;
if (message.content == "die") process.exit(1);
// "adapted" from https://github.com/ryanccn/blahaj/blob/main/src/chat.ts
await message.channel.sendTyping();
@ -86,11 +84,12 @@ client.on("messageCreate", async (message) => {
if (msg.author === msg.author.client.user) {
return { role: "assistant", content: msg.content };
}
let username = msg.member?.displayName ?? msg.author.username;
if (username == "skyevg" && msg.author.id != "1038096782963507210")
username = msg.author.username; // no impersonating :)
return {
role: "user",
content: `${msg.member?.displayName ?? msg.author.username}:${
msg.content
}`,
content: `${username}:${msg.content}`,
};
})
.values(),
@ -104,14 +103,16 @@ client.on("messageCreate", async (message) => {
const responseMessage = response.data.choices[0].message;
if (!responseMessage) return;
const lastMessage = msgs
const lastMessage =
msgs
.filter((msg) => {
if (msg.webhookId && !msg.content.startsWith("\\")) return true;
if (msg.author.bot && msg.author !== msg.author.client.user)
return false;
if (msg.content.startsWith("\\")) return false;
return true;
}).first() ?? message;
})
.first() ?? message;
const isAppropriate = await openai
.createModeration({ input: responseMessage.content })