bots

package
v0.0.0-...-04f0085 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2016 License: MIT Imports: 13 Imported by: 0

README

#bots

A library to build command bots

Documentation

Index

Constants

View Source
const (
	ColorSuccess = "#5cb85c"
	ColorInfo    = "#5bc0de"
	ColorWarning = "#f0ad4e"
	ColorError   = "#d9534f"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Client *slk.Client
	User   *slk.User

	// either Channel or Group will be non-nil
	Channel *slk.Channel
	Group   *slk.Group
	// contains filtered or unexported fields
}

func NewBot

func NewBot(token, channel string) (*Bot, error)

func (*Bot) AddAuthorizedUser

func (bot *Bot) AddAuthorizedUser(userids ...string) error

func (*Bot) AddCommand

func (bot *Bot) AddCommand(command, description string, handler func(w io.Writer, msg *slk.MessageEvent, from *slk.User, args ...string))

func (*Bot) AddIntervalCommand

func (bot *Bot) AddIntervalCommand(interval time.Duration, description string, handler func(w io.Writer))

func (*Bot) AddListener

func (bot *Bot) AddListener(pattern *regexp.Regexp, description string, handler func(w io.Writer, msg *slk.MessageEvent, from *slk.User))

func (*Bot) AddReaction

func (bot *Bot) AddReaction(msg *slk.MessageEvent, reaction string) error

func (*Bot) ChannelID

func (bot *Bot) ChannelID() string

func (*Bot) IsAuthorizedUserID

func (bot *Bot) IsAuthorizedUserID(id string) bool

func (*Bot) Run

func (bot *Bot) Run() error

func (*Bot) SendColorMessage

func (bot *Bot) SendColorMessage(text, color string) error

func (*Bot) SendMessage

func (bot *Bot) SendMessage(text string) error

func (*Bot) SendMessageOptions

func (bot *Bot) SendMessageOptions(text string, options url.Values) error

opt:username // My Bot // Optional // Name of bot. opt:as_user // true // Optional // Pass true to post the message as the authed user, instead of as a bot opt:parse // full // Optional // Change how messages are treated. See below. opt:link_names // 1 // Optional // Find and link channel names and usernames. opt:attachments // [{"pretext": "pre-hello", "text": "text-world"}] // Optional // Structured message attachments. opt:unfurl_links // true // Optional // Pass true to enable unfurling of primarily text-based content. opt:unfurl_media // false // Optional // Pass false to disable unfurling of media content. opt:icon_url // http://lorempixel.com/48/48 // Optional // URL to an image to use as the icon for this message opt:icon_emoji // :chart_with_upwards_trend: // Optional // emoji to use as the icon for this message. Overridesicon_url

func (*Bot) Stop

func (bot *Bot) Stop() error

type Command

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

type IntervalCommand

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

type Listener

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

Jump to

Keyboard shortcuts

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