Documentation
¶
Overview ¶
Package bottom is an IRC Bot mini-framework (for want of a better word)
It sets up different message handlers for different messages, has the concept of middlewares, and exposes everything underneath for when you need just a little more control.
Everything is pretty intuitive, but the examples directory will get you where you need to go.
It also makes a series of assumptions, such as SASL, and so may not be right for lots of projects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bottom ¶
type Bottom struct {
Middlewares *Middlewares
Client *girc.Client
ErrorFunc func(Context, error)
// The following are extra tunables which are not
// passed in via args, partially for backwards
// compatability reasons, but part because the defaults
// are sane enough- setting them is not compulsary
AutoAcceptInvites bool
// contains filtered or unexported fields
}
Bottom is the transport logic for an IRC Bot
It handles things like routing messages and error handling
func New ¶
New accepts some connection parameters, initialises an IRC client, and sets up an empty Middlewares list, and a default ErrorFunc
It will error for malformed server addresses. The form it expects is:
[irc|ircs]://hostname:port
So:
- `irc://irc.example.com:6667`
- `ircs://irc.example.com:6697`
Are valid, whereas
- `irc.example.com`
Is not.
type Context ¶
type Context map[string]interface{}
Context holds key/value pairs for the current irc event like `sender`, or `message`
Because this is a map of strings to interface, you will need to typecast whatever comes back
type Middleware ¶
Middleware provides a way of handling different events in different ways, such as gating certain commands
type Middlewares ¶
type Middlewares []Middleware
Middlewares holds a set of Middleware implementations, providing a set of ways to manipulate insertions
func NewMiddlewares ¶
func NewMiddlewares() *Middlewares
NewMiddlewares returns an empty set of Middlewares
func (*Middlewares) Push ¶
func (m *Middlewares) Push(nm Middleware)
Push puts a new Middleware implementation to the back of Middlewares
func (*Middlewares) Unshift ¶
func (m *Middlewares) Unshift(nm Middleware)
Unshift puts a new Middleware implementation to the front of Middlewares
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a Middleware implementation, containing routing logic for different Events.
These events are pattern matched to a specific RouterFunc
func NewRouter ¶
func NewRouter() *Router
NewRouter returns a new, empty Router, with no routes setup
func (*Router) AddRoute ¶
func (r *Router) AddRoute(pattern string, f RouterFunc) (err error)
AddRoute configures a RouterFunc to run when a certain route pattern matches.
If many patterns match, the first pattern wins If the pattern contains groups, then these are passed as the second arg to RouterFunc
type RouterFunc ¶
RouterFunc is used in routing events
Functions should expect the following information:
- sender - the nick of the author of the message
- channel - the channel the message was sent in (if sender == channel, then assume a private message)
- groups - any regexp groups extracted from the message. groups[0] is *always* the full message