Skip to content

Commit 3f6ec02

Browse files
authored
fix: !reset in dm (#158)
1 parent 133a6ff commit 3f6ec02

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/handlers/command.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GroupChat, Message } from "whatsapp-web.js";
22
import { promptTracker } from "../clients/prompt";
3-
import { sydney } from "../clients/sydney";
3+
import { idsCache, sydney } from "../clients/sydney";
44
import { config } from "../config";
55
import { getAvailableTones, react } from "../utils";
66
import { reminderDB, reminders } from "./reminder";
@@ -40,14 +40,24 @@ export async function handleCommand(
4040
});
4141

4242
if (admins.includes(message.author)) {
43-
await sydney.conversationsCache.delete(chat.id._serialized);
43+
console.log("admins:", admins);
44+
let onGoingConversation = await idsCache.get(chat.id._serialized);
45+
const conversationData = JSON.parse(onGoingConversation);
46+
let jailbreakId = conversationData.jailbreakConversationId;
47+
console.log("jailbreakId:", jailbreakId);
48+
await sydney.conversationsCache.delete(jailbreakId);
49+
await idsCache.delete(chat.id._serialized);
4450
await message.reply("Conversation history reset.");
4551
} else {
4652
await message.reply("You are not allowed to perform this command.");
4753
}
4854
break;
4955
} else {
50-
await sydney.conversationsCache.delete(chat.id._serialized);
56+
let onGoingConversation = await idsCache.get(chat.id._serialized);
57+
const conversationData = JSON.parse(onGoingConversation);
58+
let jailbreakId = conversationData.jailbreakConversationId;
59+
await idsCache.delete(chat.id._serialized);
60+
await sydney.conversationsCache.delete(jailbreakId);
5161
await message.reply("Conversation history reset.");
5262
break;
5363
}

src/handlers/message.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ async function askSydney(prompt: string, chatId: string, context: string) {
237237
const conversationData = JSON.parse(onGoingConversation);
238238
options.parentMessageId = conversationData.messageId;
239239
options.jailbreakConversationId = conversationData.jailbreakConversationId;
240+
console.log(
241+
"options.jailbreakConversationId:",
242+
options.jailbreakConversationId
243+
);
240244
}
241245

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

0 commit comments

Comments
 (0)