其他工具函数
substitudeMacros
替换字符串中的 SillyTavern 宏。
typescript
async function substitudeMacros(text: string): Promise<string>;
参数
text
- 类型:
string
- 描述: 需要替换的字符串
返回值
- 替换结果:
string
示例
typescript
const text = substitudeMacros("{{char}} speaks in {{lastMessageId}}");
text == "少女歌剧 speaks in 5";
getIframeName 🚫TavernHelper
获取 iframe 的名称。
typescript
function getIframeName(): string;
返回值
- iframe 名称:
string
- 对于楼层消息是
message-iframe-楼层id-是该楼层第几个iframe
- 对于全局脚本是
script-iframe-脚本名称
- 对于楼层消息是
getMessageId 🚫TavernHelper
从消息楼层 iframe 的 iframe_name
获取它所在楼层的楼层 id。
只能对楼层消息 iframe 使用
typescript
function getMessageId(iframe_name: string): number;
参数
iframe_name
- 类型:
string
- 描述: 消息楼层 iframe 的名称
返回值
- 楼层 id:
number
getCurrentMessageId 🚫TavernHelper
获取本消息楼层 iframe 所在楼层的楼层 id。
只能对楼层消息 iframe 使用
typescript
function getCurrentMessageId(): number;
返回值
- 楼层 id:
number
getLastMessageId
获取最新楼层 id。
typescript
async function getLastMessageId(): Promise<number>;
返回值
- 最新楼层 id:
number
getScriptId 🚫TavernHelper
获取脚本库的脚本 id。
typescript
function getScriptId(): string;
返回值
- 脚本 id:
string