flockerbot

package module
v0.0.0-...-cb5804f Latest Latest
Warning

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

Go to latest
Published: May 23, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

README

flockerbot

Flockerbot implements a simple IRC bot in golang

based on github.com/sorcix/irc

Documentation

Overview

Package flockerbot implements a simple IRC bot. To use it, populate a Bot struct and call Connect() on it. To send messages, use the SendString and SendStruct methods. For receiving messages, make sure the handler field is set. The handler function will be called on reception of messages, with the message struct as the parameter.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout signals timeout
	ErrTimeout = errors.New("Bot: Timeout")
)

Functions

This section is empty.

Types

type Bot

type Bot struct {
	ConnectAddress string // where to connect to. IP:Port.
	User           string // Username for USER command.
	Nick           string // Nickname for NICK command.
	Password       string // Password for authentication. If empty, no authentication will be used.
	IsServer       bool   // Register as server, not client. User field is used as the server name.
	Timeout        int64  // Connect and ping timeout.
	TLS            bool   // connect via TLS

	Handler          func(msg *irc.Message) // Handler for messages. The handler will not be called for PING, 001 and 443 messages.
	ConnectedHandler func()                 // Handler that is called on connect

	ErrChan chan error // Channel to send errors to
	// contains filtered or unexported fields
}

Bot implements the bot

func (*Bot) Connect

func (b *Bot) Connect() (err, loopError error)

Connect the bot and go into main loop.

func (*Bot) Connected

func (b *Bot) Connected() bool

Connected returns true if the connection was successful.

func (*Bot) CurrentNick

func (b *Bot) CurrentNick() string

CurrentNick returns the actual nick of the connection.

func (*Bot) Disconnect

func (b *Bot) Disconnect() error

Disconnect the bot.

func (*Bot) Error

func (b *Bot) Error() error

Error returns the last error generated by Connect. To be used in goroutine scenarios.

func (*Bot) ReplyTo

func (b *Bot) ReplyTo(msg *irc.Message) string

ReplyTo returns a string containing where to reply to.

func (*Bot) SendString

func (b *Bot) SendString(msg string)

SendString sends a string.

func (*Bot) SendStruct

func (b *Bot) SendStruct(msg *irc.Message)

SendStruct sends a message.

func (*Bot) SetAutoReconnect

func (b *Bot) SetAutoReconnect(v bool)

SetAutoReconnect value

func (*Bot) Setup

func (b *Bot) Setup()

Setup prepares the bot

func (*Bot) StayConnected

func (b *Bot) StayConnected() error

StayConnected keeps the bot connected

Directories

Path Synopsis
Package fixbuffer implements a buffered reader over a fixed size buffer
Package fixbuffer implements a buffered reader over a fixed size buffer
Package ringbuffer implements ringbuffer calculations.
Package ringbuffer implements ringbuffer calculations.

Jump to

Keyboard shortcuts

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