irc

package module
v0.0.0-...-04d8d34 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2013 License: BSD-2-Clause Imports: 8 Imported by: 1

README

go-irc

A Go IRC protocol package.

Documentation

Overview

Package irc provides a IRC client, implementing IRC protocol, for communicating with an IRC server.

Index

Constants

View Source
const (
	NICK    = "NICK"
	USER    = "USER"
	PASS    = "PASS"
	JOIN    = "JOIN"
	PART    = "PART"
	QUIT    = "QUIT"
	NOTICE  = "NOTICE"
	PRIVMSG = "PRIVMSG"
	PING    = "PING"
	PONG    = "PONG"
	TIME    = "TIME"
	MODE    = "MODE"
	ERROR   = "ERROR"
	VERSION = "VERSION"

	CLIENTINFO      = "CLIENTINFO"
	USERINFO        = "USERINFO"
	CTCP            = "CTCP"
	CTCP_VERSION    = "CTCP_VERSION"
	CTCP_TIME       = "CTCP_TIME"
	CTCP_PING       = "CTCP_PING"
	CTCP_USERINFO   = "CTCP_USERINFO"
	CTCP_CLIENTINFO = "CTCP_CLIENTINFO"

	RPL_WELCOME       = "001"
	RPL_YOURHOST      = "002"
	RPL_CREATED       = "003"
	RPL_MYINFO        = "004"
	RPL_ISUPPORT      = "005"
	RPL_STATSCONN     = "250"
	RPL_LUSERCLIENT   = "251"
	RPL_LUSEROP       = "252"
	RPL_LUSERUNKNOWN  = "253"
	RPL_LUSERCHANNELS = "254"
	RPL_LUSERME       = "255"
	RPL_LOCALUSERS    = "265"
	RPL_GLOBALUSERS   = "266"
	RPL_TOPIC         = "332"
	RPL_NAMREPLY      = "353"
	RPL_ENDOFNAMES    = "366"
	RPL_MOTD          = "372"
	RPL_MOTDSTART     = "375"
	RPL_ENDOFMOTD     = "376"

	ERR_NICKNAMEINUSE = "433"
	ERR_BANNICKCHANGE = "437"
)
View Source
const (
	IRC_VERSION = "go-irc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Password  string
	TLSConfig *tls.Config

	DefaultHandler func(*Event)
	// contains filtered or unexported fields
}

func NewClient

func NewClient(nick, username string) *Client

NewClient creates a new Client instance, disconnected.

func (*Client) Command

func (c *Client) Command(code string, message string, params ...string)

func (*Client) Dial

func (c *Client) Dial(server string) (err error)

Dial connects to the server and starts the Client

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect sends all buffered messages (if possible), stops all goroutines and then closes the socket.

func (*Client) Join

func (c *Client) Join(channels ...string)

func (*Client) Nick

func (c *Client) Nick() string

Nick returns the current used nickname.

func (*Client) Notice

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

func (*Client) Noticef

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

func (*Client) Part

func (c *Client) Part(channels ...string)

func (*Client) Ping

func (c *Client) Ping()

Ping sends a Ping command to IRC server.

func (*Client) Privmsg

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

func (*Client) Privmsgf

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

func (*Client) Quit

func (c *Client) Quit()

func (*Client) Raw

func (c *Client) Raw(message string)

func (*Client) Rawf

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

func (*Client) Serve

func (c *Client) Serve() error

func (*Client) SetHandler

func (c *Client) SetHandler(code string, handler func(*Event))

func (*Client) SetNick

func (c *Client) SetNick(nick string)

SetNick sets the nickname expected to be used in the channel. According to IRC protocol, the nickname specified may be not accepted by the server. Call Client.Nick() to get the current used nickname.

func (*Client) Start

func (c *Client) Start(socket net.Conn)

Starts bind a connected socket(net.Conn) to the Client

type Event

type Event struct {
	Raw string // raw message line received. contains all of the following information

	Source string // <nick>!<usr>@<host>
	Nick   string // <nick>
	User   string // <usr>
	Host   string // <host>

	Code      string   // PING/PONG ...
	Arguments []string // arguments to Code

	Message string // message after " :"
}

Jump to

Keyboard shortcuts

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