Files
ST-Amily2-Chat-Optimisation…/core/events.js
2025-09-04 19:53:04 +08:00

2 lines
6.2 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(_0x445b9e,_0x3eec19){const _0x3534b7=_0x194e,_0x30fb56=_0x445b9e();while(!![]){try{const _0x320614=-parseInt(_0x3534b7(0xd4))/0x1+-parseInt(_0x3534b7(0xfe))/0x2*(-parseInt(_0x3534b7(0xed))/0x3)+parseInt(_0x3534b7(0xe7))/0x4+parseInt(_0x3534b7(0xdd))/0x5*(parseInt(_0x3534b7(0x100))/0x6)+parseInt(_0x3534b7(0xea))/0x7*(-parseInt(_0x3534b7(0xd5))/0x8)+-parseInt(_0x3534b7(0xf2))/0x9*(-parseInt(_0x3534b7(0xf9))/0xa)+parseInt(_0x3534b7(0xce))/0xb*(-parseInt(_0x3534b7(0xd0))/0xc);if(_0x320614===_0x3eec19)break;else _0x30fb56['push'](_0x30fb56['shift']());}catch(_0x3ce793){_0x30fb56['push'](_0x30fb56['shift']());}}}(_0x2422,0xe120e));import{getContext,extension_settings}from'/scripts/extensions.js';import{saveChatConditional}from'/script.js';function _0x2422(){const _0x2914ea=['enabled','3285sWyPSY','rowIndex','isWaitingForUserInput','【监察系统-步骤2】推演完毕。是否有变化:\x20','【监察系统】错误:未找到消息\x20ID:\x20','\x20并保存。','【监察系统】接到圣旨,开始处理消息\x20ID:\x20','21880rdjdoh','filling_mode','setMemoryState','info','warn','1087324YWunMP','[分步填表]\x20表格系统总开关已关闭跳过分步填表处理。','450zxjnGM','tableIndex','chat','[Amily2号-正文优化]\x20检测到消息并非AI对用户的直接回复已跳过优化。','mes','main-api','success','11krzVOd','error','11773176cxshwj','[大史官]\x20后台自动总结任务执行时发生错误:','log','saveStateToMessage','877703EUbufD','40XnKnKc','【监察系统-步骤3】检测到变化已将新状态写入消息\x20','colIndex','【监察系统-步骤3】未检测到有效指令或变化无需写入。','table_system_enabled','【监察系统】正在处理的奏折内容:\x20\x22','optimizationEnabled','refresh','77655wGKGUX','【监察系统-步骤1】为消息\x20','forEach','\x20加载了基准状态。','loadTables','【监察系统】检测到\x22分步填表\x22或\x22优化中填表\x22模式已启用主API填表逻辑已自动禁用。','optimizedContent','\x20是用户消息无需处理。','【监察系统】消息\x20ID:\x20','slice','103164EKXmgt','apiUrl','optimizationMode','1175013MIQKyS','is_user','length','9HvwjcK','secondary-api','【监察系统】表格系统总开关已关闭,跳过所有表格处理。','addHighlight'];_0x2422=function(){return _0x2914ea;};return _0x2422();}import{extensionName}from'../utils/settings.js';import*as _0x5906c from'./table-system/manager.js';import*as _0x30f59e from'./table-system/executor.js';import{renderTables}from'../ui/table-bindings.js';import{log}from'./table-system/logger.js';async function handleTableUpdate(_0x54313d){const _0x12bccd=_0x194e,_0x4376b8=extension_settings[extensionName],_0xfd7599=_0x4376b8[_0x12bccd(0xd9)]!==![];if(!_0xfd7599){log(_0x12bccd(0xef),_0x12bccd(0xfc));return;}const _0x451ef6=_0x4376b8[_0x12bccd(0xfa)]||_0x12bccd(0x105);if(_0x451ef6===_0x12bccd(0xee)||_0x451ef6==='optimized'){log(_0x12bccd(0xe2),_0x12bccd(0xfc));return;}log(_0x12bccd(0xf8)+_0x54313d,_0x12bccd(0xfd));const _0x30dc4c=getContext(),_0x1a21f1=_0x30dc4c[_0x12bccd(0x102)][_0x54313d];if(!_0x1a21f1){log(_0x12bccd(0xf6)+_0x54313d+',流程中止。',_0x12bccd(0xcf));return;}if(_0x1a21f1['is_user']){log(_0x12bccd(0xe5)+_0x54313d+_0x12bccd(0xe4),_0x12bccd(0xfc));return;}log(_0x12bccd(0xda)+_0x1a21f1[_0x12bccd(0x104)]['substring'](0x0,0x32)+'...\x22',_0x12bccd(0xfc));const _0x247f66=_0x5906c[_0x12bccd(0xe1)](_0x54313d);log(_0x12bccd(0xde)+_0x54313d+_0x12bccd(0xe0),_0x12bccd(0xfc),_0x247f66);const {finalState:_0x131e7f,hasChanges:_0x424292,changes:_0x2a137c}=_0x30f59e['executeCommands'](_0x1a21f1['mes'],_0x247f66);log(_0x12bccd(0xf5)+_0x424292,_0x12bccd(0xfc),_0x131e7f),_0x424292?(_0x2a137c&&_0x2a137c[_0x12bccd(0xec)]>0x0&&_0x2a137c[_0x12bccd(0xdf)](_0x351058=>{const _0x38e81e=_0x12bccd;_0x5906c[_0x38e81e(0xf0)](_0x351058[_0x38e81e(0x101)],_0x351058[_0x38e81e(0xf3)],_0x351058[_0x38e81e(0xd7)]);}),_0x5906c[_0x12bccd(0xd3)](_0x131e7f,_0x1a21f1),_0x5906c[_0x12bccd(0xfb)](_0x131e7f),await saveChatConditional(),log(_0x12bccd(0xd6)+_0x54313d+_0x12bccd(0xf7),_0x12bccd(0xcd))):log(_0x12bccd(0xd8),_0x12bccd(0xfc)),_0x424292&&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(_0x2a67ff){const _0x1ad068=_0x194e,_0x3eaca2=getContext();if(_0x2a67ff&&_0x2a67ff[_0x1ad068(0xeb)]||_0x3eaca2[_0x1ad068(0xf4)])return;const _0x2e2990=extension_settings[extensionName],_0x4f95c6=_0x3eaca2[_0x1ad068(0x102)];if(!_0x4f95c6||_0x4f95c6[_0x1ad068(0xec)]===0x0)return;const _0x489276=_0x4f95c6[_0x4f95c6[_0x1ad068(0xec)]-0x1];if(_0x489276[_0x1ad068(0xeb)])return;const _0x360c2a=_0x2e2990[_0x1ad068(0xd9)]!==![];await executeAutoHide();const _0x145fbd=_0x2e2990[_0x1ad068(0xf1)]&&_0x2e2990[_0x1ad068(0xdb)]&&_0x2e2990[_0x1ad068(0xe8)];if(_0x145fbd){if(_0x4f95c6['length']>=0x2&&_0x4f95c6[_0x4f95c6['length']-0x2]['is_user']){const _0x1f05ed=_0x2e2990['contextMessages']||0x2,_0x3c6b82=Math['max'](0x0,_0x4f95c6[_0x1ad068(0xec)]-0x1-_0x1f05ed),_0x53275b=_0x4f95c6[_0x1ad068(0xe6)](_0x3c6b82,_0x4f95c6[_0x1ad068(0xec)]-0x1),_0x472071=await processOptimization(_0x489276,_0x53275b);_0x472071&&_0x472071[_0x1ad068(0xe3)]&&_0x472071[_0x1ad068(0xe3)]!==_0x489276['mes']&&(_0x489276[_0x1ad068(0x104)]=_0x472071['optimizedContent'],await saveChatConditional(),_0x2e2990[_0x1ad068(0xe9)]===_0x1ad068(0xdc)&&await reloadCurrentChat());}else console[_0x1ad068(0xd2)](_0x1ad068(0x103));}if(_0x360c2a){const _0x3ea749=_0x2e2990[_0x1ad068(0xfa)]||_0x1ad068(0x105);_0x3ea749===_0x1ad068(0xee)&&fillWithSecondaryApi(_0x489276);}else log(_0x1ad068(0xff),_0x1ad068(0xfc));((async()=>{const _0x44ba02=_0x1ad068;try{await new Promise(_0x50160a=>setTimeout(_0x50160a,0x64)),await checkAndTriggerAutoSummary();}catch(_0x237901){console[_0x44ba02(0xcf)](_0x44ba02(0xd1),_0x237901);}})());}function _0x194e(_0x17f410,_0x499494){const _0x2422b7=_0x2422();return _0x194e=function(_0x194ea4,_0x350885){_0x194ea4=_0x194ea4-0xcd;let _0x5c0c14=_0x2422b7[_0x194ea4];return _0x5c0c14;},_0x194e(_0x17f410,_0x499494);}export{handleTableUpdate};