[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 }
var (
eventTypeJoin = ptrStr("join")
eventTypeHost = ptrStr("host")
eventTypePart = ptrStr("part")
eventTypePermit = ptrStr("permit")
eventTypeRaid = ptrStr("raid")
eventTypeResub = ptrStr("resub")
eventTypeSub = ptrStr("sub")
eventTypeSubgift = ptrStr("subgift")
eventTypeWhisper = ptrStr("whisper")
eventTypeJoin = ptrStr("join")
eventTypeHost = ptrStr("host")
eventTypePart = ptrStr("part")
eventTypePermit = ptrStr("permit")
eventTypeRaid = ptrStr("raid")
eventTypeResub = ptrStr("resub")
eventTypeSub = ptrStr("sub")
eventTypeSubgift = ptrStr("subgift")
eventTypeSubmysterygift = ptrStr("submysterygift")
eventTypeWhisper = ptrStr("whisper")
eventTypeTwitchCategoryUpdate = ptrStr("category_update")
eventTypeTwitchStreamOffline = ptrStr("stream_offline")
@ -27,6 +28,7 @@ var (
eventTypeResub,
eventTypeSub,
eventTypeSubgift,
eventTypeSubmysterygift,
eventTypeWhisper,
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")
case "raid":
log.WithFields(log.Fields{
evtData := plugins.FieldCollection{
"channel": i.getChannel(m),
"from": m.Tags["login"],
"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":
log.WithFields(log.Fields{
evtData := plugins.FieldCollection{
"channel": i.getChannel(m),
"from": m.Tags["login"],
"subscribed_months": m.Tags["msg-param-cumulative-months"],
"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":
log.WithFields(log.Fields{
evtData := plugins.FieldCollection{
"channel": i.getChannel(m),
"from": m.Tags["login"],
"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":
log.WithFields(log.Fields{
evtData := plugins.FieldCollection{
"channel": i.getChannel(m),
"from": m.Tags["login"],
"gifted_months": m.Tags["msg-param-gift-months"],
"plan": m.Tags["msg-param-sub-plan"],
"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":
log.WithFields(log.Fields{
evtData := plugins.FieldCollection{
"channel": i.getChannel(m),
"from": m.Tags["login"],
"number": m.Tags["msg-param-mass-gift-count"],
"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)
}
}