mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 16:50:01 +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")
|
eventTypeSubmysterygift = ptrStr("submysterygift")
|
||||||
eventTypeSub = ptrStr("sub")
|
eventTypeSub = ptrStr("sub")
|
||||||
eventTypeTimeout = ptrStr("timeout")
|
eventTypeTimeout = ptrStr("timeout")
|
||||||
|
eventTypeWatchStreak = ptrStr("watch_streak")
|
||||||
eventTypeWhisper = ptrStr("whisper")
|
eventTypeWhisper = ptrStr("whisper")
|
||||||
|
|
||||||
eventTypeTwitchCategoryUpdate = ptrStr("category_update")
|
eventTypeTwitchCategoryUpdate = ptrStr("category_update")
|
||||||
|
@ -76,6 +77,7 @@ var (
|
||||||
eventTypeSubgift,
|
eventTypeSubgift,
|
||||||
eventTypeSubmysterygift,
|
eventTypeSubmysterygift,
|
||||||
eventTypeTimeout,
|
eventTypeTimeout,
|
||||||
|
eventTypeWatchStreak,
|
||||||
eventTypeWhisper,
|
eventTypeWhisper,
|
||||||
|
|
||||||
eventTypeTwitchCategoryUpdate,
|
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)
|
go handleMessage(i.c, m, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:funlen
|
||||||
func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
eventFieldChannel: i.getChannel(m),
|
eventFieldChannel: i.getChannel(m),
|
||||||
|
@ -391,6 +392,12 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
eventFieldUserID: m.Tags["user-id"],
|
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"] {
|
switch m.Tags["msg-id"] {
|
||||||
case "":
|
case "":
|
||||||
// Notices SHOULD have msg-id tags...
|
// Notices SHOULD have msg-id tags...
|
||||||
|
@ -423,12 +430,6 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
go handleMessage(i.c, m, eventTypeRaid, evtData)
|
go handleMessage(i.c, m, eventTypeRaid, evtData)
|
||||||
|
|
||||||
case "resub":
|
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{}{
|
evtData.SetFromData(map[string]interface{}{
|
||||||
"from": m.Tags["login"],
|
"from": m.Tags["login"],
|
||||||
"message": message,
|
"message": message,
|
||||||
|
@ -478,6 +479,21 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
|
|
||||||
go handleMessage(i.c, m, eventTypeSubmysterygift, evtData)
|
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