]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/twitch-bot/ChatSettingsForm.js
adlib chat
[alttp.git] / resources / js / components / twitch-bot / ChatSettingsForm.js
index 4d36a31601ee3d19e55be0ce8c0e8c8b68a42daa..24b2a0aca5146f39c4f98a8c256dc36a64925f60 100644 (file)
@@ -127,6 +127,52 @@ const ChatSettingsForm = ({
                                        </Form.Control.Feedback>
                                : null}
                        </Form.Group>
+                       <Form.Group as={Col} md={6} controlId="chatSettings.min_age">
+                               <Form.Label>{t('twitchBot.chatMinAge')}</Form.Label>
+                               <Form.Control
+                                       isInvalid={!!(touched.min_age && errors.min_age)}
+                                       name="min_age"
+                                       min="1"
+                                       onBlur={handleBlur}
+                                       onChange={handleChange}
+                                       type="number"
+                                       value={values.min_age || 1}
+                               />
+                       </Form.Group>
+                       <Form.Group as={Col} md={6} controlId="chatSettings.source">
+                               <Form.Label>{t('twitchBot.chatSource')}</Form.Label>
+                               <Form.Select
+                                       isInvalid={!!(touched.source && errors.source)}
+                                       name="source"
+                                       onBlur={handleBlur}
+                                       onChange={handleChange}
+                                       value={values.source || 'any'}
+                               >
+                                       {['any', 'cat', 'chan', 'catchan'].map(value =>
+                                               <option key={value} value={value}>
+                                                       {t(`twitchBot.chatSources.${value}`)}
+                                               </option>
+                                       )}
+                               </Form.Select>
+                               {touched.respond && errors.respond ?
+                                       <Form.Control.Feedback type="invalid">
+                                               {t(errors.respond)}
+                                       </Form.Control.Feedback>
+                               : null}
+                       </Form.Group>
+                       <Form.Group as={Col} md={6} controlId="chatSettings.adlib">
+                               <Form.Label>{t('twitchBot.chatAdlibChance')}</Form.Label>
+                               <Form.Control
+                                       isInvalid={!!(touched.adlib && errors.adlib)}
+                                       name="adlib"
+                                       min="0"
+                                       max="100"
+                                       onBlur={handleBlur}
+                                       onChange={handleChange}
+                                       type="number"
+                                       value={values.adlib || 1}
+                               />
+                       </Form.Group>
                </Row>
                <div className="button-bar mt-3">
                        <Button disabled={!dirty || isSubmitting} type="submit" variant="primary">
@@ -139,8 +185,11 @@ const ChatSettingsForm = ({
 ChatSettingsForm.propTypes = {
        dirty: PropTypes.bool,
        errors: PropTypes.shape({
+               adlib: PropTypes.string,
                language: PropTypes.string,
+               min_age: PropTypes.string,
                respond: PropTypes.string,
+               source: PropTypes.string,
                wait_msgs_max: PropTypes.string,
                wait_msgs_min: PropTypes.string,
                wait_time_min: PropTypes.string,
@@ -151,16 +200,22 @@ ChatSettingsForm.propTypes = {
        handleSubmit: PropTypes.func,
        isSubmitting: PropTypes.bool,
        touched: PropTypes.shape({
+               adlib: PropTypes.bool,
                language: PropTypes.bool,
+               min_age: PropTypes.bool,
                respond: PropTypes.bool,
+               source: PropTypes.bool,
                wait_msgs_max: PropTypes.bool,
                wait_msgs_min: PropTypes.bool,
                wait_time_min: PropTypes.bool,
                wait_time_max: PropTypes.bool,
        }),
        values: PropTypes.shape({
+               adlib: PropTypes.number,
                language: PropTypes.string,
+               min_age: PropTypes.number,
                respond: PropTypes.string,
+               source: PropTypes.string,
                wait_msgs_max: PropTypes.number,
                wait_msgs_min: PropTypes.number,
                wait_time_min: PropTypes.string,
@@ -180,8 +235,11 @@ export default withFormik({
                });
        },
        mapPropsToValues: ({ channel }) => ({
+               adlib: channel.chat_settings.adlib || 50,
                language: channel.chat_settings.language || channel.languages[0] || 'de',
+               min_age: channel.chat_settings.min_age || 1,
                respond: channel.chat_settings.respond || 'yes',
+               source: channel.chat_settings.source || 'any',
                wait_msgs_min: channel.chat_settings.wait_msgs_min || 1,
                wait_msgs_max: channel.chat_settings.wait_msgs_max || 10,
                wait_time_min: channel.chat_settings.wait_time_min
@@ -190,7 +248,9 @@ export default withFormik({
                        ? formatTime({ time: channel.chat_settings.wait_time_max }) : '15:00',
        }),
        validationSchema: yup.object().shape({
+               adlib: yup.number().min(0).max(100),
                language: yup.string(),
+               min_age: yup.number().min(1),
                respond: yup.string(),
                wait_msgs_min: yup.number().min(1),
                wait_msgs_max: yup.number().min(1),