Skip to content
Merged
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
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firebotv5",
"version": "5.66.0",
"version": "5.66.1",
"description": "Powerful all-in-one bot for Twitch streamers.",
"main": "build/main.js",
"scripts": {
Expand Down Expand Up @@ -91,7 +91,7 @@
"escape-html": "^1.0.3",
"eventsource": "^1.0.7",
"express": "^5.1.0",
"expressionish": "github:SReject/expressionish#27f38753346b60c5a09d69ebe407bf70583eec2d",
"expressionish": "github:SReject/expressionish#2e798f91c640384b0bf0b2b4bfa589d5e7ad2a51",
"extra-life-ts": "^0.4.0",
"firebot-nutjs": "github:crowbartools/firebot-nutjs#f52581d4c4426cf7f4dcc2b0d26cf56777e115f8",
"form-data": "^4.0.5",
Expand Down
18 changes: 10 additions & 8 deletions src/backend/chat/frontend-chat-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FirebotFrontendChatHelpers {
chatMessage: FirebotChatMessage
): void {
if (chatWidget.settings.delayMessages === true) {
if (this._pendingMessageCache[chatWidget.id].some(m => m === chatMessage.id)) {
if ((this._pendingMessageCache[chatWidget.id] ?? []).some(m => m === chatMessage.id)) {
// Remove it from the pending list so we know we've taken care of it
this._pendingMessageCache[chatWidget.id] = this._pendingMessageCache[chatWidget.id]
.filter(m => m !== chatMessage.id);
Expand Down Expand Up @@ -85,16 +85,18 @@ class FirebotFrontendChatHelpers {
const advancedChatWidgets = overlayWidgetConfigManager.getConfigsOfType<OverlayWidgetConfig<AdvancedChatWidgetSettings, ChatWidgetState>>("firebot:chat-advanced");

for (const chatWidget of [...chatWidgets, ...advancedChatWidgets]) {
if (chatWidget.settings.delayMessages === true && chatWidget.settings.messageDelay) {
this._pendingMessageCache[chatWidget.id] ??= [];
if (!!chatWidget.active) {
if (chatWidget.settings.delayMessages === true && chatWidget.settings.messageDelay) {
this._pendingMessageCache[chatWidget.id] ??= [];

this._pendingMessageCache[chatWidget.id].push(chatMessage.id);
this._pendingMessageCache[chatWidget.id].push(chatMessage.id);

setTimeout(() => {
setTimeout(() => {
this.sendChatMessageToChatWidget(chatWidget, chatMessage);
}, chatWidget.settings.messageDelay * 1000);
} else {
this.sendChatMessageToChatWidget(chatWidget, chatMessage);
}, chatWidget.settings.messageDelay * 1000);
} else {
this.sendChatMessageToChatWidget(chatWidget, chatMessage);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/crowbar-relay/crowbar-relay-websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CrowbarRelayWebSocket extends TypedEmitter<{
});

this.ws.addEventListener("error", (err) => {
logger.error("Crowbar Relay WebSocket errored", err);
logger.error("Crowbar Relay WebSocket errored", err.message);
});

this.ws.addEventListener("close", (closedEvent) => {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/effects/builtin/clips.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ const clip = {

videoElement = `
<iframe style="border: none; ${styles}"
src="${clipVideoUrl}&parent=${window.location.hostname}&autoplay=true"
src="${clipVideoUrl}&parent=${window.location.hostname}&autoplay=true&muted=false"
height="${height || screen.height}"
width="${width || screen.width}"
frameBorder=0
Expand Down
10 changes: 9 additions & 1 deletion src/backend/effects/builtin/overlay-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ const effect: EffectType<OverlayAlertEffect> = {
placeholder-text="Enter alert text"
use-text-area="true"
/>
<div class="muted">
If you would like to add HTML from a variable, you must wrap it inside of <code>$allowHtml</code> (e.g. <code>$allowHtml[$someOtherVariable]</code>).<br />
<strong>WARNING:</strong> Be very careful doing this with untrusted or potentially harmful data, like chat messages.
</div>
<div class="mt-3">
<font-options ng-model="effect.font" allow-alpha="true"></font-options>
</div>
Expand Down Expand Up @@ -671,7 +675,11 @@ const effect: EffectType<OverlayAlertEffect> = {
...event.trigger,
effectOutputs: event.outputs
},
(token: string) => escapeHTML(token)
(text, token) => {
if (token.value !== "allowHtml") {
return escapeHTML(text);
}
}
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/backend/events/filters/builtin/twitch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import sharedChat from "./shared-chat";
import sharedTrain from "./shared-train";
import streamCategory from "./stream-category";
import subKind from "./sub-kind";
import subMonths from "./sub-months";
import subType from "./sub-type";
import treasureTrain from "./treasure-train";
import username from "./username";
Expand All @@ -43,6 +44,7 @@ export default [
sharedTrain,
streamCategory,
subKind,
subMonths,
subType,
treasureTrain,
username
Expand Down
13 changes: 13 additions & 0 deletions src/backend/events/filters/builtin/twitch/sub-months.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createNumberFilter } from "../../filter-factory";

const filter = createNumberFilter({
id: "firebot:sub-months",
name: "Months Subbed",
description: "Filter by the total number of months the user has been subscribed",
eventMetaKey: "totalMonths",
events: [
{ eventSourceId: "twitch", eventId: "sub" }
]
});

export default filter;
10 changes: 6 additions & 4 deletions src/backend/logwrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ class FrontendTransport extends Transport {
log(info :TransformableInfo, callback: () => void) {
setImmediate(() => this.emit("logged", info));

frontendCommunicator.send("logging", {
message: info[Symbol.for("message")],
meta: info[Symbol.for("splat")]
});
try {
frontendCommunicator.send("logging", {
message: info[Symbol.for("message")],
meta: info[Symbol.for("splat")]
});
} catch { }

if (callback) {
callback();
Expand Down
15 changes: 15 additions & 0 deletions src/backend/variables/builtin/utility/allow-html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { ReplaceVariable } from "../../../../types/variables";

const allowHtmlVariable: ReplaceVariable = {
definition: {
handle: "allowHtml",
usage: "allowHtml[$otherVariable]",
description: "Allows HTML to be used in places where it's usually not allowed",
categories: ["advanced"],
possibleDataOutput: ["text"],
hidden: true
},
evaluator: (trigger, arg: string) => arg
};

export default allowHtmlVariable;
2 changes: 2 additions & 0 deletions src/backend/variables/builtin/utility/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import allowHtml from './allow-html';
import apiRead from './api-read';
import apiReadRaw from './api-read-raw';
import audioDuration from './audio-duration';
Expand All @@ -20,6 +21,7 @@ import runEffect from './run-effect';
import videoDuration from './video-duration';

export default [
allowHtml,
apiRead,
apiReadRaw,
audioDuration,
Expand Down
15 changes: 8 additions & 7 deletions src/backend/variables/replace-variable-manager.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import EventEmitter from "events";
import expressionish, * as expressionishErrs from "expressionish";
import type {
ReplaceVariable,
Awaitable,
ExpressionishToken,
RegisteredVariable,
VariableUsage,
ReplaceVariable,
Trigger,
TriggerMeta,
TriggerType,
Trigger
} from "../../types/variables";
import type { Awaitable } from "../../types/util-types";
VariableUsage
} from "../../types";
import { SettingsManager } from "../common/settings-manager";
import macroManager from "./macro-manager";
import { CustomVariableManager } from "../common/custom-variable-manager";
Expand Down Expand Up @@ -226,7 +227,7 @@ class ReplaceVariableManager extends EventEmitter {
async populateStringWithTriggerData(
string = "",
trigger: Trigger,
postProcessVariable: (value: string) => string = undefined
postProcessVariable: (value: string, token: ExpressionishToken) => string = undefined
) {
if (trigger == null || string === "") {
return string;
Expand All @@ -242,7 +243,7 @@ class ReplaceVariableManager extends EventEmitter {
metadata: Record<string, unknown>,
trigger: TriggerWithId,
onlyValidate = false,
postProcessVariable: (value: string) => string = undefined
postProcessVariable: (value: string, token: ExpressionishToken) => string = undefined
): Promise<string> {
if (input.toString().includes("$")) {
// eslint-disable-next-line
Expand Down
74 changes: 74 additions & 0 deletions src/types/expressionish.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
type ExpressionishBaseToken = {
type: "TEXT" | "VARIABLE" | "LOOKUP" | "IF" | "LOGICAL" | "CONDITION" | "UNKNOWN";

/**
* Rough character position of the token within the input string
*/
position: number;

/**
* Depends on token type.
*
* `TEXT` or `UNKNOWN`: raw text value
*
* `VAR`, `IF`, or `LOOKUP`: name of variable
*
* `CONDITION` or `LOGICAL`: operator
*/
value: string;

};

type ExpressionishTokenWithArguments = {
/**
* Arguments to resolve then pass to calling registered handler
*/
arguments: Array<ExpressionishToken>;
};

type ExpressionishTextToken = ExpressionishBaseToken & {
type: "TEXT";
};

type ExpressionishLookupToken = ExpressionishBaseToken & ExpressionishTokenWithArguments & {
type: "LOOKUP";

/**
* Lookup prefix
*/
prefix: string;
};

type ExpressionishVariableToken = ExpressionishBaseToken & ExpressionishTokenWithArguments & {
type: "VARIABLE";
};

type ExpressionishComparisonToken = ExpressionishBaseToken & ExpressionishTokenWithArguments & {
type: "CONDITION";
};

type ExpressionishLogicToken = ExpressionishBaseToken & ExpressionishTokenWithArguments & {
type: "LOGICAL";
};

type ExpressionishIfToken = ExpressionishBaseToken & ExpressionishTokenWithArguments & {
type: "IF";

/**
* Condition used for evaluation
*/
condition: ExpressionishLogicToken | ExpressionishComparisonToken;
};

type ExpressionishUnknownToken = ExpressionishBaseToken & {
type: "UNKNOWN";
};

export type ExpressionishToken =
| ExpressionishTextToken
| ExpressionishLookupToken
| ExpressionishVariableToken
| ExpressionishComparisonToken
| ExpressionishLogicToken
| ExpressionishIfToken
| ExpressionishUnknownToken;
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from "./currency";
export * from "./discord";
export * from "./effects";
export * from "./events";
export * from "./expressionish";
export * from "./games";
export * from "./goals";
export * from "./hotkeys";
Expand Down