Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Trigger System / Config #560

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ You can now shoutout a specific person by adding a Shoutout Command .. or
With the help of a [very powerful json query library: JSONata](https://jsonata.org) it is now possible to parse trigger payloads (twitch message, raid, etc) and use those as variables for Arguments of Command Blocks.
(insert screenshot here)

## 2023.1.0

### Features

- New Recipe Command Block: Shoutout a twitch user
Example: as Command Block

- Triggers now have inline Recipes (link to recipe example)
Example: screenshot and stuff

- Recipe: Command Block -> Config Arguments can now use variables (from the Triggers)
Example: parse the chat commands 2nd argument to shoutout

- New Recipe Command Block: Call an URL and reuse it in other commands (thanks to variables :tada:)

### Internal

Refactored the Twitch / Timer Triggers to be more generic for easier way to add more types of triggers.

## 2022.1.1

### New Command Block "Random Command Group"
Expand Down
188 changes: 188 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,191 @@
}
}
}
},
"triggers-twitch": {
"projectType": "library",
"root": "projects/triggers-twitch",
"sourceRoot": "projects/triggers-twitch/src",
"prefix": "memebox",
"architect": {
"build": {
"builder": "@nrwl/angular:ng-packagr-lite",
"options": {
"tsConfig": "projects/triggers-twitch/tsconfig.lib.json",
"project": "projects/triggers-twitch/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/triggers-twitch/tsconfig.lib.prod.json"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/triggers-twitch/src/**/*.ts",
"projects/triggers-twitch/src/**/*.html"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/triggers-twitch"],
"options": {
"jestConfig": "projects/triggers-twitch/jest.config.js",
"passWithNoTests": true
}
}
}
},
"triggers-timer": {
"projectType": "library",
"root": "projects/triggers-timer",
"sourceRoot": "projects/triggers-timer/src",
"prefix": "memebox",
"architect": {
"build": {
"builder": "@nrwl/angular:ng-packagr-lite",
"options": {
"tsConfig": "projects/triggers-timer/tsconfig.lib.json",
"project": "projects/triggers-timer/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/triggers-timer/tsconfig.lib.prod.json"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/triggers-timer/src/**/*.ts",
"projects/triggers-timer/src/**/*.html"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/triggers-timer"],
"options": {
"jestConfig": "projects/triggers-timer/jest.config.js",
"passWithNoTests": true
}
}
}
},
"triggers-twitch-contracts": {
"projectType": "library",
"root": "projects/triggers-twitch-contracts",
"sourceRoot": "projects/triggers-twitch-contracts/src",
"prefix": "memebox",
"architect": {
"build": {
"builder": "@nrwl/angular:ng-packagr-lite",
"options": {
"tsConfig": "projects/triggers-twitch-contracts/tsconfig.lib.json",
"project": "projects/triggers-twitch-contracts/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/triggers-twitch-contracts/tsconfig.lib.prod.json"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/triggers-twitch-contracts/src/**/*.ts",
"projects/triggers-twitch-contracts/src/**/*.html"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/triggers-twitch-contracts"],
"options": {
"jestConfig": "projects/triggers-twitch-contracts/jest.config.js",
"passWithNoTests": true
}
}
}
},
"server-common": {
"projectType": "library",
"root": "projects/server-common",
"sourceRoot": "projects/server-common/src",
"prefix": "memebox",
"architect": {
"build": {
"builder": "@nrwl/angular:ng-packagr-lite",
"options": {
"tsConfig": "projects/server-common/tsconfig.lib.json",
"project": "projects/server-common/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/server-common/tsconfig.lib.prod.json"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/server-common/src/**/*.ts",
"projects/server-common/src/**/*.html"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/server-common"],
"options": {
"jestConfig": "projects/server-common/jest.config.js",
"passWithNoTests": true
}
}
}
},
"twitch-api": {
"projectType": "library",
"root": "projects/twitch-api",
"sourceRoot": "projects/twitch-api/src",
"prefix": "memebox",
"architect": {
"build": {
"builder": "@nrwl/angular:ng-packagr-lite",
"options": {
"tsConfig": "projects/twitch-api/tsconfig.lib.json",
"project": "projects/twitch-api/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/twitch-api/tsconfig.lib.prod.json"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/twitch-api/src/**/*.ts",
"projects/twitch-api/src/**/*.html"
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/projects/twitch-api"],
"options": {
"jestConfig": "projects/twitch-api/jest.config.js",
"passWithNoTests": true
}
}
}
}
},
"cli": {
Expand All @@ -630,6 +815,9 @@
"prefix": "app",
"style": "scss",
"skipTests": true
},
"@nrwl/angular:component": {
"style": "scss"
}
}
}
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ module.exports = {
rootDir: __dirname,
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
projects: '<rootDir>/projects/twitch-api'
};
14 changes: 7 additions & 7 deletions projects/app-state/src/lib/state/app.queries.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Injectable } from "@angular/core";
import { Query } from "@datorama/akita";
import { AppState } from "@memebox/contracts";
import { AppStore } from "./app.store";
import {Injectable} from "@angular/core";
import {Query} from "@datorama/akita";
import {AppState} from "@memebox/contracts";
import {AppStore} from "./app.store";
import {RecipeStateQueries} from "@memebox/recipe-core";

@Injectable({
providedIn: "root"
})
export class AppQueries extends Query<AppState> {
export class AppQueries extends Query<AppState> implements RecipeStateQueries {
state$ = this.select().pipe(

);

actionList$ = this.select(store => Object.values(store.clips));
screensList$ = this.select(store => Object.values(store.screen));
twitchEvents$ = this.select(store => Object.values(store.twitchEvents));
timedEvents$ = this.select(store => Object.values(store.timers));
triggers$ = this.select(store => Object.values(store.triggers));
tagList$ = this.select(store => Object.values(store.tags));
queueList$ = this.select(store => {
const allClips = Object.values(store.clips);
Expand Down
27 changes: 19 additions & 8 deletions projects/contracts/src/lib/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Dictionary, ScreenMediaOverridableProperties} from "./types";
import {AllTwitchEvents} from "./twitch.connector.types";
import {AllTwitchEvents} from "../../../triggers-twitch-contracts/src/lib/twitch.connector.types";

// TODO refactor / rename to more understandable names

Expand All @@ -23,13 +23,24 @@ export const ACTIONS = {
}

export enum TriggerActionOrigin {
Unknown,
AppPreview,
StreamDeck, // currently also Unknown
TwitchEvent,
Timer,
Meta, // TODO CHECK META
Scripts
Unknown = 0,
AppPreview = 1,
StreamDeck = 2, // currently also Unknown
/**
* @deprecated
*/
TwitchEvent = 3,
/**
* @deprecated
*/
Timer = 4,
/**
* @deprecated
*/
Meta = 5,
Scripts = 6,
Recipe = 7,
Triggers = 8
}

/**
Expand Down
24 changes: 5 additions & 19 deletions projects/contracts/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {TwitchEventTypes} from './types';

// TODO merge App / Server Endpoint CONSTANTS

export const ENDPOINTS = {
Expand All @@ -10,7 +8,6 @@ export const ENDPOINTS = {
ERROR: 'error',
STATE: 'state',

TIMED_EVENTS: 'timed_events',
NETWORK_LIST: 'network_ip_list',

OPEN: {
Expand All @@ -27,11 +24,12 @@ export const ENDPOINTS = {
CUSTOM_PORT: '/customPort'
},

TWITCH_EVENTS: {
PREFIX: 'twitch_events',

TRIGGER_CONFIGS: {
PREFIX: 'trigger_configs',
TRIGGER_CONFIG_EXAMPLE: '/trigger_config_example',
TRIGGER_EVENT: '/trigger_event',
LAST_20_EVENTS: '/last_events'
TRIGGER_ONE: '/trigger_one',
LAST_20_EVENTS: '/last_triggered'
},

OBS_DATA: {
Expand Down Expand Up @@ -73,18 +71,6 @@ export const ENDPOINTS = {
},
}

export const TwitchTypesArray = [
// TwitchEventTypes.follow,
TwitchEventTypes.bits,
TwitchEventTypes.channelPoints,
// TwitchEventTypes.host,
TwitchEventTypes.message,
TwitchEventTypes.raid,
TwitchEventTypes.ban,
TwitchEventTypes.subscription,
TwitchEventTypes.gift
];

export const WEBSOCKET_PATHS = {
TWITCH_EVENTS: '/ws/twitch_events',
ACTION_ACTIVITY: '/ws/action_activity',
Expand Down
5 changes: 2 additions & 3 deletions projects/contracts/src/lib/createInitialState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SettingsState} from "./types";
import {SettingsState} from "./types.state";

export function createInitialState (): SettingsState {
return {
Expand All @@ -18,10 +18,9 @@ export function createInitialState (): SettingsState {
}
},
},
twitchEvents: {},
triggers: {},
screen: {},
clips: {},
tags: {},
timers: {}
}
}
9 changes: 9 additions & 0 deletions projects/contracts/src/lib/timed-trigger.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {TriggerConfig} from "@memebox/contracts";

export interface TimerTriggerConfig extends TriggerConfig {
type: 'timer.ms';

argumentValues: {
interval: number
};
}
Loading
Loading