diff --git a/events.go b/events.go index f129be3..332445e 100644 --- a/events.go +++ b/events.go @@ -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") diff --git a/irc.go b/irc.go index 23ff58a..33d790b 100644 --- a/irc.go +++ b/irc.go @@ -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) } diff --git a/wiki/Events.md b/wiki/Events.md index a0e5a5e..fafea32 100644 --- a/wiki/Events.md +++ b/wiki/Events.md @@ -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!)