rbot

package
v0.0.0-...-93194af Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Session DiscordSession
	Handler *handler.Handler
	// contains filtered or unexported fields
}

The Bot struct holds all information needed to do any general work on the bot. It also contains a DropletManager struct to manage modules at a high level.

func NewBot

func NewBot(token string, conf *Config) (*Bot, error)

NewBot will create a new instance of a bot, almost everything will be initialized, but some things such as connecting to discord will not.

func (*Bot) Connect

func (b *Bot) Connect() error

Connect will call Open() on the discord session.

type Config

type Config struct {
	Name string
	// contains filtered or unexported fields
}

Config contains parsed information from a supplied YAML file. This file is provided via command line arguments.

func NewConfigFromFile

func NewConfigFromFile(filepath string) (*Config, error)

NewConfigFromFile returns an initialized config from a given file path.

func NewConfigFromString

func NewConfigFromString(confstring string) (*Config, error)

NewConfigFromString creates a config from a string using a YAML parser.

type DST

type DST struct {
	ID int
}

DST stands for DiscordSessionTest. It has mocked methods that are used within the bot's functions. The 'id' int for each struct is used to identify the structs. Positive IDs, starting with 0, represent properly working mocks. Negative IDs, starting with -1, represent intentionally broken mocks.

func (*DST) AddHandler

func (dst *DST) AddHandler(handler interface{}) func()

AddHandler mocks discordgo.Session.AddHandler()

func (*DST) ChannelMessageSend

func (dst *DST) ChannelMessageSend(channelID string,
	content string) (*discordgo.Message, error)

func (*DST) Open

func (dst *DST) Open() (err error)

Open mocks discordgo.Session.Open().

func (*DST) User

func (dst *DST) User(userID string) (*discordgo.User, error)

type DiscordSession

type DiscordSession interface {
	AddHandler(handler interface{}) func()
	Open() (err error)
	ChannelMessageSend(channelID string, content string) (*discordgo.Message, error)
	User(userID string) (*discordgo.User, error)
}

DiscordSession is an interface to specify discord session capability. It is implemented mostly for testing of the bot (so that mocks can be created for the discord session struct from bwmarrin's discordgo).

Jump to

Keyboard shortcuts

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