client: check input for aiscript

af1c9251fc
5f3640c7fd

Co-authored-by: Johann150 <johann.galle@protonmail.com>
Changelog: Fixed
This commit is contained in:
syuilo 2023-02-10 20:04:45 +01:00 committed by Johann150
parent 27b912b9b0
commit 09fe55379e
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
5 changed files with 12 additions and 4 deletions

View file

@ -59,6 +59,7 @@ async function run() {
os.inputText({
title: q,
}).then(({ canceled, result: a }) => {
if (canceled) return;
ok(a);
});
});

View file

@ -18,7 +18,8 @@ export function install(plugin) {
return new Promise(ok => {
inputText({
title: q,
}).then(({ result: a }) => {
}).then(({ canceled, result: a }) => {
if (canceled) return;
ok(a);
});
});

View file

@ -24,7 +24,11 @@ export function createAiScriptEnv(opts) {
return confirm.canceled ? values.FALSE : values.TRUE;
}),
'Mk:api': values.FN_NATIVE(async ([ep, param, token]) => {
if (token) utils.assertString(token);
if (token) {
utils.assertString(token);
// In case there is a bug, it could be undefined.
if (typeof token.value !== 'string') throw new Error('invalid token');
}
apiRequests++;
if (apiRequests > 16) return values.NULL;
const res = await os.api(ep.value, utils.valToJs(param), token ? token.value : (opts.token || null));

View file

@ -72,7 +72,8 @@ const run = async (): Promise<void> => {
return new Promise(ok => {
os.inputText({
title: q,
}).then(({ result: a }) => {
}).then(({ canceled, result: a }) => {
if (canceled) return;
ok(a);
});
});

View file

@ -60,7 +60,8 @@ const run = async (): Promise<void> => {
return new Promise(ok => {
os.inputText({
title: q,
}).then(({ result: a }) => {
}).then(({ canceled, result: a }) => {
if (canceled) return;
ok(a);
});
});