[core] Add submysterygift event, add more event data to events

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-10-16 14:06:25 +02:00
parent 2261aee955
commit d1386903da
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 32 additions and 23 deletions

View file

@ -3,15 +3,16 @@ package main
func ptrStr(s string) *string { return &s } func ptrStr(s string) *string { return &s }
var ( var (
eventTypeJoin = ptrStr("join") eventTypeJoin = ptrStr("join")
eventTypeHost = ptrStr("host") eventTypeHost = ptrStr("host")
eventTypePart = ptrStr("part") eventTypePart = ptrStr("part")
eventTypePermit = ptrStr("permit") eventTypePermit = ptrStr("permit")
eventTypeRaid = ptrStr("raid") eventTypeRaid = ptrStr("raid")
eventTypeResub = ptrStr("resub") eventTypeResub = ptrStr("resub")
eventTypeSub = ptrStr("sub") eventTypeSub = ptrStr("sub")
eventTypeSubgift = ptrStr("subgift") eventTypeSubgift = ptrStr("subgift")
eventTypeWhisper = ptrStr("whisper") eventTypeSubmysterygift = ptrStr("submysterygift")
eventTypeWhisper = ptrStr("whisper")
eventTypeTwitchCategoryUpdate = ptrStr("category_update") eventTypeTwitchCategoryUpdate = ptrStr("category_update")
eventTypeTwitchStreamOffline = ptrStr("stream_offline") eventTypeTwitchStreamOffline = ptrStr("stream_offline")
@ -27,6 +28,7 @@ var (
eventTypeResub, eventTypeResub,
eventTypeSub, eventTypeSub,
eventTypeSubgift, eventTypeSubgift,
eventTypeSubmysterygift,
eventTypeWhisper, eventTypeWhisper,
eventTypeTwitchCategoryUpdate, eventTypeTwitchCategoryUpdate,

35
irc.go
View file

@ -267,51 +267,58 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
log.WithField("msg", m).Warn("Received usernotice without msg-id") log.WithField("msg", m).Warn("Received usernotice without msg-id")
case "raid": case "raid":
log.WithFields(log.Fields{ evtData := plugins.FieldCollection{
"channel": i.getChannel(m), "channel": i.getChannel(m),
"from": m.Tags["login"], "from": m.Tags["login"],
"viewercount": m.Tags["msg-param-viewerCount"], "viewercount": m.Tags["msg-param-viewerCount"],
}).Info("Incoming raid") }
log.WithFields(log.Fields(evtData)).Info("Incoming raid")
go handleMessage(i.c, m, eventTypeRaid, nil) go handleMessage(i.c, m, eventTypeRaid, evtData)
case "resub": case "resub":
log.WithFields(log.Fields{ evtData := plugins.FieldCollection{
"channel": i.getChannel(m), "channel": i.getChannel(m),
"from": m.Tags["login"], "from": m.Tags["login"],
"subscribed_months": m.Tags["msg-param-cumulative-months"], "subscribed_months": m.Tags["msg-param-cumulative-months"],
"plan": m.Tags["msg-param-sub-plan"], "plan": m.Tags["msg-param-sub-plan"],
}).Info("User re-subscribed") }
log.WithFields(log.Fields(evtData)).Info("User re-subscribed")
go handleMessage(i.c, m, eventTypeResub, nil) go handleMessage(i.c, m, eventTypeResub, evtData)
case "sub": case "sub":
log.WithFields(log.Fields{ evtData := plugins.FieldCollection{
"channel": i.getChannel(m), "channel": i.getChannel(m),
"from": m.Tags["login"], "from": m.Tags["login"],
"plan": m.Tags["msg-param-sub-plan"], "plan": m.Tags["msg-param-sub-plan"],
}).Info("User subscribed") }
log.WithFields(log.Fields(evtData)).Info("User subscribed")
go handleMessage(i.c, m, eventTypeSub, nil) go handleMessage(i.c, m, eventTypeSub, evtData)
case "subgift", "anonsubgift": case "subgift", "anonsubgift":
log.WithFields(log.Fields{ evtData := plugins.FieldCollection{
"channel": i.getChannel(m), "channel": i.getChannel(m),
"from": m.Tags["login"], "from": m.Tags["login"],
"gifted_months": m.Tags["msg-param-gift-months"], "gifted_months": m.Tags["msg-param-gift-months"],
"plan": m.Tags["msg-param-sub-plan"], "plan": m.Tags["msg-param-sub-plan"],
"to": m.Tags["msg-param-recipient-user-name"], "to": m.Tags["msg-param-recipient-user-name"],
}).Info("User gifted a sub") }
log.WithFields(log.Fields(evtData)).Info("User gifted a sub")
go handleMessage(i.c, m, eventTypeSubgift, nil) go handleMessage(i.c, m, eventTypeSubgift, evtData)
case "submysterygift": case "submysterygift":
log.WithFields(log.Fields{ evtData := plugins.FieldCollection{
"channel": i.getChannel(m), "channel": i.getChannel(m),
"from": m.Tags["login"], "from": m.Tags["login"],
"number": m.Tags["msg-param-mass-gift-count"], "number": m.Tags["msg-param-mass-gift-count"],
"plan": m.Tags["msg-param-sub-plan"], "plan": m.Tags["msg-param-sub-plan"],
}).Info("User gifted subs to the community") }
log.WithFields(log.Fields(evtData)).Info("User gifted subs to the community")
go handleMessage(i.c, m, eventTypeSubmysterygift, evtData)
} }
} }