mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-20 02:00:49 +00:00
parent
d4e99bfe10
commit
fd9dbedfdb
3 changed files with 31 additions and 4 deletions
|
@ -109,7 +109,8 @@
|
||||||
"streamer": "Streamer only"
|
"streamer": "Streamer only"
|
||||||
},
|
},
|
||||||
"remove-command-title": "Remove command {{name}}?",
|
"remove-command-title": "Remove command {{name}}?",
|
||||||
"no-commands": "Chatbot has no commands configured"
|
"no-commands": "Chatbot has no commands configured",
|
||||||
|
"command-already-in-use": "Command name already in use"
|
||||||
},
|
},
|
||||||
"bottimers": {
|
"bottimers": {
|
||||||
"title": "Bot timers",
|
"title": "Bot timers",
|
||||||
|
@ -126,7 +127,8 @@
|
||||||
"timer-activity": "Minimul chat activity (0 to disable)",
|
"timer-activity": "Minimul chat activity (0 to disable)",
|
||||||
"timer-activity-desc": "messages in the last 5 minutes",
|
"timer-activity-desc": "messages in the last 5 minutes",
|
||||||
"timer-messages": "Messages",
|
"timer-messages": "Messages",
|
||||||
"no-timers": "There are no timers configured"
|
"no-timers": "There are no timers configured",
|
||||||
|
"name-already-in-use": "Timer name already in use"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"title": "Authentication required",
|
"title": "Authentication required",
|
||||||
|
|
|
@ -189,6 +189,7 @@ function CommandDialog({
|
||||||
item?: TwitchBotCustomCommand;
|
item?: TwitchBotCustomCommand;
|
||||||
onSubmit?: (name: string, item: TwitchBotCustomCommand) => void;
|
onSubmit?: (name: string, item: TwitchBotCustomCommand) => void;
|
||||||
}) {
|
}) {
|
||||||
|
const [commands] = useModule(modules.twitchBotCommands);
|
||||||
const [commandName, setCommandName] = useState(name ?? '');
|
const [commandName, setCommandName] = useState(name ?? '');
|
||||||
const [description, setDescription] = useState(item?.description ?? '');
|
const [description, setDescription] = useState(item?.description ?? '');
|
||||||
const [response, setResponse] = useState(item?.response ?? '');
|
const [response, setResponse] = useState(item?.response ?? '');
|
||||||
|
@ -226,7 +227,17 @@ function CommandDialog({
|
||||||
id="command-name"
|
id="command-name"
|
||||||
value={commandName}
|
value={commandName}
|
||||||
required={true}
|
required={true}
|
||||||
onChange={(e) => setCommandName(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setCommandName(e.target.value);
|
||||||
|
// If command name is different but matches another defined command, set as invalid
|
||||||
|
if (e.target.value !== name && e.target.value in commands) {
|
||||||
|
(e.target as HTMLInputElement).setCustomValidity(
|
||||||
|
t('pages.botcommands.command-already-in-use'),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
(e.target as HTMLInputElement).setCustomValidity('');
|
||||||
|
}
|
||||||
|
}}
|
||||||
placeholder={t('pages.botcommands.command-name-placeholder')}
|
placeholder={t('pages.botcommands.command-name-placeholder')}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
@ -200,6 +200,7 @@ function TimerDialog({
|
||||||
item?: TwitchBotTimer;
|
item?: TwitchBotTimer;
|
||||||
onSubmit?: (name: string, item: TwitchBotTimer) => void;
|
onSubmit?: (name: string, item: TwitchBotTimer) => void;
|
||||||
}) {
|
}) {
|
||||||
|
const [timerConfig] = useModule(modules.twitchBotTimers);
|
||||||
const [timerName, setName] = useState(name ?? '');
|
const [timerName, setName] = useState(name ?? '');
|
||||||
const [messages, setMessages] = useState(item?.messages ?? ['']);
|
const [messages, setMessages] = useState(item?.messages ?? ['']);
|
||||||
const [minDelay, setMinDelay] = useState(item?.minimum_delay ?? 300);
|
const [minDelay, setMinDelay] = useState(item?.minimum_delay ?? 300);
|
||||||
|
@ -234,7 +235,20 @@ function TimerDialog({
|
||||||
<InputBox
|
<InputBox
|
||||||
id="timer-name"
|
id="timer-name"
|
||||||
value={timerName}
|
value={timerName}
|
||||||
onChange={(e) => setName(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setName(e.target.value);
|
||||||
|
// If timer name is different but matches another defined timer, set as invalid
|
||||||
|
if (
|
||||||
|
e.target.value !== name &&
|
||||||
|
e.target.value in timerConfig.timers
|
||||||
|
) {
|
||||||
|
(e.target as HTMLInputElement).setCustomValidity(
|
||||||
|
t('pages.bottimers.name-already-in-use'),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
(e.target as HTMLInputElement).setCustomValidity('');
|
||||||
|
}
|
||||||
|
}}
|
||||||
placeholder={t('pages.bottimers.timer-name-placeholder')}
|
placeholder={t('pages.bottimers.timer-name-placeholder')}
|
||||||
required={true}
|
required={true}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue