Skip to content

Commit

Permalink
Merge pull request #2235 from crowbartools/v5
Browse files Browse the repository at this point in the history
  • Loading branch information
ebiggz committed Sep 17, 2023
2 parents b00b978 + f993dad commit 18eab87
Show file tree
Hide file tree
Showing 72 changed files with 1,927 additions and 611 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/compile-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ jobs:
npm config set msvs_version 2022
npm install --global --production --omit=dev [email protected]
- name: Linux Build Prep
if: runner.os == 'linux'
run: sudo apt-get install libx11-dev libxtst-dev libpng-dev

- name: Restore Robotjs from cache
id: robotjs-cache
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-robotjs
path: ./node_modules/robotjs/

- name: Linux Build Prep
if: runner.os == 'linux'
run: sudo apt-get install libx11-dev libxtst-dev libpng-dev

- name: Install Global Dependencies
run: npm install --global --production --omit=dev grunt-cli node-gyp

Expand Down Expand Up @@ -140,9 +140,6 @@ jobs:
with:
path: ./bundles/

- name: Rename Artifacts
run: mv ./bundles/Windows/firebot-${{ needs.checkversion.outputs.version }}-full.nupkg ./bundles/Windows/firebot-v${{ needs.checkversion.outputs.version }}-full.nupkg

