const { t } = useTranslation();
- const chat = React.useCallback(async text => {
+ const chat = React.useCallback(async (text, bot_nick) => {
try {
await axios.post(`/api/channels/${channel.id}/chat`, {
text,
+ bot_nick,
});
toastr.success(t('twitchBot.chatSuccess'));
} catch (e) {
}
}, [channel, chatText, t]);
- const join = React.useCallback(async () => {
+ const join = React.useCallback(async (bot_nick) => {
try {
- const rsp = await axios.post(`/api/channels/${channel.id}/join`);
+ const rsp = await axios.post(`/api/channels/${channel.id}/join`, { bot_nick });
setChannel(rsp.data);
toastr.success(t('twitchBot.joinSuccess'));
} catch (e) {
}
}, [channel, t]);
- const part = React.useCallback(async () => {
+ const part = React.useCallback(async (bot_nick) => {
try {
- const rsp = await axios.post(`/api/channels/${channel.id}/part`);
+ const rsp = await axios.post(`/api/channels/${channel.id}/part`, { bot_nick });
setChannel(rsp.data);
toastr.success(t('twitchBot.partSuccess'));
} catch (e) {
value={channel ? channel.id : ''}
/>
</Form.Group>
- {channel ?
- <Form.Group as={Col} md={6}>
- <Form.Label>{t('twitchBot.join')}</Form.Label>
+ {channel ? <>
+ <Form.Group as={Col} md={3}>
+ <Form.Label>{t('twitchBot.joinApp')}</Form.Label>
<div>
<Form.Control
as={ToggleSwitch}
onChange={({ target: { value } }) => {
if (value) {
- join();
+ join('localhorsttv');
} else {
- part();
+ part('localhorsttv');
}
}}
value={channel.join}
/>
</div>
</Form.Group>
- : null}
+ <Form.Group as={Col} md={3}>
+ <Form.Label>{t('twitchBot.joinChat')}</Form.Label>
+ <div>
+ <Form.Control
+ as={ToggleSwitch}
+ onChange={({ target: { value } }) => {
+ if (value) {
+ join('horstiebot');
+ } else {
+ part('horstiebot');
+ }
+ }}
+ value={channel.chat}
+ />
+ </div>
+ </Form.Group>
+ </> : null}
</Row>
{channel ?
<Row>
}}
value={chatText}
/>
- <Button
- className="mt-2"
- disabled={!chatText}
- onClick={() => {
- if (chatText) chat(chatText);
- }}
- variant="twitch"
- >
- {t('button.send')}
- </Button>
+ <div className="button-bar">
+ <Button
+ className="mt-2"
+ disabled={!chatText || !channel.join}
+ onClick={() => {
+ if (chatText) chat(chatText, 'localhorsttv');
+ }}
+ variant="twitch"
+ >
+ {t('twitchBot.sendApp')}
+ </Button>
+ <Button
+ className="mt-2"
+ disabled={!chatText || !channel.chat}
+ onClick={() => {
+ if (chatText) chat(chatText, 'horstiebot');
+ }}
+ variant="twitch"
+ >
+ {t('twitchBot.sendChat')}
+ </Button>
+ </div>
</Form.Group>
</Row>
: