oodle

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUsage = errors.New("Wrong command usage")

Functions

This section is empty.

Types

type BaseTrigger

type BaseTrigger struct {
	IRC IRCClient
}

BaseTrigger is just an implementation of Trigger to reduce some boilerplate code

func (*BaseTrigger) OnEvent added in v0.7.2

func (btrigger *BaseTrigger) OnEvent(msg interface{})

func (*BaseTrigger) SetIRC added in v0.7.2

func (btrigger *BaseTrigger) SetIRC(irc IRCClient)

type Bot

type Bot interface {
	RegisterTrigger(trigger Trigger)
	RegisterCommand(command Command)
}

type Command

type Command interface {
	Info() CommandInfo
	Execute(nick string, args []string) (reply string, err error)
}

Command is like a pure function just inputs and outputs

type CommandInfo

type CommandInfo struct {
	Prefix      string
	Name        string
	Description string
	Usage       string
}

CommandInfo contains information of a command

type Config

type Config struct {
	Nick        string     `toml:"nick"`
	Name        string     `toml:"name"`
	User        string     `toml:"user"`
	Server      string     `toml:"server"`
	Port        int        `toml:"port"`
	Channel     string     `toml:"channel"`
	Retry       bool       `toml:"retry"`
	SASLUser    string     `toml:"sasl_user"`
	SASLPass    string     `toml:"sasl_pass"`
	DBPath      string     `toml:"dbpath"`
	WebHookAddr string     `toml:"webhook_addr"`
	Secret      string     `toml:"secret"`
	Commands    []string   `toml:"commands"`
	Points      []int      `toml:"points"`
	Cooldowns   []Duration `toml:"cooldowns"`
}

type Duration added in v0.6.0

type Duration struct {
	time.Duration
}

func (*Duration) UnmarshalText added in v0.6.0

func (d *Duration) UnmarshalText(text []byte) error

type IRCClient added in v0.7.2

type IRCClient interface {
	InChannel(nick string) bool
	Send(message string)
	Sendf(format string, a ...interface{})
}

type Join

type Join struct {
	Nick string
}

type Leave

type Leave struct {
	Nick string
}

type Message

type Message struct {
	Nick string
	Msg  string
}

Simpified IRC events

type Stateful added in v0.2.0

type Stateful interface {
	Init(config *Config, db *gorm.DB)
}

type Trigger

type Trigger interface {
	SetIRC(irc IRCClient)
	OnEvent(event interface{})
}

Trigger can listen for a event and get triggered and send messages via. the send queue

Jump to

Keyboard shortcuts

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