diff --git a/libs/castmate-core/src/accounts/account.ts b/libs/castmate-core/src/accounts/account.ts index c729a088..59441d26 100644 --- a/libs/castmate-core/src/accounts/account.ts +++ b/libs/castmate-core/src/accounts/account.ts @@ -14,7 +14,7 @@ import util, { InspectOptions } from "util" import { AccountConfig, AccountSecrets, AccountState } from "castmate-schema" -interface AccountConstructor extends ResourceConstructor { +export interface AccountConstructor extends ResourceConstructor { new (...args: any[]): any accountDirectory: string storage: ResourceStorage diff --git a/package.json b/package.json index 9212f345..9d987e65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "castmate-monorepo", - "version": "0.5.0", + "version": "0.5.1", "description": "", "private": true, "type": "module", diff --git a/packages/castmate/package.json b/packages/castmate/package.json index 71569a10..c107ef0e 100644 --- a/packages/castmate/package.json +++ b/packages/castmate/package.json @@ -1,6 +1,6 @@ { "name": "castmate", - "version": "0.5.0", + "version": "0.5.1", "description": "CastMate", "author": "LordTocs", "scripts": { diff --git a/plugins/obs/main/src/audio.ts b/plugins/obs/main/src/audio.ts index cf3f8cbc..0675b4a0 100644 --- a/plugins/obs/main/src/audio.ts +++ b/plugins/obs/main/src/audio.ts @@ -43,7 +43,7 @@ export function setupAudio(obsDefault: ReactiveRef) { }, muted: { type: Toggle, - name: "muted", + name: "Muted", required: true, default: true, template: true, @@ -74,6 +74,7 @@ export function setupAudio(obsDefault: ReactiveRef) { defineAction({ id: "changeVolume", name: "Change Volume", + icon: "mdi mdi-volume-high", config: { type: Object, properties: { diff --git a/plugins/obs/main/src/connection.ts b/plugins/obs/main/src/connection.ts index d3896b00..2b2123e8 100644 --- a/plugins/obs/main/src/connection.ts +++ b/plugins/obs/main/src/connection.ts @@ -370,6 +370,7 @@ export class OBSConnection extends FileResource(OBSConnection, "getPreview") ResourceRegistry.getInstance().exposeIPCFunction(OBSConnection, "openProcess") + ResourceRegistry.getInstance().exposeIPCFunction(OBSConnection, "refreshAllBrowsers") ResourceRegistry.getInstance().exposeIPCFunction(OBSConnection, "findBrowserByUrlPattern") ResourceRegistry.getInstance().exposeIPCFunction(OBSConnection, "getRemoteHost") ResourceRegistry.getInstance().exposeIPCFunction(OBSConnection, "createNewSource") @@ -427,6 +428,24 @@ export class OBSConnection extends FileResource { + logger.log("Refreshing", i.inputName) + await this.connection.call("PressInputPropertiesButton", { + inputName: i.inputName as string, + propertyName: "refreshnocache", + }) + }) + ) + } + async refreshBrowsersByUrlPattern(urlPattern: string) { if (!this.state.connected) return undefined diff --git a/plugins/obs/main/src/main.ts b/plugins/obs/main/src/main.ts index 4c1c969b..e52481a6 100644 --- a/plugins/obs/main/src/main.ts +++ b/plugins/obs/main/src/main.ts @@ -23,6 +23,7 @@ import { setupToggles } from "./toggles" import { setupTransforms } from "./transform" import { attemptQRReading, setupAutoConnect } from "./auto-connect" +import { setupAudio } from "./audio" export default definePlugin( { @@ -125,6 +126,7 @@ export default definePlugin( setupScenes(obsDefault) setupSources(obsDefault) setupMedia(obsDefault) + setupAudio(obsDefault) setupToggles(obsDefault) setupTransforms(obsDefault) diff --git a/plugins/obs/renderer/src/components/DashboardObsCard.vue b/plugins/obs/renderer/src/components/DashboardObsCard.vue index d3ec5afb..15e52546 100644 --- a/plugins/obs/renderer/src/components/DashboardObsCard.vue +++ b/plugins/obs/renderer/src/components/DashboardObsCard.vue @@ -1,6 +1,18 @@ @@ -28,10 +35,11 @@ import { OverlayConfig } from "castmate-plugin-overlays-shared" import { computed, onMounted, ref, watch } from "vue" import PButton from "primevue/button" -import { useResource, useResourceIPCCaller, useSettingValue } from "castmate-ui-core" +import { NameDialog, useResource, useResourceIPCCaller, useSettingValue } from "castmate-ui-core" import { ResourceData } from "castmate-schema" import { OBSConnectionConfig, OBSConnectionState } from "castmate-plugin-obs-shared" import { asyncComputed } from "@vueuse/core" +import { useDialog } from "primevue/usedialog" const obs = useResource>("OBSConnection", () => props.obsId) @@ -130,22 +138,43 @@ async function getBrowserSourceSettings() { } } +const dialog = useDialog() + async function createSourceClick(ev: MouseEvent) { if (!obs.value) return - const newSourceName = await createNewSource( - "browser_source", - "CastMate Overlay!", - obs.value.state.scene, - await getBrowserSourceSettings() - ) - sourceName.value = newSourceName + dialog.open(NameDialog, { + props: { + header: "Create Browser Source", + style: { + width: "25vw", + }, + modal: true, + }, + async onClose(options) { + if (!options?.data) { + return + } + + if (!obs.value) return + + await createNewSource( + "browser_source", + options.data, + obs.value.state.scene, + await getBrowserSourceSettings() + ) + setTimeout(findBrowserSource, 200) + }, + }) } async function fixErrorsClick(ev: MouseEvent) { if (!sourceName.value) return await updateSourceSettings(sourceName.value, await getBrowserSourceSettings()) + + await findBrowserSource() } async function openObs() { diff --git a/plugins/twitch/main/src/group.ts b/plugins/twitch/main/src/group.ts index 3928f2b1..bdf85f80 100644 --- a/plugins/twitch/main/src/group.ts +++ b/plugins/twitch/main/src/group.ts @@ -6,6 +6,7 @@ import { defineAction, definePluginResource, onLoad, + usePluginLogger, } from "castmate-core" import { TwitchViewerGroupConfig, @@ -17,6 +18,8 @@ import { nanoid } from "nanoid/non-secure" import { ViewerCache } from "./viewer-cache" import { TwitchAccount } from "./twitch-auth" +const logger = usePluginLogger("twitch") + interface SerializedConfig { name: string userIds: string[] @@ -158,24 +161,29 @@ async function satisfiesRule(userId: string, rule: TwitchViewerGroupRule): Promi } } return false - } else if ("property" in rule) { + } else if ("properties" in rule) { //Todo: Make this not silly hardcoded - if (rule.property === "following") { - return await ViewerCache.getInstance().getIsFollowing(userId) - } else if (rule.property === "subscribed") { - return await ViewerCache.getInstance().getIsSubbed(userId) - } else if (rule.property === "sub-tier-1") { - return (await ViewerCache.getInstance().getSubInfo(userId))?.tier == 1 - } else if (rule.property === "sub-tier-2") { - return (await ViewerCache.getInstance().getSubInfo(userId))?.tier == 2 - } else if (rule.property === "sub-tier-3") { - return (await ViewerCache.getInstance().getSubInfo(userId))?.tier == 3 - } else if (rule.property === "mod") { - return await ViewerCache.getInstance().getIsMod(userId) - } else if (rule.property === "vip") { - return await ViewerCache.getInstance().getIsVIP(userId) - } else if (rule.property === "broadcaster") { - return userId === TwitchAccount.channel.twitchId + if (rule.properties.following) { + if (await ViewerCache.getInstance().getIsFollowing(userId)) return true + } + + if (rule.properties.subTier1) { + if ((await ViewerCache.getInstance().getSubInfo(userId))?.tier == 1) return true + } + if (rule.properties.subTier2) { + if ((await ViewerCache.getInstance().getSubInfo(userId))?.tier == 2) return true + } + if (rule.properties.subTier3) { + if ((await ViewerCache.getInstance().getSubInfo(userId))?.tier == 3) return true + } + if (rule.properties.mod) { + if (await ViewerCache.getInstance().getIsMod(userId)) return true + } + if (rule.properties.vip) { + if (await ViewerCache.getInstance().getIsVIP(userId)) return true + } + if (rule.properties.broadcaster) { + if (userId === TwitchAccount.channel.twitchId) return true } return false } else if ("group" in rule) { @@ -186,6 +194,7 @@ async function satisfiesRule(userId: string, rule: TwitchViewerGroupRule): Promi } else if ("userIds" in rule) { return rule.userIds.includes(userId) } + logger.log("Unknown Group Rule", rule) return false } diff --git a/plugins/twitch/main/src/subscriptions.ts b/plugins/twitch/main/src/subscriptions.ts index 36bccec3..2298b0eb 100644 --- a/plugins/twitch/main/src/subscriptions.ts +++ b/plugins/twitch/main/src/subscriptions.ts @@ -1,7 +1,7 @@ import { ApiClient } from "@twurple/api" import { EventSubWsListener } from "@twurple/eventsub-ws" import { TwitchAccount } from "./twitch-auth" -import { defineState, defineTrigger } from "castmate-core" +import { defineState, defineTrigger, usePluginLogger } from "castmate-core" import { Range } from "castmate-schema" import { TwitchAPIService, onChannelAuth } from "./api-harness" import { ViewerCache } from "./viewer-cache" @@ -9,6 +9,8 @@ import { TwitchViewer, TwitchViewerGroup } from "castmate-plugin-twitch-shared" import { inTwitchViewerGroup } from "./group" export function setupSubscriptions() { + const logger = usePluginLogger() + const subscription = defineTrigger({ id: "subscription", name: "Subscriber", @@ -123,6 +125,16 @@ export function setupSubscriptions() { }) service.eventsub.onChannelSubscriptionMessage(channel.twitchId, async (event) => { + logger.log( + "Sub Message Received: ", + event.userDisplayName, + event.userId, + event.tier, + event.cumulativeMonths, + event.durationMonths, + event.streakMonths + ) + let tier = 1 if (event.tier == "2000") { tier = 2 diff --git a/plugins/twitch/main/src/twitch-auth.ts b/plugins/twitch/main/src/twitch-auth.ts index b88d6973..fa29981c 100644 --- a/plugins/twitch/main/src/twitch-auth.ts +++ b/plugins/twitch/main/src/twitch-auth.ts @@ -1,5 +1,5 @@ import { TwitchAccountConfig, TwitchAccountSecrets } from "castmate-plugin-twitch-shared" -import { Account, ResourceStorage, usePluginLogger } from "castmate-core" +import { Account, AccountConstructor, ResourceStorage, loadYAML, usePluginLogger } from "castmate-core" import { getTokenInfo, AuthProvider, AccessTokenWithUserId, AccessTokenMaybeWithUserId } from "@twurple/auth" import { BrowserWindow } from "electron" import { ApiClient, UserIdResolvable } from "@twurple/api" @@ -37,6 +37,7 @@ const defaultScopes = [ "moderation:read", "channel:manage:moderators", + "moderator:manage:banned_users", "channel:read:ads", //Get ad schedule "channel:manage:ads", //Snooze ad @@ -299,7 +300,7 @@ export class TwitchAccount extends Account((resolve, reject) => { - const authUrl = this.getAuthURL(scopes, false) + const authUrl = this.getAuthURL(scopes, true) const window = new BrowserWindow({ width: 600, @@ -389,6 +390,16 @@ export class TwitchAccount extends Account { await super.initialize()