Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created August 10, 2021 13:43
Show Gist options
  • Save percybolmer/015f0b507cb955dded164e5e1d5bc5e6 to your computer and use it in GitHub Desktop.
Save percybolmer/015f0b507cb955dded164e5e1d5bc5e6 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, client *slack.Client) 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
err := handleAppMentionEvent(ev, client)
if err != nil {
return err
}
}
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