refactor name and icon get

This commit is contained in:
kwaroran
2024-07-29 23:36:52 +09:00
parent 47c3fab589
commit 9d5b5da351
13 changed files with 73 additions and 45 deletions

View File

@@ -103,10 +103,25 @@ export const replacePlaceholders = (msg:string, name:string) => {
let selectedChar = get(selectedCharID)
let currentChar = db.characters[selectedChar]
return msg .replace(/({{char}})|({{Char}})|(<Char>)|(<char>)/gi, currentChar.name)
.replace(/({{user}})|({{User}})|(<User>)|(<user>)/gi, db.username)
.replace(/({{user}})|({{User}})|(<User>)|(<user>)/gi, getUserName())
.replace(/(\{\{((set)|(get))var::.+?\}\})/gu,'')
}
export function getUserName(){
const db = get(DataBase)
return db.username ?? 'User'
}
export function getUserIcon(){
const db = get(DataBase)
return db.userIcon ?? ''
}
export function getUserPersonaDesc(){
const db = get(DataBase)
return db.personaPrompt ?? ''
}
export function checkIsIos(){
return /(iPad|iPhone|iPod)/g.test(navigator.userAgent)
}