From 3918bb46db8657df6022db7e82084d81fec471ba Mon Sep 17 00:00:00 2001 From: Hannah-GBS Date: Fri, 30 Aug 2024 00:50:01 +0100 Subject: [PATCH] Misc Changes --- packages/packages/src/discord/gateway.ts | 6 ++++ packages/packages/src/http.ts | 6 ++-- packages/packages/src/map.ts | 2 +- packages/packages/src/obs/requests.ts | 32 ++++++++++++++++++ packages/packages/src/utils.ts | 43 ++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) diff --git a/packages/packages/src/discord/gateway.ts b/packages/packages/src/discord/gateway.ts index 2f6f62c0..48b43fa8 100644 --- a/packages/packages/src/discord/gateway.ts +++ b/packages/packages/src/discord/gateway.ts @@ -131,6 +131,11 @@ export function register(pkg: Package, { gateway }: Ctx) { name: "Message", type: t.string(), }), + messageID: io.dataOutput({ + id: "messageID", + name: "Message ID", + type: t.string(), + }), channelId: io.dataOutput({ id: "channelId", name: "Channel ID", @@ -164,6 +169,7 @@ export function register(pkg: Package, { gateway }: Ctx) { }), run({ ctx, data, io }) { ctx.setOutput(io.message, data.content); + ctx.setOutput(io.messageID, data.id); ctx.setOutput(io.channelId, data.channel_id); ctx.setOutput(io.username, data.author.username); ctx.setOutput(io.userId, data.author.id); diff --git a/packages/packages/src/http.ts b/packages/packages/src/http.ts index 3cb865fd..9d385290 100644 --- a/packages/packages/src/http.ts +++ b/packages/packages/src/http.ts @@ -279,7 +279,7 @@ export function pkg(core: Core) { } let type: string; - let body: string | FormData | null; + let body: string | FormData | null = null; const input = ctx.getInput(io.body); switch (input.variant) { case "Plaintext": { @@ -582,8 +582,8 @@ export function pkg(core: Core) { name: "Body Type", source: () => BodyEnum.variants.map((value) => ({ - id: value.name, - display: value.name, + id: value.id, + display: value.id, })), } satisfies PropertyDef; diff --git a/packages/packages/src/map.ts b/packages/packages/src/map.ts index bc8d105d..0bfe7744 100644 --- a/packages/packages/src/map.ts +++ b/packages/packages/src/map.ts @@ -92,7 +92,7 @@ export function pkg() { }; }, run({ ctx, io }) { - const map = ctx.getInput(io.mapIn); + const map = new ReactiveMap(ctx.getInput(io.mapIn)); for (const input of io.pins) { map.set(ctx.getInput(input.key), ctx.getInput(input.value)); ctx.setOutput(input.current, Maybe(map.get(ctx.getInput(input.key)))); diff --git a/packages/packages/src/obs/requests.ts b/packages/packages/src/obs/requests.ts index cd8ec220..877106eb 100644 --- a/packages/packages/src/obs/requests.ts +++ b/packages/packages/src/obs/requests.ts @@ -2315,6 +2315,38 @@ export function register(pkg: Package) { }, }); + createOBSExecSchema({ + name: "Get Scene Item Source", + createIO: ({ io, obs }) => { + return { + sceneName: io.dataInput({ + id: "sceneName", + name: "Scene Name", + type: t.string(), + fetchSuggestions: sceneListSuggestionFactory(obs), + }), + sceneItemId: io.dataInput({ + id: "sceneItemId", + name: "Scene Item Id", + type: t.int(), + }), + + sourceName: io.dataOutput({ + id: "sourceName", + name: "Source Name", + type: t.string(), + }), + }; + }, + async run({ ctx, io, obs }) { + const data = await obs.call("GetSceneItemSource", { + sceneName: ctx.getInput(io.sceneName), + sceneItemId: ctx.getInput(io.sceneItemId), + }); + ctx.setOutput(io.sourceName, data.sourceName); + }, + }); + createOBSExecSchema({ name: "Create Scene Item", createIO: ({ io, obs }) => ({ diff --git a/packages/packages/src/utils.ts b/packages/packages/src/utils.ts index 5acc7795..9581828d 100644 --- a/packages/packages/src/utils.ts +++ b/packages/packages/src/utils.ts @@ -1640,6 +1640,49 @@ export function pkg(core: Core) { }, }); + pkg.createSchema({ + name: "Split Lines", + type: "pure", + createIO({ io }) { + return { + input: io.dataInput({ + id: "input", + name: "String", + type: t.string(), + }), + output: io.dataOutput({ + id: "output", + type: t.list(t.string()), + }), + }; + }, + run({ ctx, io }) { + const array = ctx.getInput(io.input).split(/[\r\n]+/); + ctx.setOutput(io.output, array); + }, + }); + + pkg.createSchema({ + name: "Join Lines", + type: "pure", + createIO({ io }) { + return { + input: io.dataInput({ + id: "input", + name: "Lines", + type: t.list(t.string()), + }), + output: io.dataOutput({ + id: "output", + type: t.string(), + }), + }; + }, + run({ ctx, io }) { + ctx.setOutput(io.output, ctx.getInput(io.input).join("\n")); + }, + }); + pkg.createSchema({ name: "Nth Word", type: "pure",