poll

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ResponseUsername is the username which will be used to post the slack command response
	ResponseUsername = "Matterpoll"
	// ResponseIconURL is the profile picture which will be used to post the slack command response
	ResponseIconURL = "https://www.mattermost.org/wp-content/uploads/2016/04/icon.png"
)
View Source
const (

	//ErrorTextWrongFormat is an error message and is used, if the message isn`t formated correct
	ErrorTextWrongFormat = `The message format is wrong. Try this instead: ` + backTick + `/poll \"What do you gys wanna grab for lunch?\" :pizza: :sushi:` + backTick
	// ErrorTokenMissmatch is an error message and is used, if the token comparison fails
	ErrorTokenMissmatch = `An error occurred. Ask your administrator to check the Matterpoll config settings.`
	// ErrorWrongLength is an error message and is used, if the channel id or the token have a wrong length
	ErrorWrongLength = `An error occurred. Try the same command again. If it fails again, contact your administrator.`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf struct {
	Host   string `json:"host"`
	Listen string `json:"listen"`
	Token  string `json:"token"`
	User   User   `json:"user"`
}

Conf represents the login credentials of a mattermost user

func LoadConf

func LoadConf(path string) (*Conf, error)

LoadConf loads a configuration file located at path and parse it to a Conf struct

type Request added in v0.1.0

type Request struct {
	ChannelID string
	Token     string
	Message   string
	Emojis    []string
}

Request wraps up all information needed to answer a poll request

func NewRequest added in v0.1.0

func NewRequest(u map[string][]string) (*Request, error)

NewRequest validates the data in map and wraps it into a Request struct

type Server added in v0.1.0

type Server struct {
	Conf *Conf
}

Server handles slash commands from a mattermost instance. One sever may handle multiple requests from one mattermost instance. It uses a provided configuration to handle the requests.

func (Server) Cmd added in v0.1.0

func (ps Server) Cmd(w http.ResponseWriter, r *http.Request)

Cmd handles a slash command request and sends back a response

type User added in v0.1.0

type User struct {
	ID       string `json:"id"`
	Password string `json:"password"`
}

User represents the login credentials of a mattermost user

Jump to

Keyboard shortcuts

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