Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created August 10, 2021 13:12
Show Gist options
  • Save percybolmer/ba2c4d9e2a5745d7b83b725e0b88d721 to your computer and use it in GitHub Desktop.
Save percybolmer/ba2c4d9e2a5745d7b83b725e0b88d721 to your computer and use it in GitHub Desktop.
// handleEventMessage will take an event and handle it properly based on the type of event
func handleEventMessage(event slackevents.EventsAPIEvent) error {
switch event.Type {
// First we check if this is an CallbackEvent
case slackevents.CallbackEvent:
innerEvent := event.InnerEvent
// Yet Another Type switch on the actual Data to see if its an AppMentionEvent
switch ev := innerEvent.Data.(type) {
case *slackevents.AppMentionEvent:
// The application has been mentioned since this Event is a Mention event
log.Println(ev)
}
default:
return errors.New("unsupported event type")
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment