add readme

This commit is contained in:
Simon Vieille 2025-08-29 12:46:37 +02:00
commit 2590c74dc4
Signed by: deblan
GPG key ID: 579388D585F70417
3 changed files with 201 additions and 2016 deletions

29
README.md Normal file
View file

@ -0,0 +1,29 @@
# Owncast webhook server and chat aggregator
This project provides a webhook server for Owncast.
It implements the webhook triggered when a new message is posted in the chat. It also allows retrieving messages from a Twitch channel and displaying them together on a page that can be embedded into OBS.
## Installation
```
git clone https://gitnet.fr/deblan/owncast-webhook
npm i
./node_modules/.bin/webpack
go run ./cmd/server/
```
## Configuration
### Server side
```
cp config.ini.example config.ini
```
### Owncast
Add a webhook (Integration > Webhooks):
- URL: `https://api.example.com/webhook/{server.webhook_secret}/owncast/chat_message`
- Events: `When a user sends a chat message`

View file

@ -23,6 +23,46 @@ func New(e *echo.Echo) *Controller {
}
func (ctrl *Controller) Messages(c echo.Context) error {
createMessage := func(message store.MessageInterface) Node {
var containerStyle Node
var userStyle Node
var originIcon Node
switch message.Origin() {
case store.MessageOriginOwncast:
msg := message.(store.OwncastMessage)
containerStyle = StyleAttr(fmt.Sprintf(
"border-color: var(--theme-color-users-%d)",
msg.WebhookMessage.User.DisplayColor,
))
userStyle = StyleAttr(fmt.Sprintf(
"color: var(--theme-color-users-%d)",
msg.WebhookMessage.User.DisplayColor,
))
originIcon = Img(Src(assets.Asset("static/img/owncast.png")), Class("message-origin"))
case store.MessageOriginTwitch:
originIcon = Img(Src(assets.Asset("static/img/twitch.png")), Class("message-origin"))
}
return Div(
Class("message"),
ID(message.ID()),
containerStyle,
Div(
Class("message-user"),
userStyle,
Group([]Node{originIcon, Text(message.Author())}),
),
Div(
Class("message-body"),
Raw(message.Content()),
),
)
}
page := HTML5(HTML5Props{
Title: "Chat",
Language: "fr",
@ -34,45 +74,7 @@ func (ctrl *Controller) Messages(c echo.Context) error {
ID("chat"),
Div(
Class("messages"),
Map(store.GetMessageStore().All(), func(message store.MessageInterface) Node {
var containerStyle Node
var userStyle Node
var originIcon Node
switch message.Origin() {
case store.MessageOriginOwncast:
msg := message.(store.OwncastMessage)
containerStyle = StyleAttr(fmt.Sprintf(
"border-color: var(--theme-color-users-%d)",
msg.WebhookMessage.User.DisplayColor,
))
userStyle = StyleAttr(fmt.Sprintf(
"color: var(--theme-color-users-%d)",
msg.WebhookMessage.User.DisplayColor,
))
originIcon = Img(Src(assets.Asset("static/img/owncast.png")), Class("message-origin"))
case store.MessageOriginTwitch:
originIcon = Img(Src(assets.Asset("static/img/twitch.png")), Class("message-origin"))
}
return Div(
Class("message"),
ID(message.ID()),
containerStyle,
Div(
Class("message-user"),
userStyle,
Group([]Node{originIcon, Text(message.Author())}),
),
Div(
Class("message-body"),
Raw(message.Content()),
),
)
}),
Map(store.GetMessageStore().All(), createMessage),
),
Group(assets.EntrypointJs("main")),
},

1886
package-lock.json generated

File diff suppressed because it is too large Load diff