Skip to content

Commit

Permalink
Merge pull request #68 from Kruiser8/develop
Browse files Browse the repository at this point in the history
Update for v2.0.1
  • Loading branch information
Kruiser8 authored Jul 19, 2023
2 parents 404cf54 + 1f0b498 commit a7aa90e
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 21 deletions.
28 changes: 23 additions & 5 deletions js/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Each handler provides its own triggers and actions that can be used in a trigger
+ [List Index](#list-index)
+ [List Join](#list-join)
+ [List Remove](#list-remove)
+ [List Set](#list-remove)
+ [List Set](#list-set)
- [Message](#message)
* [Triggers](#message-triggers)
+ [OnMessage](#onmessage)
Expand Down Expand Up @@ -297,6 +297,7 @@ Each handler provides its own triggers and actions that can be used in a trigger
+ [Twitch Complete](#twitch-complete)
+ [Twitch Copy](#twitch-copy)
+ [Twitch CreateClip](#twitch-createclip)
+ [Twitch CreateReward](#twitch-createreward)
+ [Twitch DeleteMessage](#twitch-deletemessage)
+ [Twitch Description](#twitch-description)
+ [Twitch EmoteOnly](#twitch-emoteonly)
Expand Down Expand Up @@ -3714,10 +3715,10 @@ _Note: Bit voting is not currently supported, however Twitch provides these valu
##### Parameters
| | |
------------ | -------------
**id** | The user id of the user who sent the subscription gift.
**login** | The user login of the user who sent the subscription gift.
**name** | The user display name of the user who sent the subscription gift.
**tier** | The tier of subscriptions in the subscription gift. `1`, `2`, or `3` depending on what subscription tier the user is.
**id** | The user id of the user who sent the resubscription chat message.
**login** | The user login of the user who sent the resubscription chat message.
**name** | The user display name of the user who sent the resubscription chat message.
**tier** | The tier of subscription in the resubscription chat message. `1`, `2`, or `3` depending on what subscription tier the user is.
**message** | The resubscription message.
**months** | The total number of months the user has been subscribed to the channel.
**streak** | The number of consecutive months the user’s current subscription has been active. This value is empty if the user has opted out of sharing this information.
Expand Down Expand Up @@ -4025,6 +4026,23 @@ _Note: Due to a Twitch API restriction, in order for Kruiz Control to interact w
**Example** | `Twitch CreateClip`
**Example w/ optional_should_delay** | `Twitch CreateClip true`

##### Parameters
| | |
------------ | -------------
**data** | The complete response from the Twitch Create Clip API.
**url** | The url of the created clip.
**id** | The ID of the created clip.

***

#### Twitch CreateReward
| | |
------------ | -------------
**Info** | Creates a channel point reward in the broadcaster's stream. `<name>` is the name of the channel point reward. `<optional_cost>` is an optional input to set the cost of the reward (default: 1000).
**Format** | `Twitch CreateReward <name> <optional_cost>`
**Example** | `Twitch CreateReward Waldo`
**Example w/ optional_cost** | `Twitch CreateReward Waldo 1234`

***

#### Twitch DeleteMessage
Expand Down
17 changes: 12 additions & 5 deletions js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,25 @@ class Controller {
}

if (runParams.loops && runParams.lines) {
var loopId = uuidv4();
var toLoop = triggerSequence.slice(i + 1, i + runParams.lines + 1);
triggerSequence.splice(i+1, 0,
['Ignore', 'Param', 'Copy', 'loop_i', `loop_i_${loopId}`],
['Ignore', 'Param', 'Copy', 'loop', `loop_${loopId}`],
['Ignore', 'Param', 'Create', 'loop_i', '0'],
['Ignore', 'Param', 'Create', 'loop', '1']
);
triggerSequence.splice(i+2, 0, );
for (var loopLine = 0; loopLine < runParams.loops - 1; loopLine++) {
triggerSequence.splice(i+3, 0, ...toLoop,
['Ignore', 'Param', 'Add', 'loop_i', '1'],
['Ignore', 'Param', 'Add', 'loop', '1']
for (var loopLine = 1; loopLine < runParams.loops; loopLine++) {
triggerSequence.splice(i+3+(loopLine*(runParams.lines+2)), 0,
['Ignore', 'Param', 'Create', 'loop_i', String(loopLine)],
['Ignore', 'Param', 'Create', 'loop', String(loopLine + 1)],
...toLoop,
);
}
triggerSequence.splice(i+3+(runParams.loops*(runParams.lines+2)), 0,
['Ignore', 'Param', 'Copy', `loop_i_${loopId}`, 'loop_i'],
['Ignore', 'Param', 'Copy', `loop_${loopId}`, 'loop']
);
delete runParams.loops;
delete runParams.lines;
}
Expand Down
40 changes: 32 additions & 8 deletions js/twitch/twitchHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class TwitchHandler extends Handler {
* Create a new Timer handler.
*/
constructor() {
super('Twitch', ['OnTWCommunityGoalStart', 'OnTWCommunityGoalProgress', 'OnTWCommunityGoalComplete', 'OnTWChannelUpdate', 'OnTWFollow', 'OnTWSub', 'OnTWSubEnd', 'OnTWSubGift', 'OnTWSubMessage', 'OnTWCheer', 'OnTWRaid', 'OnTWBan', 'OnTWTimeout', 'OnTWUnban', 'OnTWModAdd', 'OnTWModRemove', 'OnTWChannelPoint', 'OnTWChannelPointCompleted', 'OnTWChannelPointRejected', 'OnTWPoll', 'OnTWPollUpdate', 'OnTWPollEnd', 'OnTWPrediction', 'OnTWPredictionUpdate', 'OnTWPredictionLock', 'OnTWPredictionEnd', 'OnTWHypeTrainStart', 'OnTWHypeTrainProgress', 'OnTWHypeTrainEnd', 'OnTWCharityDonation', 'OnTWCharityStarted', 'OnTWCharityProgress', 'OnTWCharityStopped', 'OnTWShieldStarted', 'OnTWShieldStopped', 'OnTWShoutout', 'OnTWShoutoutReceived', 'OnTWGoalStarted', 'OnTWGoalProgress', 'OnTWGoalCompleted', 'OnTWGoalFailed', 'OnTWStreamStarted', 'OnTWStreamStopped']);
super('Twitch', ['OnTWCommunityGoalStart', 'OnTWCommunityGoalProgress', 'OnTWCommunityGoalComplete', 'OnTWChannelUpdate', 'OnTWFollow', 'OnTWSub', 'OnTWSubEnd', 'OnTWSubGift', 'OnTWSubMessage', 'OnTWCheer', 'OnTWRaid', 'OnTWBan', 'OnTWTimeout', 'OnTWUnban', 'OnTWModAdd', 'OnTWModRemove', 'OnTWChannelPoint', 'OnTWChannelPointCompleted', 'OnTWChannelPointRejected', 'OnTWPoll', 'OnTWPollUpdate', 'OnTWPollEnd', 'OnTWPrediction', 'OnTWPredictionUpdate', 'OnTWPredictionLock', 'OnTWPredictionEnd', 'OnTWHypeTrainStart', 'OnTWHypeTrainConductor', 'OnTWHypeTrainProgress', 'OnTWHypeTrainLevel', 'OnTWHypeTrainEnd', 'OnTWCharityDonation', 'OnTWCharityStarted', 'OnTWCharityProgress', 'OnTWCharityStopped', 'OnTWShieldStart', 'OnTWShieldStop', 'OnTWShoutout', 'OnTWShoutoutReceived', 'OnTWGoalStarted', 'OnTWGoalProgress', 'OnTWGoalCompleted', 'OnTWGoalFailed', 'OnTWStreamStarted', 'OnTWStreamStopped']);
this.rewards = [];
this.rewardsTrigger = {};
this.completedRewards = [];
Expand Down Expand Up @@ -67,7 +67,11 @@ class TwitchHandler extends Handler {
console.error(JSON.stringify(error));
}
}
await connectEventSubWebsocket(this.channelId, clientId, clientSecret, accessToken, refreshToken, this.onEventMessage.bind(this));
try {
await connectEventSubWebsocket(this.channelId, clientId, clientSecret, accessToken, refreshToken, this.onEventMessage.bind(this));
} catch (error) {
console.error(JSON.stringify(error));
}
this.success();
}

Expand Down Expand Up @@ -346,7 +350,7 @@ class TwitchHandler extends Handler {
name: event.user_name,
is_anonymous: event.is_anonymous,
message: event.message,
amount: events.bits
amount: event.bits
});
});
break;
Expand All @@ -357,7 +361,7 @@ class TwitchHandler extends Handler {
id: event.from_broadcaster_user_id,
login: event.from_broadcaster_user_login,
name: event.from_broadcaster_user_name,
raiders: events.viewers
raiders: event.viewers
});
});
break;
Expand Down Expand Up @@ -829,7 +833,7 @@ class TwitchHandler extends Handler {
});
break;
case 'channel.shield_mode.begin':
this.eventSubTrigger['ontwshieldstarted']?.forEach(triggerId => {
this.eventSubTrigger['ontwshieldstart']?.forEach(triggerId => {
controller.handleData(triggerId, {
data: event,
mod: event.moderator_user_name,
Expand All @@ -839,7 +843,7 @@ class TwitchHandler extends Handler {
});
break;
case 'channel.shield_mode.end':
this.eventSubTrigger['ontwshieldstopped']?.forEach(triggerId => {
this.eventSubTrigger['ontwshieldstop']?.forEach(triggerId => {
controller.handleData(triggerId, {
data: event,
mod: event.moderator_user_name,
Expand Down Expand Up @@ -1194,12 +1198,32 @@ class TwitchHandler extends Handler {
}
break;
case 'createclip':
var { delay = "false" } = Parser.getInputs(triggerData, ['action', 'delay' ], false, 1);
var { delay = "false" } = Parser.getInputs(triggerData, ['action', 'delay'], false, 1);
var should_delay = false;
if (delay.toLowerCase() === 'true') {
should_delay = true;
}
await this.api.createClip(this.channelId, should_delay);
var response = await this.api.createClip(this.channelId, should_delay);
return {
data: response,
id: response.data[0].id,
url: `https://clips.twitch.tv/${response.data[0].id}`
};
break;
case 'createreward':
var { name, cost = 1000 } = Parser.getInputs(triggerData, ['action', 'name', 'cost'], false, 1);

var reward_cost = 1000;
if (isNumeric(cost)) {
reward_cost = parseInt(cost);
}

var data = {
"title": name,
"cost": reward_cost,
"is_enabled": false,
}
await this.api.createCustomRewards(this.channelId, data);
break;
case 'deletemessage':
var { message_id } = Parser.getInputs(triggerData, ['action', 'message_id']);
Expand Down
2 changes: 1 addition & 1 deletion js/voicemod/voicemod-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function connectVoicemodWebsocket(address, apiKey) {

websocket.onerror = (err) => {
console.error('Voicemod websocket error');
console.error(err);
console.error(JSON.stringify(err));
};

websocket.onmessage = (e) => {
Expand Down
2 changes: 1 addition & 1 deletion settings/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ To capture Twitch events, you'll need a **Client Id** and **Client Secret**. To
- Login with your Twitch account
- Once logged in, on the left sidebar click `Applications`.
- Click the `+ Register Your Application` button and enter the following details:
- Name: `YOUR_USERNAME Kruiz Control`
- Name: `YOUR_USERNAME Kruiz Control` (Any name works, as long as it is unique)
- OAuth Redirect URLs: `http://localhost`
- Category: `Chat Bot`
- Click the `Create` button at the bottom.
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0.0
v2.0.1

0 comments on commit a7aa90e

Please sign in to comment.