Skip to content

Commit 3bea44b

Browse files
committed
Merge branch 'develop'
2 parents 2a15425 + 62c376e commit 3bea44b

10 files changed

Lines changed: 501 additions & 207 deletions

File tree

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<script src="https://cdn.jsdelivr.net/npm/comfy.js@latest/dist/comfy.min.js"></script>
1212
<!-- IndexedDB -->
1313
<script src="https://cdn.jsdelivr.net/npm/idb-keyval@3/dist/idb-keyval-iife.min.js"></script>
14+
<!-- UUID -->
15+
<script src="https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/uuidv4.min.js"></script>
1416
<script src="js/utils/utils.js"></script>
1517
<script src="js/utils/shlex.js"></script>
1618
<script src="js/utils/idb-service.js"></script>
@@ -26,7 +28,8 @@
2628
<script src="js/message/messageHandler.js"></script>
2729
<script src="js/chat/chatHandler.js"></script>
2830
<script src="js/api/apiHandler.js"></script>
29-
<script src="js/actions/actionsHandler.js"></script>
31+
<script src="js/action/actionHandler.js"></script>
32+
<script src="js/cooldown/cooldownHandler.js"></script>
3033
<script src="js/debug/debugHandler.js"></script>
3134
<script src="js/param/paramHandler.js"></script>
3235
<script src="js/discord/discordHandler.js"></script>

js/Documentation.md

