events

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package events provides management and structs for Eludris gateway events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Subscribe

func Subscribe[E Event](m EventManager, subscriber func(E, interfaces.Client))

Subscribe allows you to subscribe to an event to the given manager. This infers the event type from the function signature.

Types

type Event

type Event interface {
	Op() string
}

Event represents the base fields for all events.

type EventListener

type EventListener interface {
	Handle(Event, interfaces.Client)
	Op() string
	Func() func(Event, interfaces.Client)
}

type EventManager

type EventManager interface {
	Subscribe(EventListener)
	Dispatch(interfaces.Client, []byte)
}

EventManager manages events, allowing you to subscribe to them.

func NewEventManager

func NewEventManager() EventManager

NewEventManager creates a new event manager.

type MessageEvent

type MessageEvent struct {
	Content string `mapstructure:"content"`
	Author  string `mapstructure:"author"`
}

MessageEvent represents a received message from Eludris.

func (*MessageEvent) Op

func (*MessageEvent) Op() string

type PongEvent

type PongEvent struct{}

func (*PongEvent) Op

func (*PongEvent) Op() string

Jump to

Keyboard shortcuts

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