Skip to content

Commit 5d96e67

Browse files
authored
New Components - streamlabs (#15557)
* streamlabs init * new components * pnpm-lock.yaml * remove unnecessary makeRequest params
1 parent f52d5e7 commit 5d96e67

File tree

7 files changed

+369
-3
lines changed

7 files changed

+369
-3
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import streamlabs from "../../streamlabs.app.mjs";
2+
import currencies from "../../common/currencies.mjs";
3+
4+
export default {
5+
key: "streamlabs-create-donation",
6+
name: "Create Donation",
7+
description: "Create a donation for the authenticated user. [See the documentation](https://dev.streamlabs.com/reference/donations-1)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
streamlabs,
12+
name: {
13+
type: "string",
14+
label: "Name",
15+
description: "The name of the donor. Has to be between 2-25 length and should only contain utf8 characters",
16+
},
17+
identifier: {
18+
type: "string",
19+
label: "Identifier",
20+
description: "An identifier for this donor, which is used to group donations with the same donor. For example, if you create more than one donation with the same identifier, they will be grouped together as if they came from the same donor. Typically this is best suited as an email address, or a unique hash.",
21+
},
22+
amount: {
23+
type: "string",
24+
label: "Amount",
25+
description: "The amount of this donation",
26+
},
27+
currency: {
28+
type: "string",
29+
label: "Currency",
30+
description: "The 3 letter currency code for this donation. Must be one of the [supported currency codes](https://dev.streamlabs.com/docs/currency-codes)",
31+
options: currencies,
32+
},
33+
message: {
34+
type: "string",
35+
label: "Message",
36+
description: "The message from the donor. Must be < 255 characters",
37+
optional: true,
38+
},
39+
createdAt: {
40+
type: "string",
41+
label: "Created At",
42+
description: "A timestamp that identifies when this donation was made. If left blank, it will default to now. Enter in ISO-8601 format (e.g., `2018-02-18T02:30:00-07:00` or `2018-02-18T08:00:00Z`, where Z stands for UTC)",
43+
optional: true,
44+
},
45+
skipAlert: {
46+
type: "string",
47+
label: "Skip Alert",
48+
description: "Set to `yes` if you need to skip the alert. Default is `no`",
49+
options: [
50+
"yes",
51+
"no",
52+
],
53+
optional: true,
54+
},
55+
},
56+
async run({ $ }) {
57+
const response = await this.streamlabs.createDonation({
58+
$,
59+
data: {
60+
name: this.name,
61+
identifier: this.identifier,
62+
amount: parseFloat(this.amount),
63+
currency: this.currency,
64+
message: this.message,
65+
createdAt: this.createdAt && Date.parse(this.createdAt),
66+
skip_alert: this.skipAlert,
67+
},
68+
});
69+
if (response?.donation_id) {
70+
$.export("$summary", `Successfully created donation with ID: ${response.donation_id}`);
71+
}
72+
return response;
73+
},
74+
};
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import streamlabs from "../../streamlabs.app.mjs";
2+
3+
export default {
4+
key: "streamlabs-send-alert",
5+
name: "Send Alert",
6+
description: "Sends an alert to the stream overlay with a custom message, image, and sound. [See the documentation](https://dev.streamlabs.com/reference/alerts)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
streamlabs,
11+
type: {
12+
type: "string",
13+
label: "Type",
14+
description: "determines which alert box this alert will show up in",
15+
options: [
16+
"follow",
17+
"subscription",
18+
"donation",
19+
"host",
20+
],
21+
},
22+
message: {
23+
type: "string",
24+
label: "Message",
25+
description: "The message to show with this alert",
26+
},
27+
imageHref: {
28+
type: "string",
29+
label: "Image HREF",
30+
description: "The href pointing to an image resource to play when this alert shows",
31+
optional: true,
32+
},
33+
soundHref: {
34+
type: "string",
35+
label: "Sound HREF",
36+
description: "The href pointing to a sound resource to play when this alert shows",
37+
optional: true,
38+
},
39+
userMessage: {
40+
type: "string",
41+
label: "User Message",
42+
description: "Acting as the second heading, this shows below message",
43+
optional: true,
44+
},
45+
duration: {
46+
type: "string",
47+
label: "Duration",
48+
description: "How many seconds this alert should be displayed. Value should be in milliseconds. Ex: `1000` for 1 second.",
49+
optional: true,
50+
},
51+
specialTextColor: {
52+
type: "string",
53+
label: "Special Text Color",
54+
description: "The color to use for special tokens. Must be a valid CSS color string",
55+
optional: true,
56+
},
57+
},
58+
async run({ $ }) {
59+
const response = await this.streamlabs.sendAlert({
60+
$,
61+
data: {
62+
type: this.type,
63+
message: this.message,
64+
image_href: this.imageHref,
65+
sound_href: this.soundHref,
66+
user_message: this.userMessage,
67+
duration: this.duration,
68+
special_text_color: this.specialTextColor,
69+
},
70+
});
71+
$.export("$summary", `Alert sent with message: ${this.message}`);
72+
return response;
73+
},
74+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import streamlabs from "../../streamlabs.app.mjs";
2+
3+
export default {
4+
key: "streamlabs-send-test-alert",
5+
name: "Send Test Alert",
6+
description: "Send a test alert to the stream overlay in StreamLabs. [See the documentation](https://dev.streamlabs.com/reference/alertssend_test_alert)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
streamlabs,
11+
platform: {
12+
type: "string",
13+
label: "Platform",
14+
description: "The streaming platform",
15+
options: [
16+
"twitch",
17+
"youtube",
18+
],
19+
reloadProps: true,
20+
},
21+
},
22+
additionalProps() {
23+
if (!this.platform) {
24+
return {};
25+
}
26+
const props = {
27+
type: {
28+
type: "string",
29+
label: "Type",
30+
description: "The type of the alert",
31+
},
32+
};
33+
if (this.platform === "twitch") {
34+
props.type.options = [
35+
"follow",
36+
"subscription",
37+
"donation",
38+
"host",
39+
"bits",
40+
"raid",
41+
];
42+
}
43+
if (this.platform === "youtube") {
44+
props.type.options = [
45+
"subscription",
46+
"sponsor",
47+
"superchat",
48+
"donation",
49+
];
50+
}
51+
return props;
52+
},
53+
async run({ $ }) {
54+
const response = await this.streamlabs.sendTestAlert({
55+
$,
56+
data: {
57+
platform: this.platform,
58+
type: this.type,
59+
},
60+
});
61+
$.export("$summary", "Successfully sent test alert");
62+
return response;
63+
},
64+
};
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
export default [
2+
{
3+
value: "USD",
4+
label: "US Dollar",
5+
},
6+
{
7+
value: "AUD",
8+
label: "Australian Dollar",
9+
},
10+
{
11+
value: "BRL",
12+
label: "Brazilian Real",
13+
},
14+
{
15+
value: "CAD",
16+
label: "Canadian Dollar",
17+
},
18+
{
19+
value: "CZK",
20+
label: "Czech Koruna",
21+
},
22+
{
23+
value: "DKK",
24+
label: "Danish Krone",
25+
},
26+
{
27+
value: "EUR",
28+
label: "Euro",
29+
},
30+
{
31+
value: "HKD",
32+
label: "Hong Kong Dollar",
33+
},
34+
{
35+
value: "ILS",
36+
label: "Israeli New Sheqel",
37+
},
38+
{
39+
value: "MYR",
40+
label: "Malaysian Ringgit",
41+
},
42+
{
43+
value: "MXN",
44+
label: "Mexican Peso",
45+
},
46+
{
47+
value: "NOK",
48+
label: "Norwegian Krone",
49+
},
50+
{
51+
value: "NZD",
52+
label: "New Zealand Dollar",
53+
},
54+
{
55+
value: "PHP",
56+
label: "Philippine Peso",
57+
},
58+
{
59+
value: "PLN",
60+
label: "Polish Zloty",
61+
},
62+
{
63+
value: "GBP",
64+
label: "Pound Sterling",
65+
},
66+
{
67+
value: "RUB",
68+
label: "Russian Ruble",
69+
},
70+
{
71+
value: "SGD",
72+
label: "Singapore Dollar",
73+
},
74+
{
75+
value: "SEK",
76+
label: "Swedish Krona",
77+
},
78+
{
79+
value: "CHF",
80+
label: "Swiss Franc",
81+
},
82+
{
83+
value: "THB",
84+
label: "Thai Baht",
85+
},
86+
{
87+
value: "TRY",
88+
label: "Turkish Lira",
89+
},
90+
];

