Add is-mobile command and macro

This commit is contained in:
Cohee 2024-12-21 22:25:14 +02:00
parent 5739efc59b
commit d9101ce679
3 changed files with 10 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import { timestampToMoment, isDigitsOnly, getStringHash, escapeRegex, uuidv4 } f
import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
import { getInstructMacros } from './instruct-mode.js';
import { getVariableMacros } from './variables.js';
import { isMobile } from './RossAscends-mods.js';
/**
* @typedef Macro
@ -542,5 +543,6 @@ export function initMacros() {
});
}
MacrosParser.registerMacro('isMobile', () => String(isMobile()));
initLastGenerationType();
}

View File

@ -47,7 +47,7 @@ import {
} from '../script.js';
import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';
import { SlashCommandParserError } from './slash-commands/SlashCommandParserError.js';
import { getMessageTimeStamp } from './RossAscends-mods.js';
import { getMessageTimeStamp, isMobile } from './RossAscends-mods.js';
import { hideChatMessageRange } from './chats.js';
import { getContext, saveMetadataDebounced } from './extensions.js';
import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
@ -1958,6 +1958,12 @@ export function initDefaultSlashCommands() {
</div>
`,
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'is-mobile',
callback: () => String(isMobile()),
returns: ARGUMENT_TYPE.BOOLEAN,
helpString: 'Returns true if the current device is a mobile device, false otherwise. Equivalent to <code>{{isMobile}}</code> macro.',
}));
registerVariableCommands();
}

View File

@ -48,6 +48,7 @@
<li><tt>&lcub;&lcub;random::(arg1)::(arg2)&rcub;&rcub;</tt> <span data-i18n="help_macros_38">alternative syntax for random that allows to use commas in the list items.</span></li>
<li><tt>&lcub;&lcub;pick::(args)&rcub;&rcub;</tt> <span data-i18n="help_macros_39">picks a random item from the list. Works the same as &lcub;&lcub;random&rcub;&rcub;, with the same possible syntax options, but the pick will stay consistent for this chat once picked and won't be re-rolled on consecutive messages and prompt processing.</span></li>
<li><tt>&lcub;&lcub;banned "text here"&rcub;&rcub;</tt> <span data-i18n="help_macros_40">dynamically add text in the quotes to banned words sequences, if Text Generation WebUI backend used. Do nothing for others backends. Can be used anywhere (Character description, WI, AN, etc.) Quotes around the text are important.</span></li>
<li><tt>&lcub;&lcub;isMobile&rcub;&rcub;</tt> <span data-i18n="help_macros_isMobile">"true" if currently running in a mobile environment, "false" otherwise</span></li>
</ul>
<div data-i18n="Instruct Mode and Context Template Macros:">
Instruct Mode and Context Template Macros: