diff --git a/public/scripts/macros.js b/public/scripts/macros.js index ea6b64b67..cbc38ded4 100644 --- a/public/scripts/macros.js +++ b/public/scripts/macros.js @@ -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(); } diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 5cb76d06d..7265b76bf 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -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() { `, })); + 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 {{isMobile}} macro.', + })); registerVariableCommands(); } diff --git a/public/scripts/templates/macros.html b/public/scripts/templates/macros.html index 84a163c4e..7490596d3 100644 --- a/public/scripts/templates/macros.html +++ b/public/scripts/templates/macros.html @@ -48,6 +48,7 @@
  • {{random::(arg1)::(arg2)}}alternative syntax for random that allows to use commas in the list items.
  • {{pick::(args)}}picks a random item from the list. Works the same as {{random}}, 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.
  • {{banned "text here"}}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.
  • +
  • {{isMobile}}"true" if currently running in a mobile environment, "false" otherwise
  • Instruct Mode and Context Template Macros: