mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 16:50:01 +00:00
[core] Add username fields to events
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
d1386903da
commit
a91410d1ce
2 changed files with 15 additions and 6 deletions
17
irc.go
17
irc.go
|
@ -205,7 +205,7 @@ func (i ircHandler) handlePermit(m *irc.Message) {
|
||||||
log.WithField("user", username).Debug("Added permit")
|
log.WithField("user", username).Debug("Added permit")
|
||||||
timerStore.AddPermit(m.Params[0], username)
|
timerStore.AddPermit(m.Params[0], username)
|
||||||
|
|
||||||
go handleMessage(i.c, m, eventTypePermit, nil)
|
go handleMessage(i.c, m, eventTypePermit, plugins.FieldCollection{"username": username})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i ircHandler) handleTwitchNotice(m *irc.Message) {
|
func (i ircHandler) handleTwitchNotice(m *irc.Message) {
|
||||||
|
@ -268,8 +268,9 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
|
|
||||||
case "raid":
|
case "raid":
|
||||||
evtData := plugins.FieldCollection{
|
evtData := plugins.FieldCollection{
|
||||||
"channel": i.getChannel(m),
|
"channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel
|
||||||
"from": m.Tags["login"],
|
"from": m.Tags["login"],
|
||||||
|
"user": m.Tags["login"], // Compatibility to plugins.DeriveUser
|
||||||
"viewercount": m.Tags["msg-param-viewerCount"],
|
"viewercount": m.Tags["msg-param-viewerCount"],
|
||||||
}
|
}
|
||||||
log.WithFields(log.Fields(evtData)).Info("Incoming raid")
|
log.WithFields(log.Fields(evtData)).Info("Incoming raid")
|
||||||
|
@ -278,10 +279,11 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
|
|
||||||
case "resub":
|
case "resub":
|
||||||
evtData := plugins.FieldCollection{
|
evtData := plugins.FieldCollection{
|
||||||
"channel": i.getChannel(m),
|
"channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel
|
||||||
"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"],
|
||||||
|
"user": m.Tags["login"], // Compatibility to plugins.DeriveUser
|
||||||
}
|
}
|
||||||
log.WithFields(log.Fields(evtData)).Info("User re-subscribed")
|
log.WithFields(log.Fields(evtData)).Info("User re-subscribed")
|
||||||
|
|
||||||
|
@ -289,9 +291,10 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
|
|
||||||
case "sub":
|
case "sub":
|
||||||
evtData := plugins.FieldCollection{
|
evtData := plugins.FieldCollection{
|
||||||
"channel": i.getChannel(m),
|
"channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel
|
||||||
"from": m.Tags["login"],
|
"from": m.Tags["login"],
|
||||||
"plan": m.Tags["msg-param-sub-plan"],
|
"plan": m.Tags["msg-param-sub-plan"],
|
||||||
|
"user": m.Tags["login"], // Compatibility to plugins.DeriveUser
|
||||||
}
|
}
|
||||||
log.WithFields(log.Fields(evtData)).Info("User subscribed")
|
log.WithFields(log.Fields(evtData)).Info("User subscribed")
|
||||||
|
|
||||||
|
@ -299,11 +302,12 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
|
|
||||||
case "subgift", "anonsubgift":
|
case "subgift", "anonsubgift":
|
||||||
evtData := plugins.FieldCollection{
|
evtData := plugins.FieldCollection{
|
||||||
"channel": i.getChannel(m),
|
"channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel
|
||||||
"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"],
|
||||||
|
"user": m.Tags["login"], // Compatibility to plugins.DeriveUser
|
||||||
}
|
}
|
||||||
log.WithFields(log.Fields(evtData)).Info("User gifted a sub")
|
log.WithFields(log.Fields(evtData)).Info("User gifted a sub")
|
||||||
|
|
||||||
|
@ -311,10 +315,11 @@ func (i ircHandler) handleTwitchUsernotice(m *irc.Message) {
|
||||||
|
|
||||||
case "submysterygift":
|
case "submysterygift":
|
||||||
evtData := plugins.FieldCollection{
|
evtData := plugins.FieldCollection{
|
||||||
"channel": i.getChannel(m),
|
"channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel
|
||||||
"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"],
|
||||||
|
"user": m.Tags["login"], // Compatibility to plugins.DeriveUser
|
||||||
}
|
}
|
||||||
log.WithFields(log.Fields(evtData)).Info("User gifted subs to the community")
|
log.WithFields(log.Fields(evtData)).Info("User gifted subs to the community")
|
||||||
|
|
||||||
|
|
|
@ -28,5 +28,9 @@ func DeriveUser(m *irc.Message, evtData FieldCollection) string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s, err := evtData.String("username"); err == nil {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue