Add is-mobile command and macro

d9101ce6795b73142edca1b5b365a3bdbb9a1883

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +10 -1Showing whitespace changes
public/scripts/macros.js+2 -0
@@ -4,6 +4,7 @@ import { timestampToMoment, isDigitsOnly, getStringHash, escapeRegex, uuidv4 } f
4import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';4import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
5import { getInstructMacros } from './instruct-mode.js';5import { getInstructMacros } from './instruct-mode.js';
6import { getVariableMacros } from './variables.js';6import { getVariableMacros } from './variables.js';
7import { isMobile } from './RossAscends-mods.js';
78
8/**9/**
9 * @typedef Macro10 * @typedef Macro
@@ -542,5 +543,6 @@ export function initMacros() {
542 });543 });
543 }544 }
544545
546 MacrosParser.registerMacro('isMobile', () => String(isMobile()));
545 initLastGenerationType();547 initLastGenerationType();
546}548}
public/scripts/slash-commands.js+7 -1
@@ -47,7 +47,7 @@ import {
47} from '../script.js';47} from '../script.js';
48import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';48import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';
49import { SlashCommandParserError } from './slash-commands/SlashCommandParserError.js';49import { SlashCommandParserError } from './slash-commands/SlashCommandParserError.js';
50import { getMessageTimeStamp } from './RossAscends-mods.js';50import { getMessageTimeStamp, isMobile } from './RossAscends-mods.js';
51import { hideChatMessageRange } from './chats.js';51import { hideChatMessageRange } from './chats.js';
52import { getContext, saveMetadataDebounced } from './extensions.js';52import { getContext, saveMetadataDebounced } from './extensions.js';
53import { getRegexedString, regex_placement } from './extensions/regex/engine.js';53import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
@@ -1958,6 +1958,12 @@ export function initDefaultSlashCommands() {
1958 </div>1958 </div>
1959 `,1959 `,
1960 }));1960 }));
1961 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
1962 name: 'is-mobile',
1963 callback: () => String(isMobile()),
1964 returns: ARGUMENT_TYPE.BOOLEAN,
1965 helpString: 'Returns true if the current device is a mobile device, false otherwise. Equivalent to <code>{{isMobile}}</code> macro.',
1966 }));
19611967
1962 registerVariableCommands();1968 registerVariableCommands();
1963}1969}
public/scripts/templates/macros.html+1 -0
@@ -48,6 +48,7 @@
48 <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>48 <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>
49 <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>49 <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>
50 <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>50 <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>
51 <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>
51</ul>52</ul>
52<div data-i18n="Instruct Mode and Context Template Macros:">53<div data-i18n="Instruct Mode and Context Template Macros:">
53 Instruct Mode and Context Template Macros:54 Instruct Mode and Context Template Macros: