diff --git a/events.go b/events.go index 2d97cbb..b9fd345 100644 --- a/events.go +++ b/events.go @@ -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, diff --git a/irc.go b/irc.go index 3ed1725..b44380c 100644 --- a/irc.go +++ b/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") + } + } }