1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-20 02:00:49 +00:00

Remove toggle for chat keys

This commit is contained in:
Ash Keel 2022-01-21 10:08:51 +01:00
parent c9cc780bdc
commit b078f6d8c0
No known key found for this signature in database
GPG key ID: BAD8D93E7314ED3E
5 changed files with 33 additions and 76 deletions

View file

@ -95,10 +95,7 @@
"bot-info-header": "Bot account info",
"bot-settings-copy": "A bot can interact with chat messages and provide extra events for the platform (chat events, some notifications) but requires access to a Twitch account. You can use your own or make a new one (if enabled on your main account, you can re-use the same email for your second account!)",
"bot-chat-header": "Chat logging",
"bot-chat-keys": "Enable chat logging",
"bot-chat-history": "How many messages to keep in history",
"bot-chat-history-suffix": "messages",
"bot-chat-history-desc": "Chat logging allows for pages and modules to read messages from chat. It's recommended to keep chat logging enabled with a reasonable history size (eg. 6)"
"bot-chat-history": "How many messages to keep in history (0 to disable)"
},
"botcommands": {
"title": "Bot commands",

View file

@ -21,7 +21,6 @@ interface TwitchBotConfig {
username: string;
oauth: string;
channel: string;
chat_keys: boolean;
chat_history: number;
}

View file

@ -157,54 +157,16 @@ function TwitchBotSettings() {
<SectionHeader>
{t('pages.twitch-settings.bot-chat-header')}
</SectionHeader>
<TextBlock>{t('pages.twitch-settings.bot-chat-history-desc')}</TextBlock>
<Field>
<FlexRow spacing={1}>
<Checkbox
disabled={!active || status?.type === 'pending'}
checked={botConfig?.chat_keys ?? false}
onCheckedChange={(ev) =>
dispatch(
apiReducer.actions.twitchBotConfigChanged({
...botConfig,
chat_keys: !!ev,
}),
)
}
id="bot-chat-keys"
>
<CheckboxIndicator>{active && <CheckIcon />}</CheckboxIndicator>
</Checkbox>
<Label htmlFor="bot-chat-keys">
{t('pages.twitch-settings.bot-chat-keys')}
</Label>
</FlexRow>
</Field>
<Field size="vertical">
<Field size="fullWidth">
<Label htmlFor="bot-chat-history">
{t('pages.twitch-settings.bot-chat-history')}
</Label>
<FlexRow
css={{
justifyContent: 'flex-start',
gap: '0.8rem',
backgroundColor: '$gray6',
borderRadius: '5px',
paddingRight: '0.8rem',
}}
>
<InputBox
type="number"
id="bot-chat-history"
required={active}
disabled={!active || status?.type === 'pending'}
value={botConfig?.chat_history ?? ''}
css={{
appearance: 'textfield',
width: '4rem',
textAlign: 'center',
}}
onChange={(ev) =>
dispatch(
apiReducer.actions.twitchBotConfigChanged({
@ -214,8 +176,6 @@ function TwitchBotSettings() {
)
}
/>
{t('pages.twitch-settings.bot-chat-history-suffix')}
</FlexRow>
</Field>
<SaveButton status={status} />
</form>

View file

@ -108,7 +108,6 @@ func NewBot(api *Client, config BotConfig) *Bot {
}
bot.mu.Unlock()
if bot.config.EnableChatKeys {
bot.api.db.PutJSON(ChatEventKey, message)
if bot.config.ChatHistory > 0 {
if len(bot.chatHistory) >= bot.config.ChatHistory {
@ -117,7 +116,6 @@ func NewBot(api *Client, config BotConfig) *Bot {
bot.chatHistory = append(bot.chatHistory, message)
bot.api.db.PutJSON(ChatHistoryKey, bot.chatHistory)
}
}
if bot.Timers != nil {
go bot.Timers.OnMessage(message)
@ -156,11 +154,15 @@ func NewBot(api *Client, config BotConfig) *Bot {
}
// Load custom commands
api.db.GetJSON(CustomCommandsKey, &bot.customCommands)
err = bot.updateTemplates()
err = api.db.GetJSON(CustomCommandsKey, &bot.customCommands)
if err != nil {
bot.logger.WithError(err).Error("failed to load custom commands")
}
err = bot.updateTemplates()
if err != nil {
bot.logger.WithError(err).Error("failed to parse custom commands")
}
go api.db.Subscribe(context.Background(), bot.updateCommands, CustomCommandsKey)
go api.db.Subscribe(context.Background(), bot.handleWriteMessageRPC, WriteMessageRPC)

View file

@ -15,7 +15,6 @@ type BotConfig struct {
Username string `json:"username"`
Token string `json:"oauth"`
Channel string `json:"channel"`
EnableChatKeys bool `json:"chat_keys"`
ChatHistory int `json:"chat_history"`
}