realcoloride / node_characterai

Unofficial Character AI wrapper for node.
https://beta.character.ai/
341 stars 72 forks source link

Chat.deleteMessagesBulk() seems doesn't work #151

Closed dappgbut closed 6 months ago

dappgbut commented 6 months ago

Hello there, i tried to delete a messages using chat.deleteMessagesBulk() but somehow it returns with no errors and on the website itself, the messages didn't get deleted

Here is my code like (I recently making a chatbot using this package):

if (cmd == "deleteall") {
            (async () => {
                const characterId = "CharacterID";
                const chat = await characterai.createOrContinueChat(characterId);
                await chat.deleteMessagesBulk(50,false); //tried ...Bulk() ...Bulk(amount = 50, descending = false) and ...Bulk(50,false)
                console.log('passed 1');
            })
        }

Maybe are there something wrong on my code? or it's from the package-side (I saw some old issue about DeleteMessage, Like issue #14) ?

Any answers are appreciated, thank you.

realcoloride commented 6 months ago

Will investigate and try to check whats going on.

I'll keep you updated

dappgbut commented 6 months ago

Okay, Thank you. I'll be looking foward to this issue.

realcoloride commented 6 months ago

Hello, after investigation, it seems like they have (again) silently changed how their endpoints work image

It was previously ids_to_delete, now it is uuids_to_delete image

I'll keep you updated and try to push a fix soon.

realcoloride commented 6 months ago

Hello, I've pushed the following commit: https://github.com/realcoloride/node_characterai/commit/1a9c1a467110fe37ebff9d9c7726e9c0ea9e4e84

Which introduces fixes for deleting messages, rewrote the message bulk deleting to be more accurate & added uuids. Note: you now need to use message uuids instead of ids to delete specific messages.

Could you try it and tell me how it goes?

dappgbut commented 6 months ago

Hello, Sorry for the late response...

Thank you for the fixes!.. i'll try it soon in about a few hours when I got into my computer, and give you how it will goes...

realcoloride commented 6 months ago

Hello! Let me know. Make sure to clone the repo and replace it in the node_modules folder.

dappgbut commented 6 months ago

Hello, thank you for waiting...

I tried to do it outside of my chatbot code and separate the code into this:

const sessiontokenygy = "session token";

(async () => {
    await characterai.authenticateWithToken(sessiontokenygy);
    const characterId = "CharacterId";

    const chat = await characterai.createOrContinueChat(characterId);

    console.log("start deleting");
    await chat.deleteMessagesBulk(2,false,false);
    console.log("delete success");
})();

The console.log returns two of them, but when i check on the character ai website, the messages didn't get deleted...

start deleting
delete success

Any suggestions for this?...

realcoloride commented 6 months ago

are you looking at the old or new interface? (chat/chat2, see url)

dappgbut commented 6 months ago

After a bit of research, the website version does all the message deleted... I've been using the mobile version all the time to check it by the way... where it's kinda buggy...

Sorry my bad... but i'm glad it's working now...

Thank you for your patience in dealing with this issue!! 😀

realcoloride commented 6 months ago

No problem. Again the fact you've seen new changes is because its on the new ui, synced to the mobile one, using websockets.