feat: Add support for 'module_enabled' CBS

This commit is contained in:
kwaroran
2024-05-31 08:26:22 +09:00
parent 5e6ab7ff5a
commit 6b79ee872f
2 changed files with 13 additions and 1 deletions

View File

@@ -86,7 +86,7 @@ const normalCBS = [
'chat_index', 'first_msg_index', 'blank', 'none', 'message_time', 'message_date', 'time',
'date', 'isotime', 'isodate', 'message_idle_duration', 'idle_duration', 'br', 'newline',
'model', 'axmodel', 'role', 'jbtoggled', 'random', 'maxcontext', 'lastmessage', 'lastmessageid',
'lastmessageindex', 'emotionlist', 'assetlist', 'prefill_supported', 'unixtime', '/', '/if', '/each', '/pure', '/if_pure', 'slot'
'lastmessageindex', 'emotionlist', 'assetlist', 'prefill_supported', 'unixtime', '/', '/if', '/each', '/pure', '/if_pure', 'slot', 'module_enabled'
]
const normalCBSwithParams = [

View File

@@ -963,6 +963,18 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
case 'date_time_format':{
return dateTimeFormat(arra[1])
}
case 'module_enabled':{
const selchar = db.characters[get(selectedCharID)]
let enabledChatModules:string[] = []
if(!selchar){
enabledChatModules = selchar.chats[selchar.chatPage].modules ?? []
}
const moduleId = db.modules.find((f) => {
return f.name === arra[1]
}).id
return (db.enabledModules.includes(moduleId) || enabledChatModules.includes(moduleId)) ? '1' : '0'
}
}
}
if(p1.startsWith('random')){