[core] Add support for hype_chat event

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-07-21 23:25:20 +02:00
parent 2c77c762c3
commit 0b8196b127
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5
3 changed files with 35 additions and 0 deletions

View file

@ -25,6 +25,7 @@ var (
eventTypeDelete = ptrStr("delete")
eventTypeFollow = ptrStr("follow")
eventTypeGiftPaidUpgrade = ptrStr("giftpaidupgrade")
eventTypeHypeChat = ptrStr("hype_chat")
eventTypeJoin = ptrStr("join")
eventTypeOutboundRaid = ptrStr("outbound_raid")
eventTypePart = ptrStr("part")
@ -57,6 +58,7 @@ var (
eventTypeDelete,
eventTypeFollow,
eventTypeGiftPaidUpgrade,
eventTypeHypeChat,
eventTypeJoin,
eventTypeOutboundRaid,
eventTypePart,

18
irc.go
View file

@ -3,6 +3,7 @@ package main
import (
"crypto/tls"
"fmt"
"math"
"strconv"
"strings"
"sync"
@ -354,6 +355,23 @@ func (i ircHandler) handleTwitchPrivmsg(m *irc.Message) {
go handleMessage(i.c, m, eventTypeBits, fields)
}
if amount := i.tagToNumeric(m, "pinned-chat-paid-amount", 0); amount > 0 {
fields := plugins.FieldCollectionFromData(map[string]any{
"amount": float64(amount) / math.Pow10(int(i.tagToNumeric(m, "pinned-chat-paid-exponent", 0))),
"currency": m.Tags["pinned-chat-paid-currency"],
eventFieldChannel: i.getChannel(m),
eventFieldUserID: m.Tags["user-id"],
eventFieldUserName: m.User,
"is_system_message": m.Tags["pinned-chat-paid-is-system-message"] == "1",
"level": m.Tags["pinned-chat-paid-level"],
"message": m.Trailing(),
})
log.WithFields(log.Fields(fields.Data())).Info("User used hype-chat message")
go handleMessage(i.c, m, eventTypeHypeChat, fields)
}
go handleMessage(i.c, m, nil, nil)
}

View file

@ -89,6 +89,21 @@ Fields:
- `gifter` - The login-name of the user who gifted the subscription
- `username` - The login-name of the user who upgraded their subscription
## `hype_chat`
User used the Twitch "Hype Chat" to pin a message to the chat.
Fields:
- `amount` - Amount of money the user spent (float64, i.e. `1.2` when they used 1.20 EUR)
- `channel` - The channel the event occurred in
- `currency` - [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes) alphabetic currency code
- `is_system_message` - Set to `true` if the user left no message and the message was system-generated
- `level` - `ONE` to `TEN`, uppercase number-words
- `messge` - The message the user sent (or the system generated)
- `user_id` - ID of the user
- `user` - The login-name of the user who sent the message
## `join`
User joined the channel-chat. This is **NOT** an indicator they are viewing, the event is **NOT** reliably sent when the user really joined the chat. The event will be sent with some delay after they join the chat and is sometimes repeated multiple times during their stay. So **DO NOT** use this to greet users!