-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is ideally suitable for Text-To-Speech messages and the like. It will filter out any URLs, and any emotes, so only the text from the chat message remains. I also have no clue how to properly get a firebot development environment setup (darn you font awesome, what am I doing wrong?), but it seems to be fully functional on twitch with every scenariou I could throw at it.
- Loading branch information
1 parent
e792184
commit 4a22639
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/backend/variables/builtin/twitch/chat/message/chat-message-text-only.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ReplaceVariable } from "../../../../../../types/variables"; | ||
import { EffectTrigger } from "../../../../../../shared/effect-constants"; | ||
import { OutputDataType, VariableCategory } from "../../../../../../shared/variable-constants"; | ||
|
||
const triggers = {}; | ||
triggers[EffectTrigger.MANUAL] = true; | ||
triggers[EffectTrigger.COMMAND] = true; | ||
triggers[EffectTrigger.EVENT] = [ | ||
"twitch:chat-message", | ||
"twitch:first-time-chat", | ||
"firebot:highlight-message", | ||
"twitch:viewer-arrived" | ||
]; | ||
|
||
const model: ReplaceVariable = { | ||
definition: { | ||
handle: "chatMessageTextOnly", | ||
description: "Outputs the chat message from the associated command or event, with any emotes or URLs trimmed out", | ||
triggers: triggers, | ||
categories: [VariableCategory.COMMON, VariableCategory.TRIGGER], | ||
possibleDataOutput: [OutputDataType.TEXT] | ||
}, | ||
evaluator: (trigger) => { | ||
let messageParts = []; | ||
if (trigger.type === EffectTrigger.COMMAND) { | ||
messageParts = trigger.metadata.chatMessage.parts; | ||
} else if (trigger.type === EffectTrigger.EVENT) { | ||
messageParts = trigger.metadata.eventData.chatMessage.parts; | ||
} | ||
|
||
const textParts = messageParts.filter(p => p.type === "text").map(p => p.text); | ||
return textParts.join(" ").trim(); | ||
} | ||
}; | ||
|
||
export default model; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters