Files
ST-Amily2-Chat-Optimisation/core/events.js
2025-09-04 17:00:57 +08:00

2 lines
6.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function(_0x343fcc,_0x28e8c1){const _0x26b572=_0x4ad7,_0x20ebe6=_0x343fcc();while(!![]){try{const _0xd4acd6=-parseInt(_0x26b572(0x1dc))/0x1*(-parseInt(_0x26b572(0x1b3))/0x2)+parseInt(_0x26b572(0x1d7))/0x3*(parseInt(_0x26b572(0x1dd))/0x4)+-parseInt(_0x26b572(0x1ce))/0x5*(-parseInt(_0x26b572(0x1b5))/0x6)+-parseInt(_0x26b572(0x1bb))/0x7*(-parseInt(_0x26b572(0x1c9))/0x8)+parseInt(_0x26b572(0x1ae))/0x9+-parseInt(_0x26b572(0x1cc))/0xa+-parseInt(_0x26b572(0x1d4))/0xb;if(_0xd4acd6===_0x28e8c1)break;else _0x20ebe6['push'](_0x20ebe6['shift']());}catch(_0x47f320){_0x20ebe6['push'](_0x20ebe6['shift']());}}}(_0x411d,0x3c848));import{getContext,extension_settings}from'/scripts/extensions.js';function _0x411d(){const _0x24a60e=['1IpwaoG','8wWOxjY','addHighlight','length','573291fwwLCt','main-api','optimized','loadTables','colIndex','665320TjAtpN','optimizationMode','259926bzrXxr','info','enabled','chat','tableIndex',',流程中止。','110306tzLvCY','is_user','\x20并保存。','\x20是用户消息无需处理。','slice','apiUrl','warn','【监察系统】表格系统总开关已关闭,跳过所有表格处理。','mes','setMemoryState','secondary-api','success','【监察系统】检测到\x22分步填表\x22或\x22优化中填表\x22模式已启用主API填表逻辑已自动禁用。','optimizedContent','184qQvRXX','refresh','filling_mode','1047190UmcbXh','saveStateToMessage','35XzjGAQ','[分步填表]\x20表格系统总开关已关闭跳过分步填表处理。','contextMessages','error','executeCommands','[Amily2号-正文优化]\x20检测到消息并非AI对用户的直接回复已跳过优化。','11362285toUfCS','optimizationEnabled','【监察系统-步骤3】检测到变化已将新状态写入消息\x20','485241tIpOQF','table_system_enabled','【监察系统】正在处理的奏折内容:\x20\x22','isWaitingForUserInput','forEach'];_0x411d=function(){return _0x24a60e;};return _0x411d();}function _0x4ad7(_0x34a20c,_0x5a707e){const _0x411da2=_0x411d();return _0x4ad7=function(_0x4ad770,_0xe7eec5){_0x4ad770=_0x4ad770-0x1ac;let _0x5de2f1=_0x411da2[_0x4ad770];return _0x5de2f1;},_0x4ad7(_0x34a20c,_0x5a707e);}import{saveChatConditional}from'/script.js';import{extensionName}from'../utils/settings.js';import*as _0x4e227f from'./table-system/manager.js';import*as _0x3a88bb from'./table-system/executor.js';import{renderTables}from'../ui/table-bindings.js';import{log}from'./table-system/logger.js';async function handleTableUpdate(_0x4b4c49){const _0x32d1ca=_0x4ad7,_0x5183b7=extension_settings[extensionName],_0x2b4af9=_0x5183b7['table_system_enabled']!==![];if(!_0x2b4af9){log(_0x32d1ca(0x1c2),_0x32d1ca(0x1b6));return;}const _0x38bc5f=_0x5183b7[_0x32d1ca(0x1cb)]||_0x32d1ca(0x1af);if(_0x38bc5f==='secondary-api'||_0x38bc5f===_0x32d1ca(0x1b0)){log(_0x32d1ca(0x1c7),'info');return;}log('【监察系统】接到圣旨,开始处理消息\x20ID:\x20'+_0x4b4c49,_0x32d1ca(0x1c1));const _0x13861b=getContext(),_0x22fe0b=_0x13861b[_0x32d1ca(0x1b8)][_0x4b4c49];if(!_0x22fe0b){log('【监察系统】错误:未找到消息\x20ID:\x20'+_0x4b4c49+_0x32d1ca(0x1ba),_0x32d1ca(0x1d1));return;}if(_0x22fe0b['is_user']){log('【监察系统】消息\x20ID:\x20'+_0x4b4c49+_0x32d1ca(0x1be),_0x32d1ca(0x1b6));return;}log(_0x32d1ca(0x1d9)+_0x22fe0b[_0x32d1ca(0x1c3)]['substring'](0x0,0x32)+'...\x22','info');const _0x2c9d78=_0x4e227f[_0x32d1ca(0x1b1)](_0x4b4c49);log('【监察系统-步骤1】为消息\x20'+_0x4b4c49+'\x20加载了基准状态。',_0x32d1ca(0x1b6),_0x2c9d78);const {finalState:_0x55ec2e,hasChanges:_0xfe9228,changes:_0x23dc3d}=_0x3a88bb[_0x32d1ca(0x1d2)](_0x22fe0b[_0x32d1ca(0x1c3)],_0x2c9d78);log('【监察系统-步骤2】推演完毕。是否有变化:\x20'+_0xfe9228,_0x32d1ca(0x1b6),_0x55ec2e),_0xfe9228?(_0x23dc3d&&_0x23dc3d['length']>0x0&&_0x23dc3d[_0x32d1ca(0x1db)](_0x37879f=>{const _0x4c7ff6=_0x32d1ca;_0x4e227f[_0x4c7ff6(0x1ac)](_0x37879f[_0x4c7ff6(0x1b9)],_0x37879f['rowIndex'],_0x37879f[_0x4c7ff6(0x1b2)]);}),_0x4e227f[_0x32d1ca(0x1cd)](_0x55ec2e,_0x22fe0b),_0x4e227f[_0x32d1ca(0x1c4)](_0x55ec2e),await saveChatConditional(),log(_0x32d1ca(0x1d6)+_0x4b4c49+_0x32d1ca(0x1bd),_0x32d1ca(0x1c6))):log('【监察系统-步骤3】未检测到有效指令或变化无需写入。',_0x32d1ca(0x1b6)),_0xfe9228&&renderTables();}import{processOptimization}from'./summarizer.js';import{executeAutoHide}from'./autoHideManager.js';import{checkAndTriggerAutoSummary}from'./historiographer.js';import{fillWithSecondaryApi}from'./table-system/secondary-filler.js';export async function onMessageReceived(_0x1c3985){const _0x49b924=_0x4ad7,_0x61c4cb=getContext();if(_0x1c3985&&_0x1c3985['is_user']||_0x61c4cb[_0x49b924(0x1da)])return;const _0x1d3981=extension_settings[extensionName],_0x4c9815=_0x61c4cb[_0x49b924(0x1b8)];if(!_0x4c9815||_0x4c9815['length']===0x0)return;const _0x307d18=_0x4c9815[_0x4c9815[_0x49b924(0x1ad)]-0x1];if(_0x307d18[_0x49b924(0x1bc)])return;const _0x350358=_0x1d3981[_0x49b924(0x1d8)]!==![];await executeAutoHide();const _0x4eef55=_0x1d3981[_0x49b924(0x1b7)]&&_0x1d3981[_0x49b924(0x1d5)]&&_0x1d3981[_0x49b924(0x1c0)];if(_0x4eef55){if(_0x4c9815[_0x49b924(0x1ad)]>=0x2&&_0x4c9815[_0x4c9815[_0x49b924(0x1ad)]-0x2][_0x49b924(0x1bc)]){const _0x1686d7=_0x1d3981[_0x49b924(0x1d0)]||0x2,_0x44859b=Math['max'](0x0,_0x4c9815[_0x49b924(0x1ad)]-0x1-_0x1686d7),_0x621b72=_0x4c9815[_0x49b924(0x1bf)](_0x44859b,_0x4c9815[_0x49b924(0x1ad)]-0x1),_0x5e7fc2=await processOptimization(_0x307d18,_0x621b72);_0x5e7fc2&&_0x5e7fc2['optimizedContent']&&_0x5e7fc2[_0x49b924(0x1c8)]!==_0x307d18[_0x49b924(0x1c3)]&&(_0x307d18[_0x49b924(0x1c3)]=_0x5e7fc2[_0x49b924(0x1c8)],await saveChatConditional(),_0x1d3981[_0x49b924(0x1b4)]===_0x49b924(0x1ca)&&await reloadCurrentChat());}else console['log'](_0x49b924(0x1d3));}if(_0x350358){const _0x11219d=_0x1d3981[_0x49b924(0x1cb)]||'main-api';_0x11219d===_0x49b924(0x1c5)&&fillWithSecondaryApi(_0x307d18);}else log(_0x49b924(0x1cf),'info');((async()=>{const _0x20d633=_0x49b924;try{await new Promise(_0x2a1efc=>setTimeout(_0x2a1efc,0x64)),await checkAndTriggerAutoSummary();}catch(_0x41af26){console[_0x20d633(0x1d1)]('[大史官]\x20后台自动总结任务执行时发生错误:',_0x41af26);}})());}export{handleTableUpdate};