components/streamlabs/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@pipedream/streamlabs",
3+
"version": "0.0.1",
4+
"description": "Pipedream Streamlabs Components",
5+
"main": "streamlabs.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"streamlabs"
9+
],
10+
"homepage": "https://pipedream.com/apps/streamlabs",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
17+
}
18+
}
Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,51 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "streamlabs",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return "https://streamlabs.com/api/v1.0";
10+
},
11+
_accessToken() {
12+
return this.$auth.oauth_access_token;
13+
},
14+
_makeRequest({
15+
$ = this,
16+
path,
17+
data,
18+
...otherOpts
19+
}) {
20+
return axios($, {
21+
...otherOpts,
22+
url: `${this._baseUrl()}${path}`,
23+
data: {
24+
access_token: this._accessToken(),
25+
...data,
26+
},
27+
});
28+
},
29+
sendAlert(opts = {}) {
30+
return this._makeRequest({
31+
method: "POST",
32+
path: "/alerts",
33+
...opts,
34+
});
35+
},
36+
createDonation(opts = {}) {
37+
return this._makeRequest({
38+
method: "POST",
39+
path: "/donations",
40+
...opts,
41+
});
42+
},
43+
sendTestAlert(opts = {}) {
44+
return this._makeRequest({
45+
method: "POST",
46+
path: "/alerts/send_test_alert",
47+
...opts,
48+
});
949
},
1050
},
1151
};

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)