feat(chat): add test mode
This commit is contained in:
parent
52e0f16052
commit
cad4942e66
3 changed files with 47 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
"time"
|
||||||
|
|
||||||
rice "github.com/GeertJohan/go.rice"
|
rice "github.com/GeertJohan/go.rice"
|
||||||
"github.com/go-playground/validator"
|
"github.com/go-playground/validator"
|
||||||
|
|
@ -14,6 +15,7 @@ import (
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
"gitnet.fr/deblan/owncast-webhook/internal/client/twitch"
|
"gitnet.fr/deblan/owncast-webhook/internal/client/twitch"
|
||||||
"gitnet.fr/deblan/owncast-webhook/internal/config"
|
"gitnet.fr/deblan/owncast-webhook/internal/config"
|
||||||
|
"gitnet.fr/deblan/owncast-webhook/internal/store"
|
||||||
"gitnet.fr/deblan/owncast-webhook/internal/web/router"
|
"gitnet.fr/deblan/owncast-webhook/internal/web/router"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -43,6 +45,15 @@ func main() {
|
||||||
e.Use(middleware.Logger())
|
e.Use(middleware.Logger())
|
||||||
router.RegisterControllers(e)
|
router.RegisterControllers(e)
|
||||||
|
|
||||||
|
if conf.Test.Enable {
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
store.GetMessageStore().Add(store.TestMessage{})
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
if conf.Twitch.Enable {
|
if conf.Twitch.Enable {
|
||||||
twitch.IrcClient()
|
twitch.IrcClient()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,7 @@ base_url = "https://live.example.com"
|
||||||
[twitch]
|
[twitch]
|
||||||
enable = false
|
enable = false
|
||||||
channel = "username"
|
channel = "username"
|
||||||
|
|
||||||
|
; Add fake messages to test
|
||||||
|
[test]
|
||||||
|
enable = false
|
||||||
|
|
|
||||||
32
internal/store/test_message.go
Normal file
32
internal/store/test_message.go
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
package store
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
|
"github.com/gempir/go-twitch-irc/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TestMessage struct {
|
||||||
|
Message twitch.PrivateMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o TestMessage) ID() string {
|
||||||
|
return fmt.Sprintf("%f", rand.Float64())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o TestMessage) Visible() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o TestMessage) Origin() MessageOrigin {
|
||||||
|
return MessageOriginTest
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o TestMessage) Author() string {
|
||||||
|
return fmt.Sprintf("%f", rand.Float64())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o TestMessage) Content() string {
|
||||||
|
return fmt.Sprintf("%f", rand.Float64())
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue