Skip to content

Commit 4be1476

Browse files
authored
more twitch comannds (#535)
* Fix using spaces in filter - prevent toggling the filter * add more twitch scopes for more commands + Twitch Command-Block: Announcement * Twitch Command-Block: Clear Chat * Twitch Command-Block: Start Commercial, Create Marker, Change Chat Settings * Improve UI of Command Blocks (and Settings)
1 parent 91f3a7b commit 4be1476

28 files changed

+497
-106
lines changed

projects/action-variables-ui/src/lib/action-variable-input/action-variable-input.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
<ng-container *ngSwitchCase="'boolean'">
2828
<mat-slide-toggle [checked]="!!value"
2929
(change)="value = $event.checked; valueChanged.emit($event.checked)">
30-
{{label}}
30+
<strong *ngIf="boldLabel">{{label}}</strong>
31+
<ng-container *ngIf="!boldLabel">{{label}}</ng-container>
3132
</mat-slide-toggle>
3233
</ng-container>
3334

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
:host(.full-width){
2+
mat-form-field {
3+
width: 100%
4+
}
5+
}

projects/action-variables-ui/src/lib/action-variable-input/action-variable-input.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
1+
import {Component, EventEmitter, HostBinding, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
22
import {DialogService} from "../../../../../src/app/shared/dialogs/dialog.service";
33
import {ActionAssigningMode} from "@memebox/contracts";
44
import {BehaviorSubject, combineLatest} from "rxjs";
@@ -22,6 +22,13 @@ export class ActionVariableInputComponent implements OnInit, OnChanges {
2222
@Input()
2323
public value: unknown;
2424

25+
@Input()
26+
public boldLabel: boolean;
27+
28+
@Input()
29+
@HostBinding('class.full-width')
30+
public fullWidth: boolean;
31+
2532
@Output()
2633
public readonly valueChanged = new EventEmitter<unknown>();
2734

projects/contracts/src/lib/constants.ts

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,72 @@ export const TWITCH_BOT_RESPONSE_CONSTS = {
104104

105105
export const TWITCH_CLIENT_ID = 'zmqh0d2kwa9r24eecywm5uhhryggm4';
106106

107-
export const DEFAULT_TWITCH_SCOPES = [
108-
// 'user:read:email', // ???
109-
'chat:read', // TMI - Chat
110-
'chat:edit', // TMI - Write to chat?
111-
'channel:read:redemptions', // PubSub Channelpoints Event
107+
export interface TwitchScopeMetadata {
108+
scope: string;
109+
features: string[];
110+
}
111+
112+
export const DEFAULT_TWITCH_SCOPES: TwitchScopeMetadata[] = [
113+
{
114+
scope: 'chat:read',
115+
features: [
116+
'Listening to chat messages ...duh'
117+
]
118+
},
119+
{
120+
scope: 'chat:edit',
121+
features: [
122+
'Writing in the Chat'
123+
]
124+
},
125+
{
126+
scope: 'channel:read:redemptions',
127+
features:[
128+
'Trigger: Channel Point Redemption'
129+
]
130+
},
131+
{
132+
// https://dev.twitch.tv/docs/api/reference#send-chat-announcement
133+
scope: 'moderator:manage:announcements',
134+
features: [
135+
'Ability to write Chat Announcements'
136+
]
137+
},
138+
{
139+
// https://dev.twitch.tv/docs/api/reference#delete-chat-messages
140+
scope: 'moderator:manage:chat_messages',
141+
features: [
142+
'Clear the chat'
143+
]
144+
},
145+
{
146+
// https://dev.twitch.tv/docs/api/reference#start-commercial
147+
scope: 'channel:edit:commercial',
148+
features: [
149+
'Start Commercial'
150+
]
151+
},
152+
/*{
153+
// https://dev.twitch.tv/docs/api/reference#start-a-raid
154+
scope: 'channel:manage:raids',
155+
features: [
156+
'Start a raid'
157+
]
158+
},*/
159+
{
160+
// https://dev.twitch.tv/docs/api/reference#create-stream-marker
161+
scope: 'channel:manage:broadcast',
162+
features: [
163+
'Create Stream Marker'
164+
]
165+
},
166+
{
167+
// https://dev.twitch.tv/docs/api/reference#update-chat-settings
168+
scope: 'moderator:manage:chat_settings',
169+
features: [
170+
'Update Chat Settings: Slow, Sub only, Follower only, Unique'
171+
]
172+
}
112173
];
174+
175+
export const DEFAULT_TWITCH_SCOPE_LIST = DEFAULT_TWITCH_SCOPES.map(s => s.scope);

projects/recipe-core/src/lib/command-blocks.generic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function registerGenericCommandBlocks(
1717
],
1818
toScriptCode: (step, context) => `sleep.secondsAsync(${step.payload.seconds});`,
1919
commandEntryLabelAsync: (queries, payload, parentStep) => {
20-
return Promise.resolve(`sleep: ${payload.seconds} seconds`);
20+
return Promise.resolve(`wait ${payload.seconds} seconds`);
2121
},
2222
entryIcon: () => 'hourglass_top'
2323
};
@@ -35,7 +35,7 @@ export function registerGenericCommandBlocks(
3535
],
3636
toScriptCode: (step, context) => `sleep.msAsync(${step.payload.ms});`,
3737
commandEntryLabelAsync: (queries, payload, parentStep) => {
38-
return Promise.resolve(`sleep: ${payload.ms}ms`);
38+
return Promise.resolve(`wait ${payload.ms}ms`);
3939
},
4040
entryIcon: () => 'hourglass_top'
4141
};
Lines changed: 176 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
import {RecipeCommandBlockRegistry} from "./recipe.types";
22

3-
/*
4-
* Announcements: moderator:manage:announcements
5-
* https://dev.twitch.tv/docs/api/reference#send-chat-announcement
6-
*
7-
* Clear chat: moderator:manage:chat_messages
8-
* https://dev.twitch.tv/docs/api/reference#delete-chat-messages
9-
*
10-
* Start Commercial: channel:edit:commercial
11-
* https://dev.twitch.tv/docs/api/reference#start-commercial
3+
/* Command Block Ideas
124
*
135
* Start a Raid: channel:manage:raids
146
* https://dev.twitch.tv/docs/api/reference#start-a-raid
15-
*
16-
* Create Stream Marker: channel:manage:broadcast
17-
* https://dev.twitch.tv/docs/api/reference#create-stream-marker
18-
*
19-
* Chat Settings: moderator:manage:chat_settings
20-
* https://dev.twitch.tv/docs/api/reference#update-chat-settings
21-
* Slow, Sub only, Follower only, unique
7+
* Dependency:
8+
* Resolve BroadcasterID based on a username
229
*/
2310

2411
export function registerTwitchCommandBlocks (
@@ -30,7 +17,7 @@ export function registerTwitchCommandBlocks (
3017
configArguments: [
3118
{
3219
name: "text",
33-
label: "Message to say",
20+
label: "Message to write",
3421
type: "textarea"
3522
}
3623
],
@@ -42,7 +29,177 @@ export function registerTwitchCommandBlocks (
4229
commandEntryLabelAsync: (queries, payload) => {
4330
const textToSay = payload.text as string;
4431

45-
return Promise.resolve('Twitch: Say: '+ textToSay);
46-
}
32+
return Promise.resolve('Write in Chat: '+ textToSay);
33+
},
34+
entryIcon: () => 'twitch',
35+
};
36+
37+
// https://dev.twitch.tv/docs/api/reference#send-chat-announcement
38+
registry['twitch:sendAnnouncement'] = {
39+
pickerLabel: "Send a Chat Announcement",
40+
commandGroup: "twitch",
41+
configArguments: [
42+
{
43+
name: "text",
44+
label: "Announcement to send",
45+
type: "textarea"
46+
},
47+
{
48+
name: "color",
49+
label: "Color of this announcement",
50+
type: "selectionStatic",
51+
defaultSelected: 'primary',
52+
entries: [
53+
{
54+
id: 'primary',
55+
label: 'Primary',
56+
57+
},
58+
{
59+
id: 'blue',
60+
label: 'Blue',
61+
},
62+
{
63+
id: 'green',
64+
label: 'Green',
65+
},
66+
{
67+
id: 'orange',
68+
label: 'Orange',
69+
},
70+
{
71+
id: 'purple',
72+
label: 'Purple',
73+
}
74+
]
75+
}
76+
],
77+
toScriptCode: (step) => {
78+
const textToSay = step.payload.text as string;
79+
const color = step.payload.color as string;
80+
81+
return `twitch.sendAnnouncement('${textToSay}','${color}');`;
82+
},
83+
commandEntryLabelAsync: (queries, payload) => {
84+
const textToSay = payload.text as string;
85+
const color = payload.color as string;
86+
87+
return Promise.resolve(`${color} Announcement: ${textToSay}`);
88+
},
89+
entryIcon: () => 'twitch',
90+
};
91+
92+
// https://dev.twitch.tv/docs/api/reference#delete-chat-messages
93+
registry['twitch:clearChat'] = {
94+
pickerLabel: "Clear Chat",
95+
commandGroup: "twitch",
96+
configArguments: [],
97+
toScriptCode: () => {
98+
return `twitch.clearChat();`;
99+
},
100+
commandEntryLabelAsync: (queries, payload) => {
101+
return Promise.resolve(`Clear Chat`);
102+
},
103+
entryIcon: () => 'twitch',
104+
};
105+
106+
107+
// https://dev.twitch.tv/docs/api/reference#start-commercial
108+
registry['twitch:startCommercial'] = {
109+
pickerLabel: "Start Commercial",
110+
commandGroup: "twitch",
111+
configArguments: [
112+
{
113+
name: "length",
114+
label: "Commercial Length",
115+
type: "selectionStatic",
116+
defaultSelected: '30',
117+
entries: [
118+
{
119+
id: '30',
120+
label: '30 Seconds',
121+
},
122+
{
123+
id: '60',
124+
label: '60 Seconds',
125+
},
126+
{
127+
id: '90',
128+
label: '90 Seconds',
129+
},
130+
{
131+
id: '120',
132+
label: '120 Seconds',
133+
},
134+
{
135+
id: '150',
136+
label: '150 Seconds',
137+
},
138+
{
139+
id: '180',
140+
label: '180 Seconds',
141+
}
142+
]
143+
}
144+
],
145+
toScriptCode: (command) => {
146+
const length = command.payload.length as string;
147+
return `twitch.startCommercial(${+length});`;
148+
},
149+
commandEntryLabelAsync: (queries, payload) => {
150+
const length = payload.length as string;
151+
return Promise.resolve(`Start Commercial for ${length} Seconds`);
152+
},
153+
entryIcon: () => 'twitch',
154+
};
155+
156+
// https://dev.twitch.tv/docs/api/reference#create-stream-marker
157+
registry['twitch:createMarker'] = {
158+
pickerLabel: "Create Marker",
159+
commandGroup: "twitch",
160+
configArguments: [],
161+
toScriptCode: () => {
162+
return `twitch.createMarker();`;
163+
},
164+
commandEntryLabelAsync: (queries, payload) => {
165+
return Promise.resolve(`Create Marker`);
166+
},
167+
entryIcon: () => 'twitch',
168+
};
169+
170+
// https://dev.twitch.tv/docs/api/reference#update-chat-settings
171+
registry['twitch:changeChatSettings'] = {
172+
pickerLabel: "Change Chat Settings",
173+
commandGroup: "twitch",
174+
configArguments: [
175+
{
176+
name: "emote_mode",
177+
label: "Emote Mode",
178+
type: "boolean"
179+
}, {
180+
name: "follower_mode",
181+
label: "Follower Mode",
182+
type: "boolean"
183+
}, {
184+
name: "slow_mode",
185+
label: "Slow Mode",
186+
type: "boolean"
187+
}, {
188+
name: "subscriber_mode",
189+
label: "Subscriber Mode",
190+
type: "boolean"
191+
}, {
192+
name: "unique_chat_mode",
193+
label: "Unique Chatter Mode",
194+
type: "boolean"
195+
},
196+
],
197+
toScriptCode: (step) => {
198+
return `twitch.updateChatSettings(${JSON.stringify(step.payload)});`;
199+
},
200+
commandEntryLabelAsync: (queries, payload) => {
201+
return Promise.resolve(`Update Chat Settings`);
202+
},
203+
entryIcon: () => 'twitch',
47204
};
48205
}

projects/recipe-core/src/lib/recipeStepConfigArgument.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export interface RecipeStepConfigNumberArgument extends RecipeStepConfigArgument
2121
type: 'number';
2222
}
2323

24+
export interface RecipeStepConfigStaticSelectionArgument extends RecipeStepConfigArgument {
25+
type: 'selectionStatic';
26+
entries: {id: string, label: string}[];
27+
defaultSelected: string;
28+
}
29+
2430
export interface RecipeStepConfigActionArgument extends RecipeStepConfigArgument {
2531
type: 'action';
2632
flags: {
@@ -46,6 +52,7 @@ export interface RecipeStepConfigObsFilterArgument extends RecipeStepConfigArgum
4652
export type RecipeStepConfigArguments =
4753
RecipeStepConfigBooleanArgument |RecipeStepConfigTextArgument|
4854
RecipeStepConfigTextareaArgument|RecipeStepConfigNumberArgument|
55+
RecipeStepConfigStaticSelectionArgument|
4956
RecipeStepConfigActionArgument|RecipeStepConfigActionListArgument|
5057
RecipeStepConfigObsSceneArgument|RecipeStepConfigObsSourceArgument|
5158
RecipeStepConfigObsFilterArgument

projects/recipe-ui/src/lib/command-setting-dialog/action-list-settings/action-list-settings.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@
3636
.type-of-selection {
3737
margin-right: 1rem;
3838
}
39+
40+
mat-card-title {
41+
min-width: 250px;
42+
max-width: 400px;
43+
}

projects/recipe-ui/src/lib/command-setting-dialog/action-selection/action-selection.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
display: flex;
44
}
55
}
6+
7+
mat-form-field {
8+
width: 100%;
9+
}

0 commit comments

Comments
 (0)