bot

package
v0.0.0-...-8e9a80b Latest Latest
Warning

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

Go to latest
Published: May 20, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_SERVER_PORT  uint = 8000
	DEFAULT_SERVER_IP         = "127.0.0.1"
	DEFAULT_CHANNEL_NAME      = "town-square"
)
View Source
const RESPONSE_TYPE_EPHEMERAL = "ephemeral"

Message will appear temporarily and only display to the user who activated the command

View Source
const RESPONSE_TYPE_IN_CHANNEL = "in_channel"

Message will show up in the channel as a normal message

Variables

This section is empty.

Functions

func Register

func Register(name string, ready func(bot *Bot))

Types

type Bot

type Bot struct {
	Router HttpRouter
	// contains filtered or unexported fields
}

func NewBot

func NewBot(connectionString string, teamName string) (*Bot, error)

Create a new Bot Object

connection string is a url string containing the username, password, server address and path to connect to the mattermost server

Returns a pointer to a Bot object and an error

func (*Bot) Match

func (bot *Bot) Match(callback func(*model.Post, *Bot), matchStrs ...string)

func (*Bot) MatchRegex

func (bot *Bot) MatchRegex(callback func(*model.Post, *Bot), matchRegex ...string)

func (*Bot) NewPost

func (bot *Bot) NewPost() *model.Post

func (*Bot) SendMessage

func (bot *Bot) SendMessage(post *model.Post) error

func (*Bot) SetDefaultChannel

func (bot *Bot) SetDefaultChannel() error

func (*Bot) SetTeam

func (bot *Bot) SetTeam(teamName string) error

func (*Bot) SlashCommand

func (bot *Bot) SlashCommand(cmdConfig SlashCommandConfig, handler SlashCommandHandler)

func (*Bot) Start

func (bot *Bot) Start() error

type Config

type Config struct {
	HttpEnabled        bool
	HttpServerPort     uint
	HttpServerIp       string
	DefaultChannelName string
}

type HttpRouter

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

func (*HttpRouter) Get

func (router *HttpRouter) Get(path string, handler RouteHandler)

func (*HttpRouter) GetRegex

func (router *HttpRouter) GetRegex(path *regexp.Regexp, handler RouteHandler)

func (*HttpRouter) Post

func (router *HttpRouter) Post(path string, handler RouteHandler)

func (*HttpRouter) PostRegex

func (router *HttpRouter) PostRegex(path *regexp.Regexp, handler RouteHandler)

func (HttpRouter) ServeHTTP

func (router HttpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Plugin

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

type RegisterRequest

type RegisterRequest struct {
	Name      string
	ReadyFunc func(*Bot)
}

type Route

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

type RouteHandler

type RouteHandler func(*Bot, http.ResponseWriter, *http.Request)

type SlashCommandConfig

type SlashCommandConfig struct {
	Route       string
	ChannelName string
	Command     string
	Token       string
}

type SlashCommandHandler

type SlashCommandHandler func(*Bot, SlashCommandRequest) *SlashCommandResponse

type SlashCommandRequest

type SlashCommandRequest struct {
	ChannelId   string
	ChannelName string
	Command     string
	TeamDomain  string
	TeamId      string
	Text        string
	Token       string
	UserId      string
	UserName    string
}

func ParseSlashCommandRequest

func ParseSlashCommandRequest(r *http.Request) *SlashCommandRequest

type SlashCommandResponse

type SlashCommandResponse struct {
	// The text to display in the message
	Text string `json:"text"`
	// The username to show as, if left blank will be set to the user who sent the message
	UserName string `json:"username"`
	// Determines how the Message will be displayed.  See RESPONSE_TYPE_IN_CHANNEL and RESPONSE_TYPE_EPHEMERAL
	ResponseType string `json:"response_type"`
	// Url to icon if you wish to override the default icon for the slash command
	IconUrl string `json:"icon_url"`
	// Webpage to redirect the user who sent the slash command to
	GotoLocation string `json:"goto_location"`
}

func NewSlashCommandResponse

func NewSlashCommandResponse(req SlashCommandRequest) *SlashCommandResponse

Jump to

Keyboard shortcuts

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