Move variables extension to external repo

This commit is contained in:
Cohee 2023-10-15 16:08:19 +03:00
parent d1d14bca13
commit 19363f6cb9
2 changed files with 0 additions and 77 deletions

View File

@ -1,66 +0,0 @@
import { getContext } from "../../extensions.js";
/**
* Gets a chat variable from the current chat metadata.
* @param {string} name The name of the variable to get.
* @returns {string} The value of the variable.
*/
function getChatVariable(name) {
const metadata = getContext().chatMetadata;
if (!metadata) {
return '';
}
if (!metadata.variables) {
metadata.variables = {};
return '';
}
return metadata.variables[name] || '';
}
/**
* Sets a chat variable in the current chat metadata.
* @param {string} name The name of the variable to set.
* @param {any} value The value of the variable to set.
*/
function setChatVariable(name, value) {
if (name === undefined || value === undefined) {
return;
}
const metadata = getContext().chatMetadata;
if (!metadata) {
return;
}
if (!metadata.variables) {
metadata.variables = {};
}
metadata.variables[name] = value;
}
function listChatVariables() {
const metadata = getContext().chatMetadata;
if (!metadata) {
return '';
}
if (!metadata.variables) {
metadata.variables = {};
return '';
}
return Object.keys(metadata.variables).map(key => `${key}=${metadata.variables[key]}`).join(';');
}
jQuery(() => {
const context = getContext();
context.registerHelper('getvar', getChatVariable);
context.registerHelper('setvar', setChatVariable);
context.registerHelper('listvar', listChatVariables);
});

View File

@ -1,11 +0,0 @@
{
"display_name": "Chat Variables",
"loading_order": 100,
"requires": [],
"optional": [],
"js": "index.js",
"css": "",
"author": "Cohee#1207",
"version": "1.0.0",
"homePage": "https://github.com/SillyTavern/SillyTavern"
}