mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-23 00:29:22 +09:00
Fix: AiScriptのreadlineの修正をPlay以外にも適用 (#12841)
* add AiScriptReadline() in api.ts * apply AiScriptReadline on flash.vue * AiScriptReadline → aiScriptReadline * Update flash.vue * Update scratchpad.vue * Update WidgetAiscript.vue * Update WidgetAiscriptApp.vue * Update WidgetButton.vue * Update plugin.ts
This commit is contained in:
parent
da154c8209
commit
f8d5a46dbf
@ -67,7 +67,7 @@ import { i18n } from '@/i18n.js';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import MkAsUi from '@/components/MkAsUi.vue';
|
||||
import { AsUiComponent, AsUiRoot, registerAsUiLib } from '@/scripts/aiscript/ui.js';
|
||||
import { createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import MkFolder from '@/components/MkFolder.vue';
|
||||
import MkCode from '@/components/MkCode.vue';
|
||||
import { defaultStore } from '@/store.js';
|
||||
@ -162,15 +162,7 @@ async function run() {
|
||||
THIS_ID: values.STR(flash.value.id),
|
||||
THIS_URL: values.STR(`${url}/play/${flash.value.id}`),
|
||||
}, {
|
||||
in: (q) => {
|
||||
return new Promise(ok => {
|
||||
os.inputText({
|
||||
title: q,
|
||||
}).then(({ result: a }) => {
|
||||
ok(a ?? '');
|
||||
});
|
||||
});
|
||||
},
|
||||
in: aiScriptReadline,
|
||||
out: (value) => {
|
||||
// nop
|
||||
},
|
||||
|
@ -44,7 +44,7 @@ import { Interpreter, Parser, utils } from '@syuilo/aiscript';
|
||||
import MkContainer from '@/components/MkContainer.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkCodeEditor from '@/components/MkCodeEditor.vue';
|
||||
import { createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import * as os from '@/os.js';
|
||||
import { $i } from '@/account.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
@ -86,19 +86,7 @@ async function run() {
|
||||
root.value = _root.value;
|
||||
}),
|
||||
}), {
|
||||
in: (q) => {
|
||||
return new Promise(ok => {
|
||||
os.inputText({
|
||||
title: q,
|
||||
}).then(({ canceled, result: a }) => {
|
||||
if (canceled) {
|
||||
ok('');
|
||||
} else {
|
||||
ok(a);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
in: aiScriptReadline,
|
||||
out: (value) => {
|
||||
if (value.type === 'str' && value.value.toLowerCase().replace(',', '').includes('hello world')) {
|
||||
claimAchievement('outputHelloWorldOnScratchpad');
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { Interpreter, Parser, utils, values } from '@syuilo/aiscript';
|
||||
import { createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { inputText } from '@/os.js';
|
||||
import { Plugin, noteActions, notePostInterruptors, noteViewInterruptors, postFormActions, userActions, pageViewInterruptors } from '@/store.js';
|
||||
|
||||
@ -19,19 +19,7 @@ export async function install(plugin: Plugin): Promise<void> {
|
||||
plugin: plugin,
|
||||
storageKey: 'plugins:' + plugin.id,
|
||||
}), {
|
||||
in: (q): Promise<string> => {
|
||||
return new Promise(ok => {
|
||||
inputText({
|
||||
title: q,
|
||||
}).then(({ canceled, result: a }) => {
|
||||
if (canceled) {
|
||||
ok('');
|
||||
} else {
|
||||
ok(a);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
in: aiScriptReadline,
|
||||
out: (value): void => {
|
||||
console.log(value);
|
||||
},
|
||||
|
@ -11,6 +11,16 @@ import { customEmojis } from '@/custom-emojis.js';
|
||||
import { url, lang } from '@/config.js';
|
||||
import { nyaize } from '@/scripts/nyaize.js';
|
||||
|
||||
export function aiScriptReadline(q: string): Promise<string> {
|
||||
return new Promise(ok => {
|
||||
os.inputText({
|
||||
title: q,
|
||||
}).then(({ result: a }) => {
|
||||
ok(a ?? '');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function createAiScriptEnv(opts) {
|
||||
return {
|
||||
USER_ID: $i ? values.STR($i.id) : values.NULL,
|
||||
|
@ -25,7 +25,7 @@ import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, Wid
|
||||
import { GetFormResultType } from '@/scripts/form.js';
|
||||
import * as os from '@/os.js';
|
||||
import MkContainer from '@/components/MkContainer.vue';
|
||||
import { createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { $i } from '@/account.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
|
||||
@ -69,19 +69,7 @@ const run = async () => {
|
||||
storageKey: 'widget',
|
||||
token: $i?.token,
|
||||
}), {
|
||||
in: (q) => {
|
||||
return new Promise(ok => {
|
||||
os.inputText({
|
||||
title: q,
|
||||
}).then(({ canceled, result: a }) => {
|
||||
if (canceled) {
|
||||
ok('');
|
||||
} else {
|
||||
ok(a);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
in: aiScriptReadline,
|
||||
out: (value) => {
|
||||
logs.value.push({
|
||||
id: Math.random().toString(),
|
||||
|
@ -18,7 +18,7 @@ import { Interpreter, Parser } from '@syuilo/aiscript';
|
||||
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js';
|
||||
import { GetFormResultType } from '@/scripts/form.js';
|
||||
import * as os from '@/os.js';
|
||||
import { createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { $i } from '@/account.js';
|
||||
import MkAsUi from '@/components/MkAsUi.vue';
|
||||
import MkContainer from '@/components/MkContainer.vue';
|
||||
@ -64,19 +64,7 @@ async function run() {
|
||||
root.value = _root.value;
|
||||
}),
|
||||
}, {
|
||||
in: (q) => {
|
||||
return new Promise(ok => {
|
||||
os.inputText({
|
||||
title: q,
|
||||
}).then(({ canceled, result: a }) => {
|
||||
if (canceled) {
|
||||
ok('');
|
||||
} else {
|
||||
ok(a);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
in: aiScriptReadline,
|
||||
out: (value) => {
|
||||
// nop
|
||||
},
|
||||
|
@ -16,7 +16,7 @@ import { Interpreter, Parser } from '@syuilo/aiscript';
|
||||
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js';
|
||||
import { GetFormResultType } from '@/scripts/form.js';
|
||||
import * as os from '@/os.js';
|
||||
import { createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { $i } from '@/account.js';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
|
||||
@ -56,19 +56,7 @@ const run = async () => {
|
||||
storageKey: 'widget',
|
||||
token: $i?.token,
|
||||
}), {
|
||||
in: (q) => {
|
||||
return new Promise(ok => {
|
||||
os.inputText({
|
||||
title: q,
|
||||
}).then(({ canceled, result: a }) => {
|
||||
if (canceled) {
|
||||
ok('');
|
||||
} else {
|
||||
ok(a);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
in: aiScriptReadline,
|
||||
out: (value) => {
|
||||
// nop
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user