mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 11:51:17 +00:00
[core] Add support for watch_streak
event
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
fa9f5591f6
commit
e1434eb403
2 changed files with 24 additions and 6 deletions
|
@ -42,6 +42,7 @@ var (
|
|||
eventTypeSubmysterygift = ptrStr("submysterygift")
|
||||
eventTypeSub = ptrStr("sub")
|
||||
eventTypeTimeout = ptrStr("timeout")
|
||||
eventTypeWatchStreak = ptrStr("watch_streak")
|
||||
eventTypeWhisper = ptrStr("whisper")
|
||||
|
||||
eventTypeTwitchCategoryUpdate = ptrStr("category_update")
|
||||
|
@ -76,6 +77,7 @@ var (
|
|||
eventTypeSubgift,
|
||||
eventTypeSubmysterygift,
|
||||
eventTypeTimeout,
|
||||
eventTypeWatchStreak,
|
||||
eventTypeWhisper,
|
||||
|
||||
eventTypeTwitchCategoryUpdate,
|
||||
|
|
28
irc.go
28
irc.go
|
@ -378,6 +378,7 @@ func (i ircHandler) handleTwitchPrivmsg(m *irc.Message) {
|
|||
go handleMessage(i.c, m, nil, nil)
|
||||
}
|
||||
|
||||
//nolint:funlen
|
||||
func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||
log.WithFields(log.Fields{
|
||||
eventFieldChannel: i.getChannel(m),
|
||||
|
@ -391,6 +392,12 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
|||
eventFieldUserID: m.Tags["user-id"],
|
||||
})
|
||||
|
||||
message := m.Trailing()
|
||||
if message == i.getChannel(m) {
|
||||
// If no message is given, Trailing yields the channel name
|
||||
message = ""
|
||||
}
|
||||
|
||||
switch m.Tags["msg-id"] {
|
||||
case "":
|
||||
// Notices SHOULD have msg-id tags...
|
||||
|
@ -423,12 +430,6 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
|||
go handleMessage(i.c, m, eventTypeRaid, evtData)
|
||||
|
||||
case "resub":
|
||||
message := m.Trailing()
|
||||
if message == i.getChannel(m) {
|
||||
// If no message is given, Trailing yields the channel name
|
||||
message = ""
|
||||
}
|
||||
|
||||
evtData.SetFromData(map[string]interface{}{
|
||||
"from": m.Tags["login"],
|
||||
"message": message,
|
||||
|
@ -478,6 +479,21 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
|||
|
||||
go handleMessage(i.c, m, eventTypeSubmysterygift, evtData)
|
||||
|
||||
case "viewermilestone":
|
||||
switch m.Tags["msg-param-category"] {
|
||||
case "watch-streak":
|
||||
evtData.SetFromData(map[string]any{
|
||||
"message": message,
|
||||
"streak": i.tagToNumeric(m, "msg-param-value", 0),
|
||||
})
|
||||
log.WithFields(log.Fields(evtData.Data())).Info("User shared a watch-streak")
|
||||
|
||||
go handleMessage(i.c, m, eventTypeWatchStreak, evtData)
|
||||
|
||||
default:
|
||||
log.WithField("category", m.Tags["msg-param-category"]).Debug("found unhandled viewermilestone category")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue