Files
ST-Amily2-Chat-Optimisation…/core/events.js
2025-08-20 06:17:18 +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(_0x448ef4,_0x36afb8){const _0x20501b=_0x14dd,_0x5c555c=_0x448ef4();while(!![]){try{const _0x464a27=-parseInt(_0x20501b(0x192))/0x1+-parseInt(_0x20501b(0x1bb))/0x2*(-parseInt(_0x20501b(0x1be))/0x3)+parseInt(_0x20501b(0x1b3))/0x4*(-parseInt(_0x20501b(0x1af))/0x5)+-parseInt(_0x20501b(0x19b))/0x6+-parseInt(_0x20501b(0x198))/0x7+-parseInt(_0x20501b(0x1c1))/0x8*(parseInt(_0x20501b(0x193))/0x9)+parseInt(_0x20501b(0x1ad))/0xa;if(_0x464a27===_0x36afb8)break;else _0x5c555c['push'](_0x5c555c['shift']());}catch(_0x3a1d98){_0x5c555c['push'](_0x5c555c['shift']());}}}(_0x402a,0x1f586));import{getContext,extension_settings}from'/scripts/extensions.js';import{saveChatConditional}from'/script.js';function _0x402a(){const _0x9767f=['【监察系统-步骤1】为消息\x20','table_system_enabled','[大史官]\x20后台自动总结任务执行时发生错误:','【监察系统-步骤3】检测到变化已将新状态写入消息\x20','mes','chat','executeCommands','substring','secondary-api','main-api','\x20是用户消息无需处理。','11158220upsyNr','isWaitingForUserInput','10mWxVsT','enabled','max','setMemoryState','483592jEEvUf','rowIndex','warn','【监察系统】检测到\x22分步填表\x22或\x22优化中填表\x22模式已启用主API填表逻辑已自动禁用。','optimizedContent','log','info','...\x22','1344fAJnNq','optimizationMode','【监察系统-步骤3】未检测到有效指令或变化无需写入。','30nhSuvg','is_user',',流程中止。','1278392rmtSRq','loadTables','slice','195210sTgKBk','9YvvTrQ','contextMessages','success','forEach','length','993048UHDyhW','saveStateToMessage','error','1532898gxNrKT','【监察系统】正在处理的奏折内容:\x20\x22','optimizationEnabled','[Amily2号]\x20检测到消息并非AI对用户的直接回复已跳过优化。','optimized','【监察系统-步骤2】推演完毕。是否有变化:\x20','[分步填表]\x20表格系统总开关已关闭跳过分步填表处理。'];_0x402a=function(){return _0x9767f;};return _0x402a();}import{extensionName}from'../utils/settings.js';function _0x14dd(_0x600b4d,_0x4e0dfd){const _0x402a7d=_0x402a();return _0x14dd=function(_0x14dde3,_0x10799e){_0x14dde3=_0x14dde3-0x192;let _0x43e06f=_0x402a7d[_0x14dde3];return _0x43e06f;},_0x14dd(_0x600b4d,_0x4e0dfd);}import*as _0x3d1607 from'./table-system/manager.js';import*as _0x9ff2a5 from'./table-system/executor.js';import{renderTables}from'../ui/table-bindings.js';import{log}from'./table-system/logger.js';async function handleTableUpdate(_0x46e8ee){const _0x305dc1=_0x14dd,_0x52061c=extension_settings[extensionName],_0x493df9=_0x52061c[_0x305dc1(0x1a3)]!==![];if(!_0x493df9){log('【监察系统】表格系统总开关已关闭,跳过所有表格处理。','info');return;}const _0x319d76=_0x52061c['filling_mode']||_0x305dc1(0x1ab);if(_0x319d76===_0x305dc1(0x1aa)||_0x319d76===_0x305dc1(0x19f)){log(_0x305dc1(0x1b6),_0x305dc1(0x1b9));return;}log('【监察系统】接到圣旨,开始处理消息\x20ID:\x20'+_0x46e8ee,_0x305dc1(0x1b5));const _0x135fe=getContext(),_0x40edfc=_0x135fe[_0x305dc1(0x1a7)][_0x46e8ee];if(!_0x40edfc){log('【监察系统】错误:未找到消息\x20ID:\x20'+_0x46e8ee+_0x305dc1(0x1c0),_0x305dc1(0x19a));return;}if(_0x40edfc[_0x305dc1(0x1bf)]){log('【监察系统】消息\x20ID:\x20'+_0x46e8ee+_0x305dc1(0x1ac),_0x305dc1(0x1b9));return;}log(_0x305dc1(0x19c)+_0x40edfc[_0x305dc1(0x1a6)][_0x305dc1(0x1a9)](0x0,0x32)+_0x305dc1(0x1ba),_0x305dc1(0x1b9));const _0x1e1287=_0x3d1607[_0x305dc1(0x1c2)](_0x46e8ee);log(_0x305dc1(0x1a2)+_0x46e8ee+'\x20加载了基准状态。',_0x305dc1(0x1b9),_0x1e1287);const {finalState:_0x38c12c,hasChanges:_0x1b6bbd,changes:_0x1b9a0c}=_0x9ff2a5[_0x305dc1(0x1a8)](_0x40edfc[_0x305dc1(0x1a6)],_0x1e1287);log(_0x305dc1(0x1a0)+_0x1b6bbd,_0x305dc1(0x1b9),_0x38c12c),_0x1b6bbd?(_0x1b9a0c&&_0x1b9a0c[_0x305dc1(0x197)]>0x0&&_0x1b9a0c[_0x305dc1(0x196)](_0x2eb98b=>{const _0x30e4ca=_0x305dc1;_0x3d1607['addHighlight'](_0x2eb98b['tableIndex'],_0x2eb98b[_0x30e4ca(0x1b4)],_0x2eb98b['colIndex']);}),_0x3d1607[_0x305dc1(0x199)](_0x38c12c,_0x40edfc),_0x3d1607[_0x305dc1(0x1b2)](_0x38c12c),await saveChatConditional(),log(_0x305dc1(0x1a5)+_0x46e8ee+'\x20并保存。',_0x305dc1(0x195))):log(_0x305dc1(0x1bd),'info'),_0x1b6bbd&&renderTables();}import{checkAndFixWithAPI}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(_0x7b2426){const _0x2265a4=_0x14dd,_0x1b9087=getContext();if(_0x7b2426&&_0x7b2426[_0x2265a4(0x1bf)]||_0x1b9087[_0x2265a4(0x1ae)])return;const _0x33c87e=extension_settings[extensionName],_0x209aec=_0x1b9087[_0x2265a4(0x1a7)];if(!_0x209aec||_0x209aec[_0x2265a4(0x197)]===0x0)return;const _0x6309af=_0x209aec[_0x209aec[_0x2265a4(0x197)]-0x1];if(_0x6309af[_0x2265a4(0x1bf)])return;const _0x101e2c=_0x33c87e[_0x2265a4(0x1a3)]!==![];await executeAutoHide();const _0x46c751=_0x33c87e[_0x2265a4(0x1b0)]&&_0x33c87e[_0x2265a4(0x19d)]&&_0x33c87e['apiUrl'];if(_0x46c751){if(_0x209aec[_0x2265a4(0x197)]>=0x2&&_0x209aec[_0x209aec[_0x2265a4(0x197)]-0x2]['is_user']){const _0x85de46=_0x33c87e[_0x2265a4(0x194)]||0x2,_0x1c0683=Math[_0x2265a4(0x1b1)](0x0,_0x209aec[_0x2265a4(0x197)]-0x1-_0x85de46),_0x52f025=_0x209aec[_0x2265a4(0x1c3)](_0x1c0683,_0x209aec[_0x2265a4(0x197)]-0x1),_0x262150=await checkAndFixWithAPI(_0x6309af,_0x52f025);_0x262150&&_0x262150[_0x2265a4(0x1b7)]&&_0x262150['optimizedContent']!==_0x6309af[_0x2265a4(0x1a6)]&&(_0x6309af[_0x2265a4(0x1a6)]=_0x262150[_0x2265a4(0x1b7)],await saveChatConditional(),_0x33c87e[_0x2265a4(0x1bc)]==='refresh'&&await reloadCurrentChat());}else console[_0x2265a4(0x1b8)](_0x2265a4(0x19e));}if(_0x101e2c){const _0x346664=_0x33c87e['filling_mode']||'main-api';_0x346664===_0x2265a4(0x1aa)&&fillWithSecondaryApi(_0x6309af);}else log(_0x2265a4(0x1a1),_0x2265a4(0x1b9));((async()=>{const _0x44c841=_0x2265a4;try{await new Promise(_0x5dc5a6=>setTimeout(_0x5dc5a6,0x64)),await checkAndTriggerAutoSummary();}catch(_0x5e8c3b){console[_0x44c841(0x19a)](_0x44c841(0x1a4),_0x5e8c3b);}})());}export{handleTableUpdate};