Skip to content

Commit

Permalink
fix: !reset in dm (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luisotee authored Aug 28, 2023
1 parent 133a6ff commit 3f6ec02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/handlers/command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GroupChat, Message } from "whatsapp-web.js";
import { promptTracker } from "../clients/prompt";
import { sydney } from "../clients/sydney";
import { idsCache, sydney } from "../clients/sydney";
import { config } from "../config";
import { getAvailableTones, react } from "../utils";
import { reminderDB, reminders } from "./reminder";
Expand Down Expand Up @@ -40,14 +40,24 @@ export async function handleCommand(
});

if (admins.includes(message.author)) {
await sydney.conversationsCache.delete(chat.id._serialized);
console.log("admins:", admins);
let onGoingConversation = await idsCache.get(chat.id._serialized);
const conversationData = JSON.parse(onGoingConversation);
let jailbreakId = conversationData.jailbreakConversationId;
console.log("jailbreakId:", jailbreakId);
await sydney.conversationsCache.delete(jailbreakId);
await idsCache.delete(chat.id._serialized);
await message.reply("Conversation history reset.");
} else {
await message.reply("You are not allowed to perform this command.");
}
break;
} else {
await sydney.conversationsCache.delete(chat.id._serialized);
let onGoingConversation = await idsCache.get(chat.id._serialized);
const conversationData = JSON.parse(onGoingConversation);
let jailbreakId = conversationData.jailbreakConversationId;
await idsCache.delete(chat.id._serialized);
await sydney.conversationsCache.delete(jailbreakId);
await message.reply("Conversation history reset.");
break;
}
Expand Down
4 changes: 4 additions & 0 deletions src/handlers/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ async function askSydney(prompt: string, chatId: string, context: string) {
const conversationData = JSON.parse(onGoingConversation);
options.parentMessageId = conversationData.messageId;
options.jailbreakConversationId = conversationData.jailbreakConversationId;
console.log(
"options.jailbreakConversationId:",
options.jailbreakConversationId
);
}

const response: SydneyResponse = await sydney.sendMessage(prompt, options);
Expand Down

0 comments on commit 3f6ec02

Please sign in to comment.