mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 12:25:51 +00:00
Create context-utils.js
This commit is contained in:
1
core/utils/context-utils.js
Normal file
1
core/utils/context-utils.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
'use strict';function _0x553e(){const _0x44a27f=['712269dwmhYc','3bfxVhC','comment','30alzPru','characters','is_user','extra','[翰林院-典籍库]\x20无法稳定获取当前聊天ID。','undefined','649000eobRBn','[翰林院-典籍库]\x20无法稳定获取当前角色ID。','is_system','375557XnpVNh','unknown','1354268cJUIcz','empty','_global','char_','formatting','function','chatId','error','character_id','characterId','121190BKAAdP','default_collection','7WioFVi','user','includes','50LbHCNf','getCurrentChatId','chat','9741314aSosEr','name','582044gGMPdr','type','replace','welcome_prompt','system','getContext','length','welcome','help','未指定'];_0x553e=function(){return _0x44a27f;};return _0x553e();}(function(_0x3e41c8,_0x21d5a2){const _0x3847df=_0x1dcb,_0x1b1151=_0x3e41c8();while(!![]){try{const _0x1cbc1c=-parseInt(_0x3847df(0x116))/0x1+-parseInt(_0x3847df(0x100))/0x2+parseInt(_0x3847df(0x10b))/0x3*(parseInt(_0x3847df(0x118))/0x4)+-parseInt(_0x3847df(0xf6))/0x5*(-parseInt(_0x3847df(0x10d))/0x6)+-parseInt(_0x3847df(0xf8))/0x7*(parseInt(_0x3847df(0x113))/0x8)+-parseInt(_0x3847df(0x10a))/0x9*(parseInt(_0x3847df(0xfb))/0xa)+parseInt(_0x3847df(0xfe))/0xb;if(_0x1cbc1c===_0x21d5a2)break;else _0x1b1151['push'](_0x1b1151['shift']());}catch(_0x1e4b65){_0x1b1151['push'](_0x1b1151['shift']());}}}(_0x553e,0x314c2));export function detectMessageType(_0x1dcd7b){const _0x1fe518=_0x1dcb;if(_0x1dcd7b['is_hidden'])return'hidden';if(_0x1dcd7b['is_user']===!![])return _0x1fe518(0xf9);if(_0x1dcd7b[_0x1fe518(0x10f)]===![]&&_0x1dcd7b[_0x1fe518(0x115)]!==!![])return'ai';if(_0x1dcd7b[_0x1fe518(0x115)]===!![]){const _0x250c32=_0x1dcd7b['extra']?.[_0x1fe518(0x101)]&&[_0x1fe518(0x108),_0x1fe518(0x107),_0x1fe518(0x119),'generic','narrator',_0x1fe518(0x10c),'slash_commands',_0x1fe518(0xf0),'hotkeys','macros',_0x1fe518(0x103),'assistant_note'][_0x1fe518(0xfa)](_0x1dcd7b[_0x1fe518(0x110)][_0x1fe518(0x101)]);if(_0x250c32)return _0x1fe518(0x104);const _0xd4d933=SillyTavern[_0x1fe518(0x105)]()?.['character']?.[_0x1fe518(0xff)];if(_0x1dcd7b[_0x1fe518(0xff)]===_0xd4d933)return'ai';}return _0x1fe518(0x117);}export function getCharacterId(){const _0x38bf93=_0x1dcb,_0x99f6d4=SillyTavern[_0x38bf93(0x105)]();if(!_0x99f6d4)return null;if(_0x99f6d4[_0x38bf93(0xf5)]!==undefined&&_0x99f6d4['characterId']!==null)return _0x99f6d4[_0x38bf93(0xf5)];if(typeof this_chid!==_0x38bf93(0x112)&&this_chid!==null)return this_chid;if(_0x99f6d4[_0x38bf93(0xfd)]&&_0x99f6d4['chat']['length']>0x0){const _0x6addfc=_0x99f6d4[_0x38bf93(0xfd)][_0x99f6d4['chat'][_0x38bf93(0x106)]-0x1];if(_0x6addfc&&_0x6addfc[_0x38bf93(0xf4)]!==undefined)return _0x6addfc['character_id'];}return console[_0x38bf93(0xf3)](_0x38bf93(0x114)),null;}export function getChatId(){const _0x202cdc=_0x1dcb,_0x3fc136=SillyTavern[_0x202cdc(0x105)]();if(!_0x3fc136)return null;if(typeof _0x3fc136[_0x202cdc(0xfc)]===_0x202cdc(0xf1))return _0x3fc136[_0x202cdc(0xfc)]();if(_0x3fc136[_0x202cdc(0xf2)])return _0x3fc136['chatId'];const _0x506d64=getCharacterId();if(_0x506d64!==null&&_0x3fc136[_0x202cdc(0x10e)]&&_0x3fc136[_0x202cdc(0x10e)][_0x506d64])return _0x3fc136[_0x202cdc(0x10e)][_0x506d64][_0x202cdc(0xfd)];return console['error'](_0x202cdc(0x111)),null;}function _0x1dcb(_0x2342dc,_0x3d1cfa){const _0x553e45=_0x553e();return _0x1dcb=function(_0x1dcb08,_0x4ccea6){_0x1dcb08=_0x1dcb08-0xee;let _0x55f1ea=_0x553e45[_0x1dcb08];return _0x55f1ea;},_0x1dcb(_0x2342dc,_0x3d1cfa);}export function getCharacterName(){const _0xcf9728=_0x1dcb,_0x44c8ef=SillyTavern['getContext']();if(!_0x44c8ef)return'未指定';const _0x15b922=getCharacterId();if(_0x15b922!==null&&_0x44c8ef['characters']&&_0x44c8ef[_0xcf9728(0x10e)][_0x15b922])return _0x44c8ef[_0xcf9728(0x10e)][_0x15b922][_0xcf9728(0xff)]||'未命名角色';return _0xcf9728(0x109);}export function getCollectionId(){const _0x143e96=_0x1dcb,_0x58cd2a=getCharacterId(),_0x189c58=getChatId();let _0x2e6d14;if(_0x58cd2a!==null&&_0x189c58)_0x2e6d14=_0x143e96(0xef)+_0x58cd2a+'_chat_'+_0x189c58;else _0x58cd2a!==null?_0x2e6d14=_0x143e96(0xef)+_0x58cd2a+_0x143e96(0xee):_0x2e6d14=_0x143e96(0xf7);return String(_0x2e6d14)[_0x143e96(0x102)](/[^a-zA-Z0-9\u4e00-\u9fff_-]/g,'_');}
|
||||||
Reference in New Issue
Block a user