bot

package module
v0.0.0-...-531fd89 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2017 License: MIT Imports: 8 Imported by: 0

README

gopher-bot

gopher-bot is a slack bot written in Golang.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

A Bot represents a bot client.

func New

func New(token string) *Bot

New creates a new Bot.

func (*Bot) AddPlugin

func (b *Bot) AddPlugin(p Plugin)

AddPlugin adds the plugin p to the bot.

func (*Bot) AddReaction

func (b *Bot) AddReaction(name, channel, timestamp string) error

AddReaction adds a reaction to the message.

func (*Bot) BotID

func (b *Bot) BotID() string

BotID retrieves bot user id.

func (*Bot) DoActionPlugins

func (b *Bot) DoActionPlugins(event EventInfo) bool

DoActionPlugins calls DoAction of plugins.

func (*Bot) GetClient

func (b *Bot) GetClient() *slack.Client

GetClient returns *slack.Client.

func (*Bot) PostMessage

func (b *Bot) PostMessage(text, channel string)

PostMessage posts the text to the channnel.

func (*Bot) PostMessageToThread

func (b *Bot) PostMessageToThread(text, channel, ts string)

PostMessageToThread posts the text to the channnel.

func (*Bot) ReplyMessage

func (b *Bot) ReplyMessage(text, user, channel string)

ReplyMessage replies the text to the user.

func (*Bot) ReplyMessageToThread

func (b *Bot) ReplyMessageToThread(text, user, channel, ts string)

ReplyMessageToThread replies the text to the user.

func (*Bot) SetLogger

func (b *Bot) SetLogger(l *log.Logger)

SetLogger sets the logger l to the bot.

func (*Bot) Start

func (b *Bot) Start()

Start starts the bot.

func (*Bot) Stop

func (b *Bot) Stop()

Stop stops the bot.

type BotInfo

type BotInfo interface {
	DoActionPlugins(event EventInfo) bool
	BotID() string
	PostMessage(text, channel string)
	PostMessageToThread(text, channel, ts string)
	ReplyMessage(text, user, channel string)
	AddReaction(name, channel, timestamp string) error
	GetClient() *slack.Client
}

A BotInfo represents bot information.

type EventInfo

type EventInfo interface {
	Channel() string
	BotID() string
	Text() string
	User() string
	Username() string
	ReplyTo() []string
	PostMessage(string)
	ReplyMessage(string, string)
	AddReaction(name string) error
}

A EventInfo represents an event of a received message.

type Plugin

type Plugin interface {
	Hello(BotInfo)
	DoAction(EventInfo) bool
	Help() string
}

A Plugin does an action on the received message.

Jump to

Keyboard shortcuts

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