mmhook

package
v0.0.0-...-f5ab1f4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mmhook implements an adapter that uses Mattermost Webhooks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for Mattermost.

func NewClient

func NewClient(config *adapter.Config, logger *log.Logger) *Client

NewClient returns new mattermost webhook client.

func (*Client) IncomingWebHook

func (c *Client) IncomingWebHook() *adapter.IncomingWebHook

IncomingWebHook returns webhook. It will be disabled if nil.

func (*Client) Send

func (c *Client) Send(msg *message.OutMessage) error

Send sends a message to Mattermost.

func (*Client) ServeHTTP

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

ServeHTTP implements http.Handler interface. ServeHTTP receives a message from Mattermost outgoing webhook.

func (*Client) Start

func (c *Client) Start() (chan message.InMessage, chan error)

Start starts the communication with Mattermost.

func (*Client) Stop

func (c *Client) Stop()

Stop terminates the communication.

type InMessage

type InMessage struct {
	ChannelID   string `schema:"channel_id"`
	ChannelName string `schema:"channel_name"`
	TeamDomain  string `schema:"team_domain"`
	TeamID      string `schema:"team_id"`
	Text        string `schema:"text"`
	Timestamp   string `schema:"timestamp"`
	Token       string `schema:"token"`
	TriggerWord string `schema:"trigger_word"`
	UserID      string `schema:"user_id"`
	UserName    string `schema:"user_name"`
}

InMessage represents a message from Mattermost outgouing webhook. (received from Mattermost)

type OutMessage

type OutMessage struct {
	Text     string `json:"text,omitempty"`
	Channel  string `json:"channel,omitempty"`
	UserName string `json:"username,omitempty"`
	IconURL  string `json:"icon_url,omitempty"`
}

OutMessage represents a message to Mattermost incomig webhook. (send to Mattermost)

type SendError

type SendError struct {
	Err                error
	RatelimitLimit     int
	RatelimitRemaining int
	RatelimitReset     int
	RequestID          string
	VersionID          string
	Date               string
	ContentLength      int
	ContentType        string
	Body               string
}

SendError represents an error of sending message.

func (SendError) Error

func (e SendError) Error() string

Jump to

Keyboard shortcuts

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