[core] Add "bits" event

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-10-17 13:17:28 +02:00
parent a2518c26fd
commit b6e65a1f6d
Signed by: luzifer
GPG Key ID: 0066F03ED215AD7D
3 changed files with 18 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package main
func ptrStr(s string) *string { return &s }
var (
eventTypeBits = ptrStr("bits")
eventTypeJoin = ptrStr("join")
eventTypeHost = ptrStr("host")
eventTypePart = ptrStr("part")

7
irc.go
View File

@ -3,6 +3,7 @@ package main
import (
"crypto/tls"
"fmt"
"strconv"
"strings"
"sync"
@ -251,6 +252,12 @@ func (i ircHandler) handleTwitchPrivmsg(m *irc.Message) {
return
}
if bits, err := strconv.ParseInt(string(m.Tags["bits"]), 10, 64); err == nil {
go handleMessage(i.c, m, eventTypeBits, plugins.FieldCollection{
"bits": bits,
})
}
go handleMessage(i.c, m, nil, nil)
}

View File

@ -1,5 +1,15 @@
# Available Events
## `bits`
User spent bits in the channel. The full message is available like in a normal chat message, additionally the `{{ .bits }}` field is added with the total amount of bits spent.
Fields:
- `bits` - Total amount of bits spent in the message
- `channel` - The channel the event occurred in
- `username` - The login-name of the user who spent the bits
## `category_update`
The current category for the channel was changed. (This event has some delay to the real category change!)