Files
ST-Amily2-Chat-Optimisation/core/events.js
2025-08-13 00:54:56 +08:00

2 lines
5.7 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(_0xf09fe1,_0x5526a6){const _0x1dc666=_0x354c,_0x508b85=_0xf09fe1();while(!![]){try{const _0x3a4309=-parseInt(_0x1dc666(0x1b5))/0x1+-parseInt(_0x1dc666(0x1a6))/0x2+parseInt(_0x1dc666(0x18f))/0x3*(-parseInt(_0x1dc666(0x1c1))/0x4)+-parseInt(_0x1dc666(0x19e))/0x5*(-parseInt(_0x1dc666(0x1a4))/0x6)+parseInt(_0x1dc666(0x197))/0x7*(-parseInt(_0x1dc666(0x1bc))/0x8)+-parseInt(_0x1dc666(0x1a5))/0x9+parseInt(_0x1dc666(0x1aa))/0xa;if(_0x3a4309===_0x5526a6)break;else _0x508b85['push'](_0x508b85['shift']());}catch(_0x268ae5){_0x508b85['push'](_0x508b85['shift']());}}}(_0x4990,0x436f4));import{getContext,extension_settings}from'/scripts/extensions.js';import{saveChatConditional}from'/script.js';import{extensionName}from'../utils/settings.js';import*as _0x3f5cd8 from'./table-system/manager.js';import*as _0x1df3d7 from'./table-system/executor.js';import{renderTables}from'../ui/table-bindings.js';import{log}from'./table-system/logger.js';function _0x354c(_0x3fc362,_0xcf4bca){const _0x4990e6=_0x4990();return _0x354c=function(_0x354c1d,_0x1d5730){_0x354c1d=_0x354c1d-0x18f;let _0x1bd0a1=_0x4990e6[_0x354c1d];return _0x1bd0a1;},_0x354c(_0x3fc362,_0xcf4bca);}async function handleTableUpdate(_0x553205){const _0x23f085=_0x354c,_0x4e58c0=extension_settings[extensionName],_0x4c139e=_0x4e58c0[_0x23f085(0x190)]||_0x23f085(0x199);if(_0x4c139e===_0x23f085(0x1ab)||_0x4c139e===_0x23f085(0x1b2)){log(_0x23f085(0x19b),_0x23f085(0x1be));return;}log(_0x23f085(0x1b4)+_0x553205,_0x23f085(0x1ba));const _0x452739=getContext(),_0x176f0e=_0x452739[_0x23f085(0x1b8)][_0x553205];if(!_0x176f0e){log(_0x23f085(0x193)+_0x553205+_0x23f085(0x1a9),'error');return;}if(_0x176f0e[_0x23f085(0x191)]){log(_0x23f085(0x195)+_0x553205+_0x23f085(0x1bf),'info');return;}log('【监察系统】正在处理的奏折内容:\x20\x22'+_0x176f0e['mes'][_0x23f085(0x196)](0x0,0x32)+_0x23f085(0x1a3),_0x23f085(0x1be));const _0x4b9417=_0x3f5cd8[_0x23f085(0x1b6)](_0x553205);log('【监察系统-步骤1】为消息\x20'+_0x553205+_0x23f085(0x1bb),_0x23f085(0x1be),_0x4b9417);const {finalState:_0x53104f,hasChanges:_0x4332b4,changes:_0x5532fa}=_0x1df3d7[_0x23f085(0x1a2)](_0x176f0e[_0x23f085(0x1b7)],_0x4b9417);log('【监察系统-步骤2】推演完毕。是否有变化:\x20'+_0x4332b4,'info',_0x53104f),_0x4332b4?(_0x5532fa&&_0x5532fa[_0x23f085(0x19c)]>0x0&&_0x5532fa[_0x23f085(0x192)](_0x1fccee=>{const _0x221aeb=_0x23f085;_0x3f5cd8['addHighlight'](_0x1fccee[_0x221aeb(0x1a1)],_0x1fccee[_0x221aeb(0x19a)],_0x1fccee[_0x221aeb(0x19f)]);}),_0x3f5cd8['saveStateToMessage'](_0x53104f,_0x176f0e),_0x3f5cd8[_0x23f085(0x1c2)](_0x53104f),await saveChatConditional(),log(_0x23f085(0x1a7)+_0x553205+_0x23f085(0x1b0),_0x23f085(0x1ad))):log(_0x23f085(0x1ac),_0x23f085(0x1be)),_0x4332b4&&renderTables();}import{checkAndFixWithAPI}from'./summarizer.js';function _0x4990(){const _0x12e929=['warn','\x20加载了基准状态。','8rvJEdU','slice','info','\x20是用户消息无需处理。','optimizationMode','51116QpPrbW','setMemoryState','120grHgrO','filling_mode','is_user','forEach','【监察系统】错误:未找到消息\x20ID:\x20','enabled','【监察系统】消息\x20ID:\x20','substring','1852207btZdau','max','main-api','rowIndex','【监察系统】检测到“分步填表”或“优化中填表”模式已启用主API填表逻辑已自动禁用。','length','error','5AdDviz','colIndex','isWaitingForUserInput','tableIndex','executeCommands','...\x22','3235110VVBePu','400671GbXQja','1033984piTbYU','【监察系统-步骤3】检测到变化已将新状态写入消息\x20','optimizedContent',',流程中止。','16243510hVrDFk','secondary-api','【监察系统-步骤3】未检测到有效指令或变化无需写入。','success','apiUrl','[大史官]\x20后台自动总结任务执行时发生错误:','\x20并保存。','log','optimized','contextMessages','【监察系统】接到圣旨,开始处理消息\x20ID:\x20','550052fLbjOW','loadTables','mes','chat','[Amily2号]\x20检测到消息并非AI对用户的直接回复已跳过优化。'];_0x4990=function(){return _0x12e929;};return _0x4990();}import{executeAutoHide}from'./autoHideManager.js';import{checkAndTriggerAutoSummary}from'./historiographer.js';import{fillWithSecondaryApi}from'./table-system/secondary-filler.js';export async function onMessageReceived(_0x2afb69){const _0x49b729=_0x354c,_0x57a3ec=getContext();if(_0x2afb69&&_0x2afb69[_0x49b729(0x191)]||_0x57a3ec[_0x49b729(0x1a0)])return;const _0x2fd317=extension_settings[extensionName],_0x1cbdf9=_0x57a3ec[_0x49b729(0x1b8)];if(!_0x1cbdf9||_0x1cbdf9['length']===0x0)return;const _0x430e12=_0x1cbdf9[_0x1cbdf9[_0x49b729(0x19c)]-0x1];if(_0x430e12[_0x49b729(0x191)])return;await executeAutoHide();const _0x2ff52b=_0x2fd317[_0x49b729(0x194)]&&_0x2fd317['optimizationEnabled']&&_0x2fd317[_0x49b729(0x1ae)];if(_0x2ff52b){if(_0x1cbdf9['length']>=0x2&&_0x1cbdf9[_0x1cbdf9['length']-0x2][_0x49b729(0x191)]){const _0x53235d=_0x2fd317[_0x49b729(0x1b3)]||0x2,_0x83ccd1=Math[_0x49b729(0x198)](0x0,_0x1cbdf9['length']-0x1-_0x53235d),_0x48c8fd=_0x1cbdf9[_0x49b729(0x1bd)](_0x83ccd1,_0x1cbdf9[_0x49b729(0x19c)]-0x1),_0xf98c49=await checkAndFixWithAPI(_0x430e12,_0x48c8fd);_0xf98c49&&_0xf98c49[_0x49b729(0x1a8)]&&_0xf98c49[_0x49b729(0x1a8)]!==_0x430e12[_0x49b729(0x1b7)]&&(_0x430e12[_0x49b729(0x1b7)]=_0xf98c49[_0x49b729(0x1a8)],await saveChatConditional(),_0x2fd317[_0x49b729(0x1c0)]==='refresh'&&await reloadCurrentChat());}else console[_0x49b729(0x1b1)](_0x49b729(0x1b9));}const _0x1c6f8f=_0x2fd317[_0x49b729(0x190)]||_0x49b729(0x199);_0x1c6f8f===_0x49b729(0x1ab)&&fillWithSecondaryApi(_0x430e12),((async()=>{const _0x293832=_0x49b729;try{await new Promise(_0x138d1a=>setTimeout(_0x138d1a,0x64)),await checkAndTriggerAutoSummary();}catch(_0x4d2bde){console[_0x293832(0x19d)](_0x293832(0x1af),_0x4d2bde);}})());}export{handleTableUpdate};