diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2020-04-12 19:38:19 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2020-04-12 19:38:19 +0900 |
| commit | f07047d1e89586a3bcaf36d6d2667e89e1a49d1e (patch) | |
| tree | 03986214247ed3750e780ac8568e4d4f38adbf5a /src/client/scripts/create-aiscript-env.ts | |
| parent | 12.30.0 (diff) | |
| download | sharkey-f07047d1e89586a3bcaf36d6d2667e89e1a49d1e.tar.gz sharkey-f07047d1e89586a3bcaf36d6d2667e89e1a49d1e.tar.bz2 sharkey-f07047d1e89586a3bcaf36d6d2667e89e1a49d1e.zip | |
AiScript関連
Diffstat (limited to 'src/client/scripts/create-aiscript-env.ts')
| -rw-r--r-- | src/client/scripts/create-aiscript-env.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/client/scripts/create-aiscript-env.ts b/src/client/scripts/create-aiscript-env.ts new file mode 100644 index 0000000000..75f402e13e --- /dev/null +++ b/src/client/scripts/create-aiscript-env.ts @@ -0,0 +1,28 @@ +import { utils, values } from '@syuilo/aiscript'; + +export function createAiScriptEnv(vm) { + return { + USER_ID: values.STR(vm.$store.state.i.id), + USER_USERNAME: values.STR(vm.$store.state.i.username), + 'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => { + await vm.$root.dialog({ + type: type ? type.value : 'info', + title: title.value, + text: text.value, + }); + }), + 'Mk:confirm': values.FN_NATIVE(async ([title, text]) => { + const confirm = await vm.$root.dialog({ + type: 'warning', + showCancelButton: true, + title: title.value, + text: text.value, + }); + return confirm.canceled ? values.FALSE : values.TRUE + }), + 'Mk:api': values.FN_NATIVE(async ([ep, param, token]) => { + const res = await vm.$root.api(ep.value, utils.valToJs(param), token || null); + return utils.jsToVal(res); + }), + }; +} |