Skip to content

Commit

Permalink
Misc Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannah-GBS committed Aug 29, 2024
1 parent 9ce87b9 commit 3918bb4
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/packages/src/discord/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions packages/packages/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/packages/src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
Expand Down
32 changes: 32 additions & 0 deletions packages/packages/src/obs/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,38 @@ export function register(pkg: Package<EventTypes>) {
},
});

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 }) => ({
Expand Down
43 changes: 43 additions & 0 deletions packages/packages/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3918bb4

Please sign in to comment.