Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing #2336 to default quotes to streamer name if no @ is provided #2753

Merged
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
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<{
}
});
}
};
};
Loading