seras

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bots map[string]Bot
View Source
var DefaultConfig string

Functions

func AddBotParser

func AddBotParser(name string, parser BotParser) error

func ParseBots

func ParseBots(cfg *Config) error

func RunAll added in v0.5.0

func RunAll(createModsFor func(Bot) []Module) error

func RunBot

func RunBot(bot Bot) error

func SetField added in v0.5.0

func SetField(obj interface{}, name string, value interface{}) error

func Token

func Token() string

Types

type Actions

type Actions interface {
	Messenger
	MessageFormatter
	Admin
}

type Admin

type Admin interface {
	// IsAdmin TODO: Refactor to accept just an Author struct.
	IsAdmin(userId string) bool
	TimeoutUser(channel string, user string, until time.Time) error
}

type Author

type Author struct {
	Id   string // Host in IRC, User ID in Discord.
	Nick string

	// Mention is starting to turn into an important thing for plugins,
	// Refactor the name.
	// Maybe UniqueMention?
	Mention string // TODO: Refactor?, this is quick fix to get mentions working in Discord.
}

type BaseConnection added in v0.5.0

type BaseConnection struct {
	NAME   string `toml:"name"`
	Type   string
	Admins []string
	Mods   map[string]any
}

BaseConnection is a base template for Connections to use.

func (*BaseConnection) Name added in v0.5.0

func (c *BaseConnection) Name() string

func (*BaseConnection) SetName added in v0.5.0

func (c *BaseConnection) SetName(name string)

type Bot

type BotParser

type BotParser interface {
	Parse(map[string]any) (Bot, error)
}

BotParser intakes a map of config settings for a particular bot type.

type Config

type Config struct {
	Bots map[string]map[string]any
}

func ParseToml

func ParseToml(file string) (*Config, error)

type Connection

type Connection interface {
	Name() string
	// SetName TODO: Remove, anything can change it.
	SetName(string)
	Connect() (Stream, error)
	Close() error
}

type Message

type Message struct {
	Content   string
	Arguments []string
	Target    string
	Author    Author
	Code      string
	// Name of the Connection it came from.
	ConnectionName string
	// JSON for Discord, Raw for IRC.
	Raw       string
	Timestamp time.Time
}

func (*Message) Command

func (msg *Message) Command(command string, call func(Message))

func (*Message) IsCommand

func (msg *Message) IsCommand(command string) bool

type MessageFormatter

type MessageFormatter interface {
	Bold(string) string
	Italicize(string) string
}

type Messenger

type Messenger interface {
	Send(Message) error
	Reply(Message, string) error
}

type Modable

type Modable interface {
	Modules() []Module
	AddMods([]Module)
	// ModList [name]config
	ModList() map[string]interface{}
}

type Module

type Module interface {
	Name() string
	Start(Stream, Actions) error
	Stop()
}

type ModuleManager

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

func NewModManager

func NewModManager(mods []Module, actions Actions) (*ModuleManager, error)

func (*ModuleManager) Run

func (manager *ModuleManager) Run(stream Stream) error

func (*ModuleManager) Stop

func (manager *ModuleManager) Stop()

type NullMessenger

type NullMessenger struct{}

func (*NullMessenger) Send

func (messenger *NullMessenger) Send(msg Message) error

type Stream

type Stream <-chan Message

Directories

Path Synopsis
cmd
connections
irc
Package log is meant to be used by modules to log any important information or errors to be reviewed by the bot owner.
Package log is meant to be used by modules to log any important information or errors to be reviewed by the bot owner.
art
rss
sed
Package sed is a toy implementation of sed for making _real_ corrections only, no silly seds.
Package sed is a toy implementation of sed for making _real_ corrections only, no silly seds.

Jump to

Keyboard shortcuts

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