]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/twitch-bot/Controls.js
random chat buttons
[alttp.git] / resources / js / components / twitch-bot / Controls.js
index 3093d90c04dd34e8b4f050367efa4c5c16f219b6..496ff11dd9dae4f977eecb793e25e0f0f2349256 100644 (file)
@@ -12,6 +12,8 @@ import ChannelSelect from '../common/ChannelSelect';
 import Icon from '../common/Icon';
 import ToggleSwitch from '../common/ToggleSwitch';
 
+const CHAT_CATEGORIES = ['unclassified', 'hi', 'gl', 'gg', 'lol', 'pog', 'hype', 'o7'];
+
 const Controls = () => {
        const [channel, setChannel] = React.useState(null);
        const [chatText, setChatText] = React.useState('');
@@ -33,6 +35,18 @@ const Controls = () => {
                }
        }, [channel, chatText, t]);
 
+       const randomChat = React.useCallback(async (category) => {
+               try {
+                       await axios.post(`/api/channels/${channel.id}/chat`, {
+                               bot_nick: 'horstiebot',
+                               category,
+                       });
+                       toastr.success(t('twitchBot.chatSuccess'));
+               } catch (e) {
+                       toastr.error(t('twitchBot.chatError'));
+               }
+       }, [channel, chatText, t]);
+
        const join = React.useCallback(async (bot_nick) => {
                try {
                        const rsp = await axios.post(`/api/channels/${channel.id}/join`, { bot_nick });
@@ -200,6 +214,18 @@ const Controls = () => {
                                                        </Button>
                                                </div>
                                        </Form.Group>
+                                       <h3 className="mt-3">{t('twitchBot.randomChat')}</h3>
+                                       <div className="button-bar">
+                                               {CHAT_CATEGORIES.map(category =>
+                                                       <Button
+                                                               key={category}
+                                                               onClick={() => { randomChat(category); }}
+                                                               variant="outline-secondary"
+                                                       >
+                                                               {t(`twitchBot.chatCategories.${category}`)}
+                                                       </Button>
+                                               )}
+                                       </div>
                                </Col>
                                <Col className="mt-5" md={6}>
                                        <h3>{t('twitchBot.chatSettings')}</h3>