From d804720357dfeb6f9933bd8c5b998c15caf035dc Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Thu, 9 Mar 2023 01:40:30 +0200 Subject: [PATCH] Improvements to group chats --- public/index.html | 55 ++++++++++++++++++++++++++++++++++------------- public/style.css | 2 +- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/public/index.html b/public/index.html index ef250a783..dd824ef16 100644 --- a/public/index.html +++ b/public/index.html @@ -924,15 +924,15 @@ return name; } - function checkWorldInfo(chat) { - function substituteParams(content) { - content = content.replace(/{{user}}/gi, name1); - content = content.replace(/{{char}}/gi, name2); - content = content.replace(//gi, name1); - content = content.replace(//gi, name2); - return content; - } + function substituteParams(content) { + content = content.replace(/{{user}}/gi, name1); + content = content.replace(/{{char}}/gi, name2); + content = content.replace(//gi, name1); + content = content.replace(//gi, name2); + return content; + } + function checkWorldInfo(chat) { if (world_info_data.entries.length == 0) { return ''; } @@ -1017,7 +1017,7 @@ return; } - const newMessage = { ... systemMessage, 'send_date': Date.now() }; + const newMessage = { ... systemMessage, 'send_date': humanizedISO8601DateTime() }; chat.push(newMessage); addOneMessage(newMessage); is_send_press = false; @@ -1669,7 +1669,7 @@ if (type === 'group_chat') { let avatarImg = 'img/fluffy.png'; if (characters[this_chid].avatar != 'none'){ - avatarImg = `characters/${characters[this_chid].avatar}`; + avatarImg = `characters/${characters[this_chid].avatar}?${Date.now()}`; } chat[chat.length-1]['is_name'] = true; chat[chat.length-1]['force_avatar'] = avatarImg; @@ -2112,6 +2112,27 @@ } else { sendSystemMessage(system_message_types.GROUP); + const group = groups.find(x => x.id === id); + if (group && Array.isArray(group.members)) { + for (let name of group.members) { + const character = characters.find(x => x.name === name); + + if (!character) { + continue; + } + + const mes = {}; + mes['is_user'] = false; + mes['is_system'] = false; + mes['name'] = character.name; + mes['is_name'] = true; + mes['send_date'] = humanizedISO8601DateTime(); + mes['mes'] = character.first_mes ? substituteParams(character.first_mes.trim()) : mes['mes'] = default_ch_mes; + mes['force_avatar'] = character.avatar != 'none' ? `characters/${character.avatar}?${Date.now()}` : 'img/fluffy.png'; + chat.push(mes); + addOneMessage(mes); + } + } } await saveGroupChat(id); @@ -2453,7 +2474,7 @@ if(characters[chid].avatar != 'none'){ this_avatar = "characters/"+characters[chid].avatar; } - $("#avatar_load_preview").attr('src',this_avatar+"#"+Date.now()); + $("#avatar_load_preview").attr('src',this_avatar+"?"+Date.now()); $("#name_div").css("display", "none"); $("#form_create").attr("actiontype", "editcharacter"); @@ -3806,7 +3827,7 @@ //******************** //***Message Editor*** $(document).on('click', '.mes_edit', function(){ - if(this_chid !== undefined){ + if(this_chid !== undefined || selected_group){ const message = $(this).closest('.mes'); if (message.data('isSystem')) { @@ -3842,7 +3863,11 @@ var text = chat[edit_mes_id]['mes']; if(chat[edit_mes_id]['is_user']){ this_edit_mes_chname = name1; - }else{ + } + else if (chat[edit_mes_id]['forced_avatar']) { + this_edit_mes_chname = chat[edit_mes_id]['name']; + } + else{ this_edit_mes_chname = name2; } text = text.trim(); @@ -5121,9 +5146,9 @@

Auto Mode

- +
 
- +
diff --git a/public/style.css b/public/style.css index 42fde61dc..f3ae472ec 100644 --- a/public/style.css +++ b/public/style.css @@ -1861,7 +1861,7 @@ border-radius: 5px; #rm_group_top_bar { display: flex; flex-direction: row; - align-items: flex-start; + align-items: center; width: 100%; } #rm_button_group_chats{