Compare commits

..

34 commits

Author SHA1 Message Date
06b3ff2f2f
WIP: Move template into main dir
in order to make branch switching easier

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:22 +01:00
9656010ff3
Add Editors management
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:22 +01:00
1a5b3f6bbd
Fix: Use full screen height
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:22 +01:00
7df78cf1ff
Fix naming
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
e16c623ec4
Improve sidenav display
by marking active item bold and using nested routes

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
32df28f1d8
Add error messages to translations
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
1a425416b8
Add channel editing interface
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
dc21293e35
Disable drag on images etc
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
70e268f1b5
Improve user-interactions
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
721a16ad9f
Hook botauth against events
in order to update frontend info when backend changes

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
5f5fcf6824
Simplify fetch-code
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
c52d66cea7
Add botauth component
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
debd41af50
Fix: Only replace when access_token is present
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
098a0b120d
Add stub for eventlog
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
a12dbc0ed3
Fix: When frontend cannot renew token, log out the user
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
8194d1b80f
Improve login/logout flow
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
770b9d316c
Add bot connection indicator
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
4f00beefd0
Allow to issue generic tokens with variable expiry
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
f9198367a5
Split up core configuration
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
960e205ba3
Implement dashboard content
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
3f1525b0f2
Improve interactions
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
7e783b2d00
Add TS config and I18n
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
8ca3642919
Simplify toast code
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
338284b89b
Work around JS issues, improve toasts
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
e81ffd5acf
Add toasts to communicate with user
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
529f08db18
Improve login flow
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
ba01c3c2f0
Fix: Check editor auth before creating the initial token
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
0075da1eba
Add login and auth handling
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
bb46ba5d0e
Add renew-route, shorten token lifetime
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00
0e9027fa3f
gootstrap new layout
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:20 +01:00
f1f3e70d0d
Remove old interface
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:20 +01:00
5f07a66405
Disable authentication with Twitch token
aside of the `/login` endpoint for the editor

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:20 +01:00
945fb155b4
Add new editor token generator
in order not to throw around Twitch tokens and have tokens expire

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:20 +01:00
0d76c58ede
[template] Add functions parseDuration, parseDurationToSeconds
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:40:53 +01:00
2 changed files with 62 additions and 1 deletions

View file

@ -392,6 +392,32 @@ Example:
< @user @user @user < @user @user @user
``` ```
### `parseDuration`
Parses a duration (i.e. 1h25m10s) into a time.Duration
Syntax: `parseDuration <duration>`
Example:
```
# {{ parseDuration "1h30s" }}
< 1h0m30s
```
### `parseDurationToSeconds`
Parses a duration (i.e. 1h25m10s) into a number of seconds
Syntax: `parseDurationToSeconds <duration>`
Example:
```
# {{ parseDurationToSeconds "1h25m10s" }}
< 5110
```
### `pow` ### `pow`
Returns float from calculation: `float1 ** float2` Returns float from calculation: `float1 ** float2`
@ -480,7 +506,7 @@ Example:
``` ```
# Your int this hour: {{ printf "%.0f" (mulf (seededRandom (list "int" .username (now | date "2006-01-02 15") | join ":")) 100) }}% # Your int this hour: {{ printf "%.0f" (mulf (seededRandom (list "int" .username (now | date "2006-01-02 15") | join ":")) 100) }}%
< Your int this hour: 23% < Your int this hour: 24%
``` ```
### `spotifyCurrentPlaying` ### `spotifyCurrentPlaying`

View file

@ -2,6 +2,9 @@
package date package date
import ( import (
"fmt"
"time"
"github.com/Luzifer/twitch-bot/v3/plugins" "github.com/Luzifer/twitch-bot/v3/plugins"
) )
@ -27,5 +30,37 @@ func Register(args plugins.RegistrationArguments) error {
}, },
}) })
args.RegisterTemplateFunction("parseDuration", plugins.GenericTemplateFunctionGetter(func(duration string) (time.Duration, error) {
d, err := time.ParseDuration(duration)
if err != nil {
return 0, fmt.Errorf("parsing duration: %w", err)
}
return d, nil
}), plugins.TemplateFuncDocumentation{
Description: `Parses a duration (i.e. 1h25m10s) into a time.Duration`,
Syntax: "parseDuration <duration>",
Example: &plugins.TemplateFuncDocumentationExample{
Template: `{{ parseDuration "1h30s" }}`,
ExpectedOutput: "1h0m30s",
},
})
args.RegisterTemplateFunction("parseDurationToSeconds", plugins.GenericTemplateFunctionGetter(func(duration string) (int64, error) {
d, err := time.ParseDuration(duration)
if err != nil {
return 0, fmt.Errorf("parsing duration: %w", err)
}
return int64(d / time.Second), nil
}), plugins.TemplateFuncDocumentation{
Description: `Parses a duration (i.e. 1h25m10s) into a number of seconds`,
Syntax: "parseDurationToSeconds <duration>",
Example: &plugins.TemplateFuncDocumentationExample{
Template: `{{ parseDurationToSeconds "1h25m10s" }}`,
ExpectedOutput: "5110",
},
})
return nil return nil
} }