Lines changed: 171 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ Each handler provides its own triggers and actions that can be used in a trigger
1010
* [Parameters](#parameters)
1111
* [Aliases](#aliases)
1212
- [Default Parameters](#default-parameters)
13-
- [Actions](#actions)
14-
* [Triggers](#actions-triggers)
13+
- [Action](#action)
14+
* [Triggers](#action-triggers)
1515
+ [OnAction](#onaction)
16-
* [Actions](#actions-actions)
16+
* [Actions](#action-actions)
17+
+ [Action](#action-1)
1718
- [API](#api)
1819
* [Triggers](#api-triggers)
1920
* [Actions](#api-actions)
@@ -41,6 +42,15 @@ Each handler provides its own triggers and actions that can be used in a trigger
4142
* [Actions](#chat-actions)
4243
+ [Chat Send](#chat-send)
4344
+ [Chat Whisper](#chat-whisper)
45+
- [Cooldown](#cooldown)
46+
* [Triggers](#cooldown-triggers)
47+
* [Actions](#cooldown-actions)
48+
+ [Cooldown Apply](#cooldown-apply)
49+
+ [Cooldown Check](#cooldown-check)
50+
+ [Cooldown Clear](#cooldown-clear)
51+
+ [Cooldown Global Apply](#cooldown-global-apply)
52+
+ [Cooldown Global Check](#cooldown-global-check)
53+
+ [Cooldown Global Clear](#cooldown-global-clear)
4454
- [Debug](#debug)
4555
* [Triggers](#debug-triggers)
4656
* [Actions](#debug-actions)
@@ -103,8 +113,6 @@ Each handler provides its own triggers and actions that can be used in a trigger
103113
+ [OnInit](#oninit)
104114
* [Actions](#miscellaneous-actions)
105115
+ [AsyncFunction](#asyncfunction)
106-
+ [Cooldown Apply](#cooldown-apply)
107-
+ [Cooldown Check](#cooldown-check)
108116
+ [Delay](#delay)
109117
+ [Error](#error)
110118
+ [Exit](#exit)
@@ -129,6 +137,12 @@ Each handler provides its own triggers and actions that can be used in a trigger
129137
+ [OBS CurrentScene](#obs-currentscene)
130138
+ [OBS IsSceneSourceVisible](#obs-isscenesourcevisible)
131139
+ [OBS IsSourceActive](#obs-issourceactive)
140+
+ [OBS Media Duration](#obs-media-duration)
141+
+ [OBS Media Path](#obs-media-path)
142+
+ [OBS Media Pause](#obs-media-pause)
143+
+ [OBS Media Play](#obs-media-play)
144+
+ [OBS Media Restart](#obs-media-restart)
145+
+ [OBS Media Stop](#obs-media-stop)
132146
+ [OBS Mute](#obs-mute)
133147
+ [OBS Position](#obs-position)
134148
+ [OBS Refresh](#obs-refresh)
@@ -192,7 +206,6 @@ Each handler provides its own triggers and actions that can be used in a trigger
192206
- [StreamElements](#streamelements)
193207
* [Triggers](#streamelements-triggers)
194208
+ [OnSETwitchBits](#onsetwitchbits)
195-
+ [OnSETwitchBulkGiftSub](#onsetwitchbulkgiftsub)
196209
+ [OnSEDonation](#onsedonation)
197210
+ [OnSETwitchFollow](#onsetwitchfollow)
198211
+ [OnSETwitchGiftSub](#onsetwitchgiftsub)
@@ -355,10 +368,10 @@ The following parameters are always available. Use the `_successful_` and `_unsu
355368

356369
***
357370

358-
## Actions
371+
## Action
359372
Enables the ability to create your own actions within Kruiz Control.
360373

361-
### Actions Triggers
374+
### Action Triggers
362375

363376
#### OnAction
364377
| | |
@@ -374,8 +387,15 @@ Enables the ability to create your own actions within Kruiz Control.
374387

375388
***
376389

377-
### Actions Actions
378-
None at the moment.
390+
### Action Actions
391+
392+
#### Action
393+
| | |
394+
------------ | -------------
395+
**Info** | Used to run an action by passing it through. This allows actions to be fired dynamically within an event. `<action>` is the full action that you want to complete. The action can be provided as a single argument (inside of quotes) or written out normally.
396+
**Format** | `Action <action>`
397+
**Example** | `Action Chat Send "Hello world"`
398+
**Example w/ single argument** | `Action "Chat Send 'Hello world'"`
379399

380400
***
381401

@@ -683,6 +703,88 @@ _WARNING: Kruiz Control responds to messages sent by Kruiz Control. Please be mi
683703

684704
***
685705

706+
## Cooldown
707+
Adds the ability to give events a cooldown so that they cannot be repeated within a period of time.
708+
709+
### Cooldown Triggers
710+
None at the moment.
711+
712+
***
713+
714+
### Cooldown Actions
715+
716+
#### Cooldown Apply
717+
| | |
718+
------------ | -------------
719+
**Info** | Used to apply a cooldown to triggers. `<name>` is the identifier for the cooldown. `<seconds>` is the number of seconds before the trigger can fire again.
720+
**Format** | `Cooldown Apply <name> <seconds>`
721+
**Example** | `Cooldown Apply MyCustomTrigger 30`
722+
723+
***
724+
725+
#### Cooldown Check
726+
| | |
727+
------------ | -------------
728+
**Info** | Used to check if a cooldown is active. `<name>` is the identifier for the cooldown.
729+
**Format** | `Cooldown Check <name>`
730+
**Example** | `Cooldown Check MyCustomTrigger`
731+
732+
##### Parameters
733+
| | |
734+
------------ | -------------
735+
**\<name\>** | [True/False] Whether or not the cooldown is active where **\<name\>** is the name of the cooldown.
736+
**cooldown** | The number of seconds (rounded to a whole number) left on the cooldown. This is only returned if the cooldown is active (`<name>` is True).
737+
**cooldown_real** | The decimal number of seconds left on the cooldown. This is only returned if the cooldown is active (`<name>` is True).
738+
739+
_Note: The above example, `Cooldown Check MyCustomTrigger`, would return the parameter **MyCustomTrigger**._
740+
741+
***
742+
743+
#### Cooldown Clear
744+
| | |
745+
------------ | -------------
746+
**Info** | Used to clear (remove) an existing cooldown. `<name>` is the identifier for the cooldown.
747+
**Format** | `Cooldown Clear <name>`
748+
**Example** | `Cooldown Clear MyCustomTrigger`
749+
750+
***
751+
752+
#### Cooldown Global Apply
753+
| | |
754+
------------ | -------------
755+
**Info** | Used to apply a global cooldown to triggers. Global cooldowns persist between sessions (i.e. the cooldown remains after a reset). `<name>` is the identifier for the cooldown. `<seconds>` is the number of seconds before the trigger can fire again.
756+
**Format** | `Cooldown Global Apply <name> <seconds>`
757+
**Example** | `Cooldown Global Apply MyCustomTrigger 30`
758+
759+
***
760+
761+
#### Cooldown Global Check
762+
| | |
763+
------------ | -------------
764+
**Info** | Used to check if a global cooldown is active. Global cooldowns persist between sessions (i.e. the cooldown remains after a reset). `<name>` is the identifier for the cooldown.
765+
**Format** | `Cooldown Global Check <name>`
766+
**Example** | `Cooldown Global Check MyCustomTrigger`
767+
768+
##### Parameters
769+
| | |
770+
------------ | -------------
771+
**\<name\>** | [True/False] Whether or not the cooldown is active where **\<name\>** is the name of the cooldown.
772+
**cooldown** | The number of seconds (rounded to a whole number) left on the cooldown. This is only returned if the cooldown is active (`<name>` is True).
773+
**cooldown_real** | The decimal number of seconds left on the cooldown. This is only returned if the cooldown is active (`<name>` is True).
774+
775+
_Note: The above example, `Cooldown Global Check MyCustomTrigger`, would return the parameter **MyCustomTrigger**._
776+
777+
***
778+
779+
#### Cooldown Global Clear
780+
| | |
781+
------------ | -------------
782+
**Info** | Used to clear (remove) an existing global cooldown. Global cooldowns persist between sessions (i.e. the cooldown remains after a reset). `<name>` is the identifier for the cooldown.
783+
**Format** | `Cooldown Global Clear <name>`
784+
**Example** | `Cooldown Global Clear MyCustomTrigger`
785+
786+
***
787+
686788
## Debug
687789
Adds optional logging to Kruiz Control for debugging purposes.
688790

@@ -1265,33 +1367,6 @@ A small selection of actions that are included for increased usability.
12651367

12661368
***
12671369

1268-
#### Cooldown Apply
1269-
| | |
1270-
------------ | -------------
1271-
**Info** | Used to apply a cooldown to triggers. `<name>` is the identifier for the cooldown. `<seconds>` is the number of seconds before the trigger can fire again.
1272-
**Format** | `Cooldown Apply <name> <seconds>`
1273-
**Example** | `Cooldown Apply MyCustomTrigger 30`
1274-
1275-
***
1276-
1277-
#### Cooldown Check
1278-
| | |
1279-
------------ | -------------
1280-
**Info** | Used to check if a cooldown is active. `<name>` is the identifier for the cooldown.
1281-
**Format** | `Cooldown Check <name>`
1282-
**Example** | `Cooldown Check MyCustomTrigger`
1283-
1284-
##### Parameters
1285-
| | |
1286-
------------ | -------------
1287-
**\<name\>** | [True/False] Whether or not the cooldown is active where **\<name\>** is the name of the cooldown.
1288-
**cooldown** | The number of seconds (rounded to a whole number) left on the cooldown. This is only returned if the cooldown is active (`<name>` is True).
1289-
**cooldown_real** | The decimal number of seconds left on the cooldown. This is only returned if the cooldown is active (`<name>` is True).
1290-
1291-
_Note: The above example, `Cooldown Check MyCustomTrigger`, would return the parameter **MyCustomTrigger**._
1292-
1293-
***
1294-
12951370
#### Delay
12961371
| | |
12971372
------------ | -------------
@@ -1556,6 +1631,65 @@ Enables the ability to interact with and respond to OBS.
15561631

15571632
***
15581633

1634+
#### OBS Media Duration
1635+
| | |
1636+
------------ | -------------
1637+
**Info** | Used to retrieve the duration of a media source. `<source>` is the name of the source.
1638+
**Format** | `OBS Media Duration <source>`
1639+
**Example** | `OBS Media Duration AlertVideo`
1640+
1641+
##### Parameters
1642+
| | |
1643+
------------ | -------------
1644+
**duration** | The duration of the file in seconds.
1645+
1646+
***
1647+
1648+
#### OBS Media Path
1649+
| | |
1650+
------------ | -------------
1651+
**Info** | Used to set the file path of a media source. `<source>` is the name of the source. `<path>` is the absolute path to the file.
1652+
**Format** | `OBS Media Path <source> <path>`
1653+
**Example** | `OBS Media Path AlertVideo "C:/Users/YOUR_USER_NAME/Stream/alert.webm"`
1654+
1655+
***
1656+
1657+
#### OBS Media Pause
1658+
| | |
1659+
------------ | -------------
1660+
**Info** | Used to pause a media source. `<source>` is the name of the source.
1661+
**Format** | `OBS Media Pause <source>`
1662+
**Example** | `OBS Media Pause AlertVideo`
1663+
1664+
***
1665+
1666+
#### OBS Media Play
1667+
| | |
1668+
------------ | -------------
1669+
**Info** | Used to play a media source. `<source>` is the name of the source.
1670+
**Format** | `OBS Media Play <source>`
1671+
**Example** | `OBS Media Play AlertVideo`
1672+
1673+
***
1674+
1675+
#### OBS Media Restart
1676+
| | |
1677+
------------ | -------------
1678+
**Info** | Used to restart a media source. `<source>` is the name of the source.
1679+
**Format** | `OBS Media Restart <source>`
1680+
**Example** | `OBS Media Restart AlertVideo`
1681+
1682+
***
1683+
1684+
#### OBS Media Stop
1685+
| | |
1686+
------------ | -------------
1687+
**Info** | Used to stop a media source. `<source>` is the name of the source.
1688+
**Format** | `OBS Media Stop <source>`
1689+
**Example** | `OBS Media Stop AlertVideo`
1690+
1691+
***
1692+
15591693
#### OBS Mute
15601694
| | |
15611695
------------ | -------------
@@ -2191,13 +2325,6 @@ Enables the ability to trigger actions based on StreamElement alerts. Note that
21912325

21922326
***
21932327

2194-
#### OnSETwitchBulkGiftSub
2195-
| | |
2196-
------------ | -------------
2197-
**Info** | Used to trigger actions when someone gifts multiple subscriptions to the community.
2198-
**Format** | `OnSETwitchBulkGiftSub`
2199-
**Example** | `OnSETwitchBulkGiftSub`
2200-
22012328
##### Parameters
22022329
| | |
22032330
------------ | -------------
Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class ActionsHandler extends Handler {
1+
class ActionHandler extends Handler {
22
/**
33
* Create a new Actions handler.
44
*/
55
constructor() {
6-
super('Actions', ['OnAction']);
6+
super('Action', ['OnAction']);
77
this.actions = [];
88
this.actionsTriggers = {};
99
this.success();
@@ -33,12 +33,22 @@ class ActionsHandler extends Handler {
3333
* @param {array} triggerData contents of trigger line
3434
*/
3535
async handleData(triggerData) {
36-
var action = triggerData[0].toLowerCase();
37-
var inputs = {};
38-
for (var i = 1; i < triggerData.length; i++) {
39-
inputs[`in${i}`] = triggerData[i];
40-
}
41-
if (this.actions.indexOf(action) != -1) {0
36+
var action = Parser.getAction(triggerData, 'Action', -1);
37+
38+
if (action === "action") {
39+
if (triggerData.length > 2) {
40+
triggerData.shift();
41+
return { actions: [triggerData] };
42+
} else if (triggerData.length === 2) {
43+
return { actions: [triggerData[1]] };
44+
} else {
45+
console.error('No action provided to the Action handler: ' + JSON.stringify(triggerData));
46+
}
47+
} else if (this.actions.indexOf(action) != -1) {
48+
var inputs = {};
49+
for (var i = 1; i < triggerData.length; i++) {
50+
inputs[`in${i}`] = triggerData[i];
51+
}
4252
return { "_trigId": this.actionsTriggers[action], ...inputs };
4353
} else {
4454
console.error('Unable to find parser for input: ' + action);
@@ -49,7 +59,7 @@ class ActionsHandler extends Handler {
4959
/**
5060
* Create a handler
5161
*/
52-
function actionsHandlerExport() {
53-
var actions = new ActionsHandler();
62+
function actionHandlerExport() {
63+
var actionHandler = new ActionHandler();
5464
}
55-
actionsHandlerExport();
65+
actionHandlerExport();

js/chat/chatHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class ChatHandler extends Handler {
305305
});
306306

307307
// Check for matching command and user permission
308-
var command = message.split(' ')[0];
308+
var command = message.split(' ')[0].toLowerCase();
309309
if(this.commandsOther.indexOf(command) != -1) {
310310
var args = Parser.splitLine(message);
311311
var chatArgs = {};

0 commit comments

Comments
 (0)