add charjs apis for bgembed (#324)

# PR Checklist
- [x] Did you check if it works normally in all models? *ignore this
when it dosen't uses models*
- [x] Did you check if it works normally in all of web, local and node
hosted versions? if it dosen't, did you blocked it in those versions?
- [x] Did you added a type def?

# Description

It seems like someone is holding breath for this.

![output](https://github.com/kwaroran/RisuAI/assets/133192207/1da08982-8d95-4cbf-aa11-8ca3b0c8b671)
This commit is contained in:
kwaroran
2024-03-25 02:01:57 +09:00
committed by GitHub

View File

@@ -183,6 +183,25 @@ addWorkerFunction('setCharacterFirstMessage', async (data:string) => {
return true
})
addWorkerFunction('getBackgroundEmbedding', async () => {
const db = get(DataBase)
const selectedChar = get(selectedCharID)
const char = db.characters[selectedChar]
return char.backgroundHTML
})
addWorkerFunction('setBackgroundEmbedding', async (data:string) => {
const db = get(DataBase)
const selectedChar = get(selectedCharID)
if(typeof data !== 'string'){
return false
}
db.characters[selectedChar].backgroundHTML = data
setDatabase(db)
return true
})
addWorkerFunction('getState', async (statename) => {
const db = get(DataBase)
const selectedChar = get(selectedCharID)