matterhook

package
v0.0.0-...-7b3dfe7 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

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 for incoming webhooks on mattermost.
	Url string // nolint:golint
	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"` //nolint:golint
	RawText     string `schema:"raw_text"`
	ServiceId   string `schema:"service_id"` //nolint:golint
	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