bot

package
v6.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResponse = errors.New("error response")

ErrResponse is the error that is wrapped and returned when there is a non-200 api response

Functions

This section is empty.

Types

type BotConfig

type BotConfig struct {
	ClientID     string
	ClientSecret string
	BotToken     string
	APIURL       string
	NumWorkers   int

	OS          string
	BotName     string
	BotPresence string
}

BotConfig is the set of configuration options for creating a DiscordBot with NewDiscordBot

type DiscordBot

type DiscordBot interface {
	AuthenticateAndConnect() error
	Disconnect() error
	Run(context.Context) error
	AddMessageHandler(event string, handler DiscordMessageHandlerFunc)
	SendMessage(context.Context, snowflake.Snowflake, json.Marshaler) (*http.Response, []byte, error)
	UpdateSequence(int) bool
	ReconfigureHeartbeat(context.Context, int)
	LastSequence() int
	Config() BotConfig
}

DiscordBot is the api for a discord bot object

func NewDiscordBot

func NewDiscordBot(deps dependencies, conf BotConfig) DiscordBot

NewDiscordBot creates a new DiscordBot

type DiscordMessageHandler

type DiscordMessageHandler interface {
	ConnectToBot(DiscordBot)
	AddHandler(string, DiscordMessageHandlerFunc)
	HandleRequest(wsclient.WSMessage, chan<- wsclient.WSMessage)
}

DiscordMessageHandler is the api that a bot expects a handler manager to have

type DiscordMessageHandlerFunc

type DiscordMessageHandlerFunc func(*etfapi.Payload, wsclient.WSMessage, chan<- wsclient.WSMessage)

DiscordMessageHandlerFunc is the api that a bot expects a handler function to have

Jump to

Keyboard shortcuts

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