matterhook

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"`
	FileIDs     string `schema:"file_ids"`
}

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 []slack.Attachment     `json:"attachments,omitempty"`
	Type        string                 `json:"type,omitempty"`
	Props       map[string]interface{} `json:"props"`
}

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