matterhook

package
v0.11.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2017 License: Apache-2.0 Imports: 11 Imported by: 23

Documentation

Overview

Package matterhook provides interaction with mattermost incoming/outgoing webhooks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Url string // URL for incoming webhooks on mattermost.
	In  chan IMessage
	Out chan OMessage

	Config
	// contains filtered or unexported fields
}

Client for Mattermost.

func New

func New(url string, config Config) *Client

New Mattermost client.

func (*Client) Receive

func (c *Client) Receive() IMessage

Receive returns an incoming message from mattermost outgoing webhooks URL.

func (*Client) Send

func (c *Client) Send(msg OMessage) error

Send sends a msg to mattermost incoming webhooks URL.

func (*Client) ServeHTTP

func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implementation.

func (*Client) StartServer

func (c *Client) StartServer()

StartServer starts a webserver listening for incoming mattermost POSTS.

type Config

type Config struct {
	BindAddress        string // Address to listen on
	Token              string // Only allow this token from Mattermost. (Allow everything when empty)
	InsecureSkipVerify bool   // disable certificate checking
	DisableServer      bool   // Do not start server for outgoing webhooks from Mattermost.
}

Config for client.

type IMessage

type IMessage struct {
	BotID       string `schema:"bot_id"`
	BotName     string `schema:"bot_name"`
	Token       string `schema:"token"`
	TeamID      string `schema:"team_id"`
	TeamDomain  string `schema:"team_domain"`
	ChannelID   string `schema:"channel_id"`
	ChannelName string `schema:"channel_name"`
	Timestamp   string `schema:"timestamp"`
	UserID      string `schema:"user_id"`
	UserName    string `schema:"user_name"`
	PostId      string `schema:"post_id"`
	RawText     string `schema:"raw_text"`
	ServiceId   string `schema:"service_id"`
	Text        string `schema:"text"`
	TriggerWord string `schema:"trigger_word"`
}

IMessage for mattermost outgoing webhook. (received from mattermost)

type OMessage

type OMessage struct {
	Channel     string      `json:"channel,omitempty"`
	IconURL     string      `json:"icon_url,omitempty"`
	IconEmoji   string      `json:"icon_emoji,omitempty"`
	UserName    string      `json:"username,omitempty"`
	Text        string      `json:"text"`
	Attachments interface{} `json:"attachments,omitempty"`
	Type        string      `json:"type,omitempty"`
}

OMessage for mattermost incoming webhook. (send to mattermost)

Jump to

Keyboard shortcuts

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