dulbecco

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2014 License: BSD-2-Clause Imports: 21 Imported by: 0

README

dulbecco

ANOTHER IRC bot.

Credits

Contains a lot of code copied or inspired by go-ircevent by Thomas Jager mail@jager.no and goirc.

Documentation

Index

Constants

View Source
const (
	NickservName = "nickserv"

	// IRC defines a maximum "line" length of 512 characters, including \r\n,
	// the command and all parameters. On Azzurra the limit seems to be lower...
	MaximumCommandLength = 460

	SleepBetweenReconnects = time.Minute * 5
)

the number of *Loop() methods on Connection; it's used for synchronization and must be updated accordingly.

Variables

View Source
var (
	ErrInvalidServerLine = errors.New("Invalid server line: wrong number of tokens")

	CTCPChar = "\001"
)

Functions

This section is empty.

Types

type CallbackMap added in v0.2.0

type CallbackMap map[string]map[string]IRCCallback

type Channel

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

type Configuration

type Configuration struct {
	Servers []ServerConfiguration
	Plugins []PluginConfiguration
}

func ReadConfig

func ReadConfig(filename string) *Configuration

type Connection

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

A connection to the IRC server, also the main data structure of the IRC bot.

func NewConnection

func NewConnection(config ServerConfiguration, botConfig *Configuration, mdb *markov.MarkovDB) *Connection

func (*Connection) Action

func (c *Connection) Action(target, message string)

ACTION command

func (*Connection) AddCallback

func (c *Connection) AddCallback(name string, callback IRCCallback) string

func (*Connection) Connect

func (c *Connection) Connect() (err error)

Connect to the server, launch all internal goroutines.

func (*Connection) Ctcp

func (c *Connection) Ctcp(target, args string)

CTCP

func (*Connection) CtcpReply

func (c *Connection) CtcpReply(target, args string)

CTCP replies

func (*Connection) GetTopic

func (c *Connection) GetTopic(channel string)

func (*Connection) Invite

func (c *Connection) Invite(nickname, channel string)

INVITE command

func (*Connection) Join

func (c *Connection) Join(channel string)

JOIN command

func (*Connection) JoinChannels

func (c *Connection) JoinChannels()

func (*Connection) Kick

func (c *Connection) Kick(channel, nickname, reason string)

KICK command

func (*Connection) LoginNickserv

func (c *Connection) LoginNickserv()

IDENTIFY to NickServ

func (*Connection) MainLoop

func (c *Connection) MainLoop()

func (*Connection) Mode

func (c *Connection) Mode(target string, modes ...string)

Get or set MODE

func (*Connection) Names

func (c *Connection) Names(target string)

NAMES

func (*Connection) Nick

func (c *Connection) Nick(nickname string)

NICK command

func (*Connection) Notice

func (c *Connection) Notice(target, message string)

NOTICE command

func (*Connection) Noticef

func (c *Connection) Noticef(target, format string, a ...interface{})

func (*Connection) Part

func (c *Connection) Part(channel string, message ...string)

PART command

optional argument: the part message

func (*Connection) Pass

func (c *Connection) Pass(password string)

PASS command

func (*Connection) Privmsg

func (c *Connection) Privmsg(target, message string)

PRIVMSG command

func (*Connection) Privmsgf

func (c *Connection) Privmsgf(target, format string, a ...interface{})

PRIVMSG with format string

func (*Connection) Quit

func (c *Connection) Quit(message ...string)

QUIT command

optional argument: quit message

func (*Connection) Raw

func (c *Connection) Raw(s string)

send a "raw" line to the server

func (*Connection) Rawf

func (c *Connection) Rawf(format string, a ...interface{})

send a "raw" formatted line to the server

func (*Connection) RemoveCallback

func (c *Connection) RemoveCallback(name string, id string) bool

func (*Connection) RunCallbacks

func (c *Connection) RunCallbacks(message *Message)

Execute registered callbacks for message

func (*Connection) ServerPing

func (c *Connection) ServerPing()

send a PING to the server

func (*Connection) SetTopic

func (c *Connection) SetTopic(channel, topic string)

func (*Connection) SetupCallbacks

func (c *Connection) SetupCallbacks()

Add internal callbacks.

func (*Connection) SetupPlugins

func (c *Connection) SetupPlugins(plugins []PluginConfiguration)

Add callbacks for every configured plugin.

func (*Connection) Shutdown

func (c *Connection) Shutdown()

func (*Connection) User

func (c *Connection) User(ident, realname string)

USER command http://tools.ietf.org/html/rfc2812#section-3.1.3

Parameters: <user> <mode> <unused> <realname>

func (*Connection) Who

func (c *Connection) Who(target string)

WHO

func (*Connection) Whois

func (c *Connection) Whois(nickname string)

WHOIS

type IRCCallback added in v0.2.0

type IRCCallback func(message *Message)

type Message

type Message struct {
	Ident, Nick, Host, Src string

	Cmd, Raw string
	Args     []string
	Time     time.Time
}

Each line from the IRC server is parsed into a Message struct.

Src => "irc.example.com" or "nick!ident@host"
Raw => "nick!ident@host PRIVMSG #channel :hello world"

func (*Message) Dump

func (m *Message) Dump() string

func (*Message) IsFromChannel

func (m *Message) IsFromChannel() bool

Returns true if the Message generated inside a IRC channel

Channel types: https://www.alien.net.au/irc/chantypes.html

func (*Message) ReplyTarget

func (m *Message) ReplyTarget() string

Returns a channel name when the message was sent to a public channel or a nickname when the message was sent privately.

type PluginConfiguration

type PluginConfiguration struct {
	Name    string
	Command string
	Trigger string
}

type ServerConfiguration

type ServerConfiguration struct {
	Name         string
	Address      string
	Ssl          bool
	Channels     []string
	Nickname     string
	Altnicknames []string
	Username     string
	Realname     string
	Password     string
	Nickserv     string
}

type User

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

func NewUser

func NewUser(nickname string) *User

Directories

Path Synopsis
cmd
dulbecco command
quotes-plugin command

Jump to

Keyboard shortcuts

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