mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 16:20:02 +00:00
[core] Add support for hype_chat
event
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
2c77c762c3
commit
0b8196b127
3 changed files with 35 additions and 0 deletions
|
@ -25,6 +25,7 @@ var (
|
||||||
eventTypeDelete = ptrStr("delete")
|
eventTypeDelete = ptrStr("delete")
|
||||||
eventTypeFollow = ptrStr("follow")
|
eventTypeFollow = ptrStr("follow")
|
||||||
eventTypeGiftPaidUpgrade = ptrStr("giftpaidupgrade")
|
eventTypeGiftPaidUpgrade = ptrStr("giftpaidupgrade")
|
||||||
|
eventTypeHypeChat = ptrStr("hype_chat")
|
||||||
eventTypeJoin = ptrStr("join")
|
eventTypeJoin = ptrStr("join")
|
||||||
eventTypeOutboundRaid = ptrStr("outbound_raid")
|
eventTypeOutboundRaid = ptrStr("outbound_raid")
|
||||||
eventTypePart = ptrStr("part")
|
eventTypePart = ptrStr("part")
|
||||||
|
@ -57,6 +58,7 @@ var (
|
||||||
eventTypeDelete,
|
eventTypeDelete,
|
||||||
eventTypeFollow,
|
eventTypeFollow,
|
||||||
eventTypeGiftPaidUpgrade,
|
eventTypeGiftPaidUpgrade,
|
||||||
|
eventTypeHypeChat,
|
||||||
eventTypeJoin,
|
eventTypeJoin,
|
||||||
eventTypeOutboundRaid,
|
eventTypeOutboundRaid,
|
||||||
eventTypePart,
|
eventTypePart,
|
||||||
|
|
18
irc.go
18
irc.go
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -354,6 +355,23 @@ func (i ircHandler) handleTwitchPrivmsg(m *irc.Message) {
|
||||||
go handleMessage(i.c, m, eventTypeBits, fields)
|
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)
|
go handleMessage(i.c, m, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,21 @@ Fields:
|
||||||
- `gifter` - The login-name of the user who gifted the subscription
|
- `gifter` - The login-name of the user who gifted the subscription
|
||||||
- `username` - The login-name of the user who upgraded their 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`
|
## `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!
|
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!
|
||||||
|
|
Loading…
Reference in a new issue