gobottas

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: MIT Imports: 3 Imported by: 0

README

gobottas

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command int

Enumeration of the basic types of commands that Gobottas supports

const (
	None Command = iota
	Error
	Unrecognized
	Help
	Meme
	Queue
)

func StrToCommand

func StrToCommand(s string) Command

Parse select strings into commands; note that there are several Commands that no string will parse into

func (Command) String

func (c Command) String() string

Get the string value associated with a command type

type Interceptor

type Interceptor func(*Message) error

Interceptors modify the message. Every interceptor is called on every message, most of the time this is a no-op

type Message

type Message struct {
	// Provided by the Parser
	Command Command  // Basic command type of the message
	Source  *Source  // Data from discord about the message origin
	Args    []string // parsed args (if there are any)
	Help    string

	// Initialized by Parser, Modified by Interceptors
	Response *Response
}

Every message that Gobottas sees is parsed into a Message and sent through the rest of the application

type Registry

type Registry interface {
	Parse(*discordgo.Message) (*Message, error)
	Intercept(*Message) error
	Execute(*Message, Session) error
}

type Response

type Response struct {
	ChannelId Snowflake
	Text      string
	Embed     *discordgo.MessageEmbed
}

type Session

type Session interface {
	ChannelMessageSend(channelId string, msg string) (*discordgo.Message, error)
	ChannelMessageSendEmbed(channelId string, embed *discordgo.MessageEmbed) (*discordgo.Message, error)
}

Session interfaces with the discordgo Session struct using only the relevant functions for Gobottas

type Snowflake

type Snowflake uint64

functions for Discord's unique id system

func ToSnowflake

func ToSnowflake(s string) (Snowflake, error)

func (Snowflake) String

func (s Snowflake) String() string

type Source

type Source struct {
	AuthorId  Snowflake // Unique id of sender
	Username  string    // Username (not including the number) of the sender
	ChannelId Snowflake // Unique id of channel
	Content   string    // Original content of the message
}

Data parsed from the original discord message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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