mirror of https://github.com/velour/catbase.git
slackapp: fix reaction logging
This commit is contained in:
parent
030d0371f9
commit
1ff79ce2c9
|
@ -126,6 +126,7 @@ func (s *SlackApp) Serve() error {
|
||||||
w.Write([]byte(r.Challenge))
|
w.Write([]byte(r.Challenge))
|
||||||
} else if eventsAPIEvent.Type == slackevents.CallbackEvent {
|
} else if eventsAPIEvent.Type == slackevents.CallbackEvent {
|
||||||
innerEvent := eventsAPIEvent.InnerEvent
|
innerEvent := eventsAPIEvent.InnerEvent
|
||||||
|
typ := innerEvent.Type
|
||||||
switch ev := innerEvent.Data.(type) {
|
switch ev := innerEvent.Data.(type) {
|
||||||
case *slackevents.MessageAction:
|
case *slackevents.MessageAction:
|
||||||
log.Debug().Interface("ev", ev).Msg("MessageAction")
|
log.Debug().Interface("ev", ev).Msg("MessageAction")
|
||||||
|
@ -137,11 +138,15 @@ func (s *SlackApp) Serve() error {
|
||||||
//s.msgReceivd(ev)
|
//s.msgReceivd(ev)
|
||||||
case *slackevents.MessageEvent:
|
case *slackevents.MessageEvent:
|
||||||
s.msgReceivd(ev)
|
s.msgReceivd(ev)
|
||||||
case *slack.ReactionAddedEvent:
|
case *slackevents.ReactionAddedEvent:
|
||||||
s.reactionReceived(ev)
|
err := s.reactionReceived(ev)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("error with reaction recording")
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
log.Debug().
|
log.Debug().
|
||||||
Interface("ev", ev).
|
Interface("ev", ev).
|
||||||
|
Interface("type", typ).
|
||||||
Msg("Unknown CallbackEvent")
|
Msg("Unknown CallbackEvent")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -607,7 +612,8 @@ func (s *SlackApp) log(msg, channel string) error {
|
||||||
return f.Sync()
|
return f.Sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SlackApp) reactionReceived(event *slack.ReactionAddedEvent) error {
|
func (s *SlackApp) reactionReceived(event *slackevents.ReactionAddedEvent) error {
|
||||||
|
log.Debug().Msgf("reactionReceived(%+v)", event)
|
||||||
name, _ := s.getUser(event.User, "unknown")
|
name, _ := s.getUser(event.User, "unknown")
|
||||||
|
|
||||||
ch, err := s.getChannel(event.Item.Channel)
|
ch, err := s.getChannel(event.Item.Channel)
|
||||||
|
@ -632,7 +638,7 @@ func (s *SlackApp) reactionReceived(event *slack.ReactionAddedEvent) error {
|
||||||
body = fmt.Sprintf("%s: %s", u, m.Text)
|
body = fmt.Sprintf("%s: %s", u, m.Text)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
log.Debug().Interface("msg", m).Msg("Unexpected type")
|
log.Debug().Interface("msg", m).Msg("Unexpected type in reaction received")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -641,6 +647,8 @@ func (s *SlackApp) reactionReceived(event *slack.ReactionAddedEvent) error {
|
||||||
fixDate(tstamp, "2006-01-02 15:04:05"),
|
fixDate(tstamp, "2006-01-02 15:04:05"),
|
||||||
name, body, event.Reaction)
|
name, body, event.Reaction)
|
||||||
|
|
||||||
|
log.Debug().Msgf("Made it to reaction received, logging %v: %v", msg, channel)
|
||||||
|
|
||||||
return s.log(msg, channel)
|
return s.log(msg, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
go.mod
5
go.mod
|
@ -14,6 +14,7 @@ require (
|
||||||
github.com/antchfx/xpath v1.1.1 // indirect
|
github.com/antchfx/xpath v1.1.1 // indirect
|
||||||
github.com/armon/go-radix v1.0.0 // indirect
|
github.com/armon/go-radix v1.0.0 // indirect
|
||||||
github.com/azr/backoff v0.0.0-20160115115103-53511d3c7330 // indirect
|
github.com/azr/backoff v0.0.0-20160115115103-53511d3c7330 // indirect
|
||||||
|
github.com/cdipaolo/goml v0.0.0-20190412180403-e1f51f713598
|
||||||
github.com/chrissexton/gofuck v1.0.0
|
github.com/chrissexton/gofuck v1.0.0
|
||||||
github.com/chrissexton/leftpad v0.0.0-20181207133115-1e93189d2fff
|
github.com/chrissexton/leftpad v0.0.0-20181207133115-1e93189d2fff
|
||||||
github.com/chrissexton/sentiment v0.0.0-20190927141846-d69c422ba035
|
github.com/chrissexton/sentiment v0.0.0-20190927141846-d69c422ba035
|
||||||
|
@ -28,7 +29,6 @@ require (
|
||||||
github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82 // indirect
|
github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82 // indirect
|
||||||
github.com/gonum/internal v0.0.0-20181124074243-f884aa714029 // indirect
|
github.com/gonum/internal v0.0.0-20181124074243-f884aa714029 // indirect
|
||||||
github.com/google/uuid v1.1.1
|
github.com/google/uuid v1.1.1
|
||||||
github.com/gorilla/websocket v1.4.1 // indirect
|
|
||||||
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 // indirect
|
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 // indirect
|
||||||
github.com/james-bowman/nlp v0.0.0-20191016091239-d9dbfaff30c6
|
github.com/james-bowman/nlp v0.0.0-20191016091239-d9dbfaff30c6
|
||||||
github.com/james-bowman/sparse v0.0.0-20190423065201-80c6877364c7 // indirect
|
github.com/james-bowman/sparse v0.0.0-20190423065201-80c6877364c7 // indirect
|
||||||
|
@ -44,10 +44,11 @@ require (
|
||||||
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf // indirect
|
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf // indirect
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254
|
github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254
|
||||||
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d // indirect
|
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d // indirect
|
||||||
github.com/rs/zerolog v1.15.0
|
github.com/rs/zerolog v1.15.0
|
||||||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
|
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
|
||||||
github.com/slack-go/slack v0.6.4
|
github.com/slack-go/slack v0.6.5
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
github.com/stretchr/objx v0.2.0 // indirect
|
github.com/stretchr/objx v0.2.0 // indirect
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.4.0
|
||||||
|
|
12
go.sum
12
go.sum
|
@ -70,10 +70,8 @@ github.com/gonum/internal v0.0.0-20181124074243-f884aa714029 h1:8jtTdc+Nfj9AR+0s
|
||||||
github.com/gonum/internal v0.0.0-20181124074243-f884aa714029/go.mod h1:Pu4dmpkhSyOzRwuXkOgAvijx4o+4YMUJJo9OvPYMkks=
|
github.com/gonum/internal v0.0.0-20181124074243-f884aa714029/go.mod h1:Pu4dmpkhSyOzRwuXkOgAvijx4o+4YMUJJo9OvPYMkks=
|
||||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
|
||||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
|
||||||
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 h1:KUDFlmBg2buRWNzIcwLlKvfcnujcHQRQ1As1LoaCLAM=
|
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 h1:KUDFlmBg2buRWNzIcwLlKvfcnujcHQRQ1As1LoaCLAM=
|
||||||
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o=
|
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o=
|
||||||
github.com/james-bowman/nlp v0.0.0-20191016091239-d9dbfaff30c6 h1:k8+n5sfvxlixRNVkbelPGzEYjbGIKaBnRzRlx2NCtYA=
|
github.com/james-bowman/nlp v0.0.0-20191016091239-d9dbfaff30c6 h1:k8+n5sfvxlixRNVkbelPGzEYjbGIKaBnRzRlx2NCtYA=
|
||||||
|
@ -113,6 +111,8 @@ github.com/olebedev/when v0.0.0-20190311101825-c3b538a97254/go.mod h1:DPucAeQGDP
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d h1:1VUlQbCfkoSGv7qP7Y+ro3ap1P1pPZxgdGVqiTVy5C4=
|
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d h1:1VUlQbCfkoSGv7qP7Y+ro3ap1P1pPZxgdGVqiTVy5C4=
|
||||||
|
@ -122,8 +122,8 @@ github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY=
|
||||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
|
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
|
||||||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
|
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
|
||||||
github.com/slack-go/slack v0.6.4 h1:cxOqFgM5RW6mdEyDqAJutFk3qiORK9oHRKi5bPqkY9o=
|
github.com/slack-go/slack v0.6.5 h1:IkDKtJ2IROJNoe3d6mW870/NRKvq2fhLB/Q5XmzWk00=
|
||||||
github.com/slack-go/slack v0.6.4/go.mod h1:sGRjv3w+ERAUMMMbldHObQPBcNSyVB7KLKYfnwUFBfw=
|
github.com/slack-go/slack v0.6.5/go.mod h1:FGqNzJBmxIsZURAxh2a8D21AnOVvvXZvGligs4npPUM=
|
||||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
|
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
|
||||||
|
|
Loading…
Reference in New Issue