- name: Create Release
uses: softprops/action-gh-release@v1
env:
Expand Down
166 changes: 83 additions & 83 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firebotv5",
"version": "5.57.0",
"version": "5.58.0",
"description": "Powerful all-in-one bot for Twitch streamers.",
"main": "build/main.js",
"scripts": {
Expand Down Expand Up @@ -49,10 +49,10 @@
"dependencies": {
"@aws-sdk/client-polly": "^3.26.0",
"@crowbartools/firebot-custom-scripts-types": "^5.53.2-6",
"@twurple/api": "^6.0.6",
"@twurple/auth": "^6.0.6",
"@twurple/chat": "^6.0.6",
"@twurple/pubsub": "^6.0.6",
"@twurple/api": "^6.0.9",
"@twurple/auth": "^6.0.9",
"@twurple/chat": "^6.0.9",
"@twurple/pubsub": "^6.0.9",
"@zunderscore/elgato-light-control": "^1.1.2",
"angular": "^1.8.0",
"angular-animate": "^1.7.8",
Expand Down
4 changes: 4 additions & 0 deletions src/backend/chat/commands/builtin/steam/steam-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ const getSteamGameDetails = async (requestedGame) => {
gameDetails.releaseDate = foundGame.release_date.date;
}

if (foundGame.short_description) {
gameDetails.shortDescription = foundGame.short_description;
}

return gameDetails;
};

Expand Down
5 changes: 3 additions & 2 deletions src/backend/chat/commands/builtin/steam/steam.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const steam = {
outputTemplate: {
type: "string",
title: "Output Template",
tip: "Variables: {gameName}, {price}, {releaseDate}, {metaCriticScore}, {steamUrl}",
tip: "Variables: {gameName}, {price}, {releaseDate}, {metaCriticScore}, {steamUrl}, {steamShortDescription}",
default: `{gameName} (Price: {price} - Released: {releaseDate} - Metacritic: {metaCriticScore}) {steamUrl}`,
useTextArea: true
}
Expand All @@ -49,7 +49,8 @@ const steam = {
.replace("{price}", gameDetails.price || "Unknown")
.replace("{releaseDate}", gameDetails.releaseDate || "Unknown")
.replace("{metaCriticScore}", gameDetails.score || "Unknown")
.replace("{steamUrl}", gameDetails.url);
.replace("{steamUrl}", gameDetails.url)
.replace("{steamShortDescription}", gameDetails.shortDescription || "Unknown");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function buildModules(scriptManifest) {
twitchApi: twitchApi,
httpServer: require("../../../../server/http-server-manager"),
effectManager: require("../../../effects/effectManager"),
effectRunner: require("../../effect-runner"),
conditionManager: require("../../../effects/builtin/conditional-effects/conditions/condition-manager"),
restrictionManager: require("../../../restrictions/restriction-manager"),
commandManager: require("../../../chat/commands/CommandManager"),
Expand All @@ -115,7 +116,8 @@ function buildModules(scriptManifest) {
quotesManager: require("../../../quotes/quotes-manager"),
frontendCommunicator: require("../../frontend-communicator"),
counterManager: require("../../../counters/counter-manager"),
utils: require("../../../utility")
utils: require("../../../utility"),
resourceTokenManager: require("../../../resourceTokenManager")
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/backend/common/handlers/fileWriterProcessor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const fs = require("fs-extra");
const path = require("path");
const logger = require("../../logwrapper");

function doesTextExistInFile(filepath, text) {
Expand Down Expand Up @@ -75,6 +76,7 @@ exports.run = async effect => {
fs.appendFileSync(effect.filepath, text + "\n", "utf8");
}
} else {
fs.ensureDirSync(path.dirname(effect.filepath));
fs.appendFileSync(effect.filepath, text + "\n", "utf8");
}
} else if (effect.writeMode === "delete") {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/common/user-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function userFollowsChannels(username, channelNames) {
if (cachedFollow !== undefined) {
userFollowsChannel = cachedFollow;
} else {
userFollowsChannel = await twitchApi.users.doesUserFollowChannelLegacy(username, channelName);
userFollowsChannel = await twitchApi.users.doesUserFollowChannel(username, channelName);

// set cache value
followCache.set(`${username}:${channelName}`, userFollowsChannel);
Expand Down
12 changes: 12 additions & 0 deletions src/backend/effects/builtin/control-emulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ const effect = {
"f10",
"f11",
"f12",
"f13",
"f14",
"f15",
"f16",
"f17",
"f18",
"f19",
"f20",
"f21",
"f22",
"f23",
"f24",
"alt",
"control",
"shift",
Expand Down
4 changes: 2 additions & 2 deletions src/backend/effects/builtin/cooldown-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const model = {
commandId: id,
subcommandId: effect.subcommandId,
username: effect.username,
cooldowns: {
cooldown: {
global: !isNaN(effect.globalCooldownSecs) ? parseInt(effect.globalCooldownSecs) : undefined,
user: !isNaN(effect.userCooldownSecs) && effect.username != null && effect.username !== '' ? parseInt(effect.userCooldownSecs) : undefined
}
Expand All @@ -219,7 +219,7 @@ const model = {
commandId: id,
subcommandId: effect.subcommandId,
username: effect.clearUsername,
cooldowns: {
cooldown: {
global: effect.clearGlobalCooldown,
user: effect.clearUserCooldown
}
Expand Down
4 changes: 2 additions & 2 deletions src/backend/effects/builtin/loop-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ const model = {

$scope.loopModeChanged = () => {
if ($scope.effect.loopMode === "count") {
$scope.effect.loopCount = 5;
$scope.effect.loopCount = "5";
} else if ($scope.effect.loopMode === "conditional") {
$scope.effect.loopCount = 25;
$scope.effect.loopCount = "25";
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/backend/effects/builtin/pause-resume-effect-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ const model: EffectType<{
return false;
} else {
if (effect.action === "Pause") {
effectQueueRunner.pauseQueue(effect.effectQueue);
effectQueueManager.pauseQueue(effect.effectQueue);
} else if (effect.action === "Resume") {
effectQueueRunner.resumeQueue(effect.effectQueue);
effectQueueManager.resumeQueue(effect.effectQueue);
} else {
effectQueueRunner.toggleQueue(effect.effectQueue);
effectQueueManager.toggleQueue(effect.effectQueue);
}
}

Expand Down
109 changes: 33 additions & 76 deletions src/backend/effects/builtin/play-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const accountAccess = require("../../common/account-access");
const util = require("../../utility");
const fs = require('fs-extra');
const path = require("path");
const frontendCommunicator = require('../../common/frontend-communicator');
const { wait } = require("../../utility");
const { parseYoutubeId } = require("../../../shared/youtube-url-parser");

/**
* The Play Video effect
Expand Down Expand Up @@ -366,7 +369,7 @@ const playVideo = {
/**@type {import('@twurple/api').HelixClip} */
let clip;
if (effect.videoType === "Twitch Clip") {
clipId = effect.twitchClipUrl.replace("https://clips.twitch.tv/", "");
clipId = effect.twitchClipUrl.split("/").pop();
try {
clip = await client.clips.getClipById(clipId);
} catch (error) {
Expand Down Expand Up @@ -439,54 +442,40 @@ const playVideo = {
}

let resourceToken;
if (effect.videoType === "YouTube Video") {
resourceToken = resourceTokenManager.storeResourcePath(data.filepath, effect.length);
} else {
const durationToken = resourceTokenManager.storeResourcePath(data.filepath, 5);

const durationPromise = new Promise(async (resolve, reject) => {
const listener = (event) => {
try {
if (event.name === "video-duration" && event.data.resourceToken === durationToken) {
webServer.removeListener("overlay-event", listener);
resolve(event.data.duration);
}
} catch (err) {
logger.error("Error while trying to process overlay-event for getVideoDuration: ", err);
reject(err);
}
};
webServer.on("overlay-event", listener);
});

webServer.sendToOverlay("getVideoDuration", {
resourceToken: durationToken,
overlayInstance: data.overlayInstance
});

const duration = await durationPromise;
resourceToken = resourceTokenManager.storeResourcePath(data.filepath, duration + 5);
logger.info(`Retrieved duration for video: ${duration}`);
let duration;
if (effect.videoType === "YouTube Video" && !effect.wait) {
logger.debug("Play Video Effect: Proceeding without Youtube Video Duration because wait is false");
} else if (effect.videoType === "YouTube Video" && effect.wait) {
const youtubeData = parseYoutubeId(data.youtubeId);
data.youtubeId = youtubeData.id;
const result = await frontendCommunicator.fireEventAsync("getYoutubeVideoDuration", data.youtubeId);
if (!isNaN(result)) {
duration = result;
} else {
// Error
logger.error("Play Video Effect: Unable to retrieve Youtube Video Duration", result);
return;
}
if (data.videoStarttime == null || data.videoStarttime == "" || data.videoStarttime == 0) {
data.videoStarttime = youtubeData.startTime;
}
} else if (effect.videoType === "Local Video") {
const result = await frontendCommunicator.fireEventAsync("getVideoDuration", data.filepath);
if (!isNaN(result)) {
duration = result;
}
resourceToken = resourceTokenManager.storeResourcePath(data.filepath, duration);
}

data.resourceToken = resourceToken;

webServer.sendToOverlay("video", data);
if (effect.wait) {
await new Promise(async (resolve, reject) => {
const listener = (event) => {
try {
if (event.name === "video-end" && event.data.resourceToken === resourceToken) {
webServer.removeListener("overlay-event", listener);
resolve();
}
} catch (err) {
logger.error("Error while trying to process overlay-event for play-video: ", err);
reject(err);
}
};
webServer.on("overlay-event", listener);
});
let internalDuration = data.videoDuration;
if (internalDuration == null || internalDuration === 0 || internalDuration === "") {
internalDuration = duration;
}
await wait(internalDuration * 1000);
}
return true;
},
Expand Down Expand Up @@ -544,7 +533,7 @@ const playVideo = {
const data = event;

const videoType = data.videoType;
const filepath = data.filepath;
const filepath = data.filepath ?? "";
let fileExt = filepath.split(".").pop();
if (fileExt === "ogv") {
fileExt = "ogg";
Expand Down Expand Up @@ -637,9 +626,6 @@ const playVideo = {
const exitVideo = () => {
delete startedVidCache[this.id]; // eslint-disable-line no-undef
animateVideoExit(`#${wrapperId}`, exitAnimation, exitDuration, inbetweenAnimation);
setTimeout(function(){
sendWebsocketEvent("video-end", {resourceToken: token}); // eslint-disable-line no-undef
}, millisecondsFromString(exitDuration));
};

// Remove div after X time.
Expand Down Expand Up @@ -669,29 +655,6 @@ const playVideo = {

$(".wrapper").append(wrappedHtml);

try {
const url = new URL(youtubeId);
if (url.hostname.includes("www.youtube.com")) {
for (const [key, value] of url.searchParams) {
if (key === "v") {
youtubeId = value;
} else if (key === "t") {
videoStarttime = value;
}
}
}
if (url.hostname.includes("youtu.be")) {
youtubeId = url.pathname.replace("/", "");
for (const [key, value] of url.searchParams) {
if (key === "t") {
videoStarttime = value;
}
}
}
} catch (error) {
//failed to convert url
}

// Add iframe.

const playerVars = {
Expand Down Expand Up @@ -737,9 +700,6 @@ const playVideo = {
onStateChange: (event) => {
if (event.data === 0 && !videoDuration) {
animateVideoExit(`#${wrapperId}`, exitAnimation, exitDuration, inbetweenAnimation);
setTimeout(function(){
sendWebsocketEvent("video-end", {resourceToken: token}); // eslint-disable-line no-undef
}, millisecondsFromString(exitDuration));
}
}
}
Expand All @@ -757,9 +717,6 @@ const playVideo = {
if (videoDuration) {
setTimeout(function () {
animateVideoExit(`#${wrapperId}`, exitAnimation, exitDuration, inbetweenAnimation);
setTimeout(function(){
sendWebsocketEvent("video-end", {resourceToken: token}); // eslint-disable-line no-undef
}, millisecondsFromString(exitDuration));
}, videoDuration);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/backend/effects/builtin/stream-game.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { EffectCategory } = require('../../../shared/effect-constants');
const logger = require('../../logwrapper');
const twitchApi = require("../../twitch-api/api");
const eventsManager = require("../../events/EventManager");

const model = {
definition: {
Expand Down Expand Up @@ -104,6 +105,9 @@ const model = {
await twitchApi.channels.updateChannelInformation({ gameId: category.id });
}
}

const category = (await twitchApi.channels.getChannelInformation()).gameName;
eventsManager.triggerEvent("firebot", "category-changed", {category: category});
return true;
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/backend/effects/builtin/take-screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const clip = {
<eos-overlay-instance effect="effect" class="setting-padtop"></eos-overlay-instance>
</div>
<eos-container pad-top="true">
<eos-container pad-top="true">
<div class="effect-info alert alert-info">
Note: Screenshots will capture the entirety of the selected display.
</div>
Expand Down Expand Up @@ -204,7 +204,7 @@ const clip = {
description: "Screenshot by Firebot"
}];
const screenshotEmbed = await discordEmbedBuilder.buildScreenshotEmbed(`attachment://${filename}`);
discord.sendDiscordMessage(effect.discordChannelId, "A new screenshot was taken!", screenshotEmbed, files);
await discord.sendDiscordMessage(effect.discordChannelId, "A new screenshot was taken!", screenshotEmbed, files);
}

if (effect.showInOverlay) {
Expand Down
Loading

0 comments on commit 18eab87

Please sign in to comment.