Skip to content

Commit

Permalink
Merge branch 'v5' into theme-background-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxstorm0 committed Sep 17, 2024
2 parents bb16bb1 + 83a8165 commit 4483f16
Show file tree
Hide file tree
Showing 37 changed files with 732 additions and 250 deletions.
29 changes: 23 additions & 6 deletions src/backend/chat/commands/builtin/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const QuotesManagementSystemCommand: SystemCommand<{
quoteDisplayTemplate: string;
quoteDateFormat: string;
useTTS: boolean;
defaultStreamerAttribution: boolean;
}> = {
definition: {
id: "firebot:quotesmanagement",
Expand Down Expand Up @@ -50,6 +51,12 @@ export const QuotesManagementSystemCommand: SystemCommand<{
title: "Read Quotes via TTS",
description: "Have quotes read by TTS whenever one is created or looked up.",
default: false
},
defaultStreamerAttribution: {
type: "boolean",
title: "Attribute new quote to streamer if nobody is explicitly tagged with @",
description: "If @username is not included when adding a quote, it is attributed to the streamer.",
default: false
}
},
subCommands: [
Expand Down Expand Up @@ -270,14 +277,24 @@ export const QuotesManagementSystemCommand: SystemCommand<{

switch (triggeredArg) {
case "add": {
if (args.length < 3) {
await twitchChat.sendChatMessage(`Please provide some quote text!`);
return resolve();
const shouldInsertStreamerUsername = (commandOptions.defaultStreamerAttribution && args.length === 1)
|| (commandOptions.defaultStreamerAttribution && !args[1].includes("@"));
const expectedArgs = shouldInsertStreamerUsername
? 2
: 3;

if (args.length < expectedArgs) {
await twitchChat.sendChatMessage(`Please provide some quote text!`);
return resolve();
}

// Once we've evaluated that the syntax is correct we make our API calls
const channelData = await TwitchApi.channels.getChannelInformation();

const currentGameName = channelData && channelData.gameName ? channelData.gameName : "Unknown game";

// If shouldInsertStreamerUsername and no @ is included in the originator arg, set originator @streamerName and treat the rest as the quote
if (shouldInsertStreamerUsername) {
args.splice(1,0,`@${channelData.displayName}`)
}

const newQuote = {
text: args.slice(2, args.length).join(" "),
Expand Down Expand Up @@ -597,4 +614,4 @@ export const QuotesManagementSystemCommand: SystemCommand<{
}
});
}
};
};
23 changes: 12 additions & 11 deletions src/backend/effects/builtin/clips.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const clip = {
}

webServer.sendToOverlay("playTwitchClip", {
clipSlug: clip.id,
clipVideoUrl: clip.embedUrl,
width: effect.width,
height: effect.height,
duration: clipDuration,
Expand Down Expand Up @@ -277,18 +277,19 @@ const clip = {
rotation
} = event;

const styles = (width ? `width: ${width}px;` : '') +
(height ? `height: ${height}px;` : '') +
(rotation ? `transform: rotate(${rotation});` : '');
// eslint-disable-next-line prefer-template
const styles = `width: ${width || screen.width}px;
height: ${height || screen.height}px;
transform: rotate(${rotation || 0});`;

const videoElement = `
<video autoplay
src="${clipVideoUrl}"
height="${height || ""}"
width="${width || ""}"
style="border: none;${styles}"
onloadstart="this.volume=${volume}"
allowfullscreen="false" />
<iframe style="border: none; ${styles}"
src="${clipVideoUrl}&parent=${window.location.hostname}&autoplay=true"
height="${height || screen.height}"
width="${width || screen.width}"
frameBorder=0
allowfullscreen>
</iframe>
`;

const positionData = {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/effects/builtin/moderator-ban.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const model = {
const user = await twitchApi.users.getUserByName(event.effect.username);

if (user != null) {
const result = await twitchApi.moderation.unban(user.id);
const result = await twitchApi.moderation.unbanUser(user.id);

if (result === true) {
logger.debug(`${event.effect.username} was unbanned via the Ban effect.`);
Expand Down
5 changes: 3 additions & 2 deletions src/backend/effects/builtin/play-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const playVideo = {
</eos-container>
</div>
<eos-container header="Volume" pad-top="true">
<eos-container ng-if="effect.videoType != 'Random Twitch Clip' && effect.videoType != 'Twitch Clip'" header="Volume" pad-top="true">
<div class="volume-slider-wrapper">
<i class="fal fa-volume-down volume-low"></i>
<rzslider rz-slider-model="effect.volume" rz-slider-options="{floor: 0, ceil: 10, hideLimitLabels: true}"></rzslider>
Expand Down Expand Up @@ -486,7 +486,8 @@ const playVideo = {
}
}

const clipVideoUrl = `${clip.thumbnailUrl.split("-preview-")[0]}.mp4`;
//const clipVideoUrl = `${clip.thumbnailUrl.split("-preview-")[0]}.mp4`;
const clipVideoUrl = clip.embedUrl;
const clipDuration = clip.duration;
const volume = parseInt(effect.volume) / 10;

Expand Down
14 changes: 14 additions & 0 deletions src/backend/effects/queues/effect-queue-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ class EffectQueue {

logger.debug(`Added more effects to queue ${this.id}. Current length=${this._queue.length}`);

eventManager.triggerEvent("firebot", "effect-queue-added", {
effectQueueId: this.id
});

this.sendQueueLengthUpdate();

this.processEffectQueue();
Expand Down Expand Up @@ -169,11 +173,21 @@ class EffectQueue {

pauseQueue() {
logger.debug(`Pausing queue ${this.id}...`);

eventManager.triggerEvent("firebot", "effect-queue-status", {
effectQueueId: this.id
});

this._paused = true;
}

resumeQueue() {
logger.debug(`Resuming queue ${this.id}...`);

eventManager.triggerEvent("firebot", "effect-queue-status", {
effectQueueId: this.id
});

this._paused = false;
this.processEffectQueue();
}
Expand Down
8 changes: 7 additions & 1 deletion src/backend/events/EventManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ ipcMain.on("triggerManualEvent", function(_, data) {
return;
}

const meta = event.manualMetadata || {};
const meta = structuredClone(event.manualMetadata || {});
for (const [key, value] of Object.entries(meta)) {
if (typeof value !== 'object' || value == null || Array.isArray(value) || value.type == null || value.value == null) {
continue;
}
meta[key] = value.value;
}
if (meta.username == null) {
const accountAccess = require("../common/account-access");
meta.username = accountAccess.getAccounts().streamer.username;
Expand Down
19 changes: 19 additions & 0 deletions src/backend/events/builtin/firebot-event-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ const firebotEventSource = {
queueName: "Just Chatting"
}
},
{
id: "effect-queue-added",
name: "Effect Queue Added",
description: "When an new entry added to effect queue.",
cached: false,
manualMetadata: {
queueName: "Just Chatting"
}
},
{
id: "effect-queue-status",
name: "Effect Queue Status",
description: "When an effect queue status changes.",
cached: false,
manualMetadata: {
queueName: "Just Chatting",
status: "paused"
}
},
{
id: "before-firebot-closed",
name: "Before Firebot Closed",
Expand Down
Loading

0 comments on commit 4483f16

Please sign in to comment.