slack

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 2 Imported by: 0

README

Apex Slack

Providing Slack Events for Apex

Features

This is intended for use with API Gateway or services that use JSON.

Example

package main

import (
	apex "github.com/apex/go-apex"
	"github.com/apex/go-apex/slack"
)

func main() {
	slack.HandleFunc(func(event *slack.Event, ctx *apex.Context) (interface{}, error) {
		// useEventData(event)

		// Construct response message
		var message slack.ResponseMessage
		message.ResponseType = "in_channel"
		message.Text = "response text"

		return message, nil
	})
}

GitHub @DaveBlooman  ·  Twitter @dblooman

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(h Handler)

Handle Slack Events with handler.

func HandleFunc

func HandleFunc(h HandlerFunc)

HandleFunc handles Slack Events with callback function.

Types

type Event

type Event struct {
	ChannelID   string `json:"channel_id"`
	ChannelName string `json:"channel_name"`
	Command     string `json:"command"`
	ResponseURL string `json:"response_url"`
	TeamDomain  string `json:"team_domain"`
	TeamID      string `json:"team_id"`
	Text        string `json:"text"`
	Token       string `json:"token"`
	UserID      string `json:"user_id"`
	UserName    string `json:"user_name"`
}

Event data JSON

type Handler

type Handler interface {
	HandleSlackEvent(*Event, *apex.Context) (interface{}, error)
}

Handler handles Slack Events

type HandlerFunc

type HandlerFunc func(*Event, *apex.Context) (interface{}, error)

HandlerFunc unmarshals Slack Events before passing control.

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(data json.RawMessage, ctx *apex.Context) (interface{}, error)

Handle implements apex.Handler.

type ResponseMessage

type ResponseMessage struct {
	ResponseType string `json:"response_type"`
	Text         string `json:"text"`
}

ResponseMessage JSON

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL