Files
ST-Amily2-Chat-Optimisation…/core/events.js
2025-08-07 20:26:58 +08:00

2 lines
3.0 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(_0x277d54,_0x402c7e){const _0x2fba09=_0x1bc9,_0x19fa28=_0x277d54();while(!![]){try{const _0x50ebf0=parseInt(_0x2fba09(0x107))/0x1+parseInt(_0x2fba09(0xf6))/0x2*(parseInt(_0x2fba09(0xff))/0x3)+parseInt(_0x2fba09(0xf2))/0x4+-parseInt(_0x2fba09(0x106))/0x5*(-parseInt(_0x2fba09(0x103))/0x6)+parseInt(_0x2fba09(0xef))/0x7+-parseInt(_0x2fba09(0xfc))/0x8+parseInt(_0x2fba09(0xf7))/0x9*(-parseInt(_0x2fba09(0xfe))/0xa);if(_0x50ebf0===_0x402c7e)break;else _0x19fa28['push'](_0x19fa28['shift']());}catch(_0x321aa1){_0x19fa28['push'](_0x19fa28['shift']());}}}(_0x5eba,0x6587c));import{getContext,extension_settings}from'/scripts/extensions.js';import{characters,saveChatConditional,reloadCurrentChat}from'/script.js';import{extensionName}from'../utils/settings.js';import{checkAndFixWithAPI}from'./api.js';function _0x1bc9(_0x314bdb,_0x5a9450){const _0x5eba8f=_0x5eba();return _0x1bc9=function(_0x1bc9b5,_0x417751){_0x1bc9b5=_0x1bc9b5-0xef;let _0x3081e1=_0x5eba8f[_0x1bc9b5];return _0x3081e1;},_0x1bc9(_0x314bdb,_0x5a9450);}import{executeAutoHide}from'./autoHideManager.js';import{checkAndTriggerAutoSummary}from'./historiographer.js';export async function onMessageReceived(_0x8c9cab){const _0x575d2e=_0x1bc9,_0x419002=getContext();if(_0x8c9cab&&_0x8c9cab[_0x575d2e(0xf4)]||_0x419002[_0x575d2e(0xf5)])return;const _0x1e8500=extension_settings[extensionName],_0x34c2ad=_0x419002[_0x575d2e(0x102)];if(!_0x34c2ad||_0x34c2ad[_0x575d2e(0xfd)]===0x0)return;const _0xab0d28=_0x34c2ad[_0x34c2ad['length']-0x1];if(_0xab0d28[_0x575d2e(0xf4)])return;await executeAutoHide();const _0xa1d2b8=_0x1e8500[_0x575d2e(0x101)]&&_0x1e8500[_0x575d2e(0xfa)]&&_0x1e8500[_0x575d2e(0xf9)];if(_0xa1d2b8){if(_0x34c2ad[_0x575d2e(0xfd)]>=0x2&&_0x34c2ad[_0x34c2ad[_0x575d2e(0xfd)]-0x2]['is_user']){const _0x4007b7=_0x1e8500[_0x575d2e(0x105)]||0x2,_0x4d3bed=Math[_0x575d2e(0xf1)](0x0,_0x34c2ad[_0x575d2e(0xfd)]-0x1-_0x4007b7),_0xa4c46=_0x34c2ad[_0x575d2e(0xfb)](_0x4d3bed,_0x34c2ad[_0x575d2e(0xfd)]-0x1),_0x5ccc69=await checkAndFixWithAPI(_0xab0d28,_0xa4c46);_0x5ccc69&&_0x5ccc69['optimizedContent']&&_0x5ccc69[_0x575d2e(0xf3)]!==_0xab0d28['mes']&&(_0xab0d28[_0x575d2e(0xf0)]=_0x5ccc69[_0x575d2e(0xf3)],await saveChatConditional(),_0x1e8500[_0x575d2e(0x100)]==='refresh'&&await reloadCurrentChat());}else console[_0x575d2e(0x104)]('[Amily2号]\x20检测到消息并非AI对用户的直接回复已跳过优化。');}((async()=>{const _0x58d33a=_0x575d2e;try{await new Promise(_0x571d25=>setTimeout(_0x571d25,0x64)),await checkAndTriggerAutoSummary();}catch(_0x56a1cf){console['error'](_0x58d33a(0xf8),_0x56a1cf);}})());}function _0x5eba(){const _0x6222c5=['optimizationMode','enabled','chat','30dBPJut','log','contextMessages','683015hWphQM','200214GSPPWq','4823609Cafazg','mes','max','647004MqEdXs','optimizedContent','is_user','isWaitingForUserInput','3156rYLHvv','9ysLDxg','[大史官]\x20后台自动总结任务执行时发生错误:','apiUrl','optimizationEnabled','slice','3393536rCgGVd','length','15046930WQnLjE','1161OLdVfD'];_0x5eba=function(){return _0x6222c5;};return _0x5eba();}export function onChatChanged(){}