dispatcher

package
v21.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ETFPayloadToMessage

func ETFPayloadToMessage(ctx context.Context, ep ETFPayload) (wsapi.WSMessage, error)

ETFPayloadToMessage converts a specialized etf payload to a websocket message

Types

type DispatchHandlerFunc

type DispatchHandlerFunc = func(Payload, wsapi.WSMessage, chan<- wsapi.WSMessage) snowflake.Snowflake

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

type Dispatcher

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

func NewDispatcher

func NewDispatcher(deps dependencies) *Dispatcher

NewDispatcher creates a new Dispatcher object with default state and session management handlers installed

func (*Dispatcher) AddHandler

func (c *Dispatcher) AddHandler(event string, handler DispatchHandlerFunc)

func (*Dispatcher) ConnectToBot

func (c *Dispatcher) ConnectToBot(b *bot.DiscordBot)

func (*Dispatcher) GenerateHeartbeat

func (c *Dispatcher) GenerateHeartbeat(reqCtx context.Context, seqNum int) (wsapi.WSMessage, error)

func (*Dispatcher) HandleRequest

func (c *Dispatcher) HandleRequest(req wsapi.WSMessage, resp chan<- wsapi.WSMessage) snowflake.Snowflake

func (*Dispatcher) SetDebug

func (c *Dispatcher) SetDebug(val bool)

type ETFPayload

type ETFPayload interface {
	Payload() (etfapi.Payload, error)
}

ETFPayload is the interface that a specialized etf api payload conforms to

type Logger

type Logger = interface {
	Log(keyvals ...interface{}) error
	Message(string, ...interface{})
	Err(string, error, ...interface{})
	Printf(string, ...interface{})
}

type Message

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

Message represents the data about a message in a discord channel

func MessageFromElement

func MessageFromElement(e etfapi.Element) (Message, error)

MessageFromElement generates a new Message object from the given Element

func MessageFromElementMap

func MessageFromElementMap(eMap map[string]etfapi.Element) (Message, error)

MessageFromElementMap generates a new Message object from the given data

func (*Message) AuthorID

func (m *Message) AuthorID() snowflake.Snowflake

AuthorID returns the ID of the author of the message

func (*Message) ChannelID

func (m *Message) ChannelID() snowflake.Snowflake

ChannelID returns the ID of the channel the message was sent to

func (*Message) ContentString

func (m *Message) ContentString() string

ContentString returns the content of the message

func (*Message) ID

func (m *Message) ID() snowflake.Snowflake

ID returns the ID of the message

func (*Message) MessageType

func (m *Message) MessageType() MessageType

MessageType returns the MessageType of the message

type MessageType

type MessageType int

MessageType represents the type of message received in a discord channel

const (
	DefaultMessage              MessageType = 0
	RecipientAddMessage         MessageType = 1
	RecipientRemoveMessage      MessageType = 2
	CallMessage                 MessageType = 3
	ChannelNameChangeMessage    MessageType = 4
	ChannelIconChangeMessage    MessageType = 5
	ChannelPinnedMessageMessage MessageType = 6
	GuildMemberJoinMessage      MessageType = 7
)

These are the known message types

func MessageTypeFromElement

func MessageTypeFromElement(e etfapi.Element) (MessageType, error)

MessageTypeFromElement generates a MessageType representation from the given message-type Element

func (MessageType) String

func (t MessageType) String() string

type Payload

type Payload = interface {
	EventName() string
	Contents() map[string]etfapi.Element
}

type Reaction

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

Message represents the data about a message in a discord channel

func ReactionFromElement

func ReactionFromElement(e etfapi.Element) (Reaction, error)

ReactionFromElement generates a new Reaction object from the given Element

func ReactionFromElementMap

func ReactionFromElementMap(eMap map[string]etfapi.Element) (Reaction, error)

ReactionFromElementMap generates a new Reaction object from the given data

func (*Reaction) ChannelID

func (r *Reaction) ChannelID() snowflake.Snowflake

ChannelID returns the ID of the channel the reaction was to

func (*Reaction) Emoji

func (r *Reaction) Emoji() string

Emoji returns the emoji of the reaction ChannelID returns the ID of the channel the reaction was to

func (*Reaction) GuildID

func (r *Reaction) GuildID() snowflake.Snowflake

GuildID returns the ID of the guild the reaction was to

func (*Reaction) MessageID

func (r *Reaction) MessageID() snowflake.Snowflake

MessageID returns the ID of the message the reaction was to

func (*Reaction) UserID

func (r *Reaction) UserID() snowflake.Snowflake

UserID returns the ID of the reactor

type User

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

User represents the data about a discord user

func UserFromElement

func UserFromElement(e etfapi.Element) (User, error)

UserFromElement generates a new User object from the given Element

func (*User) UpdateFromElementMap

func (u *User) UpdateFromElementMap(eMap map[string]etfapi.Element) error

UpdateFromElementMap updates the information about a user from the given data

This will not remove information, only change and add information

Jump to

Keyboard shortcuts

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