From 29880bdc238d7c0e10f7a2f171953ec7734c3fde Mon Sep 17 00:00:00 2001 From: Ash Keel Date: Thu, 4 May 2023 13:10:11 +0200 Subject: [PATCH] feat: Add sending chat command responses as whispers/replies/announcements --- CHANGELOG.md | 4 +++ frontend/src/locale/en/translation.json | 6 +++++ frontend/src/locale/it/translation.json | 8 +++++- frontend/src/store/api/types.ts | 2 ++ frontend/src/ui/pages/BotCommands.tsx | 22 ++++++++++++++++ twitch/client.auth.go | 2 +- twitch/commands.go | 35 ++++++++++++++++++++++++- twitch/data.go | 13 +++++++++ twitch/doc.go | 8 ++++++ 9 files changed, 97 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 368a15a..b8d4a8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [current] +### Added + +- Custom chat commands can now be sent as replies, whispers and announcements. Due to some API shenanigans yet to be solved, the latter two will always be sent from your main account, not the bot account (if they are different) + ## [3.2.0] - 2023-05-03 ### Added diff --git a/frontend/src/locale/en/translation.json b/frontend/src/locale/en/translation.json index 7517bde..1cc574d 100644 --- a/frontend/src/locale/en/translation.json +++ b/frontend/src/locale/en/translation.json @@ -116,6 +116,12 @@ "command-response-placeholder": "Hello {0}!", "command-acl": "Access level", "command-acl-help": "This specifies the minimum level, eg. if you choose VIPs, moderators and streamer can still use the command", + "response-types": { + "chat": "Message", + "reply": "Reply", + "whisper": "Whisper", + "announce": "Announcement" + }, "acl": { "everyone": "Everyone", "subscribers": "Subscribers", diff --git a/frontend/src/locale/it/translation.json b/frontend/src/locale/it/translation.json index 21651b4..dd77254 100644 --- a/frontend/src/locale/it/translation.json +++ b/frontend/src/locale/it/translation.json @@ -112,7 +112,13 @@ "subscribers": "Abbonati", "vip": "VIP" }, - "command-already-in-use": "Nome comando già in uso" + "command-already-in-use": "Nome comando già in uso", + "response-types": { + "announce": "Annuncio", + "chat": "Canale", + "reply": "Risposta", + "whisper": "Chat privata" + } }, "bottimers": { "add-button": "Nuovo timer", diff --git a/frontend/src/store/api/types.ts b/frontend/src/store/api/types.ts index d213b2f..cc7cf41 100644 --- a/frontend/src/store/api/types.ts +++ b/frontend/src/store/api/types.ts @@ -34,10 +34,12 @@ export const accessLevels = [ export type AccessLevelType = (typeof accessLevels)[number]; +export type ReplyType = 'chat' | 'reply' | 'whisper' | 'announce'; export interface TwitchBotCustomCommand { description: string; access_level: AccessLevelType; response: string; + response_type: ReplyType; enabled: boolean; } diff --git a/frontend/src/ui/pages/BotCommands.tsx b/frontend/src/ui/pages/BotCommands.tsx index 2573313..22a86b6 100644 --- a/frontend/src/ui/pages/BotCommands.tsx +++ b/frontend/src/ui/pages/BotCommands.tsx @@ -7,6 +7,7 @@ import { modules } from '~/store/api/reducer'; import { accessLevels, AccessLevelType, + ReplyType, TwitchBotCustomCommand, } from '~/store/api/types'; import AlertContent from '../components/AlertContent'; @@ -23,6 +24,8 @@ import { InputBox, Label, MultiButton, + MultiToggle, + MultiToggleItem, NoneText, PageContainer, PageHeader, @@ -185,11 +188,15 @@ function CommandDialog({ const [commands] = useModule(modules.twitchBotCommands); const [commandName, setCommandName] = useState(name ?? ''); const [description, setDescription] = useState(item?.description ?? ''); + const [responseType, setResponseType] = useState( + item?.response_type ?? 'chat', + ); const [response, setResponse] = useState(item?.response ?? ''); const [accessLevel, setAccessLevel] = useState( item?.access_level ?? 'everyone', ); const { t } = useTranslation(); + const replyTypes: ReplyType[] = ['chat', 'reply', 'whisper', 'announce']; return (