ircd

package
v0.0.0-...-92fb79e Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2016 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CNick = iota
	CUser
	CReal
	CHost
)

delete me

View Source
const (
	ModeQuery = iota
	ModeAdd
	ModeDel
)

Variables

This section is empty.

Functions

func ErrorParams

func ErrorParams(server string, c Client, cmd string)

ErrorParams sends an error to a client indicating more parameters are required for a command.

func Errorf

func Errorf(c Client, format string, args ...interface{})

func HandleJoin

func HandleJoin(s Server, c Client, m parser.Message) error

JOIN

func HandleList

func HandleList(s Server, c Client, m parser.Message) error

LIST

func HandleMode

func HandleMode(s Server, c Client, m parser.Message) error

Change modes.

TODO(mischief): check for user/chan modes when channels are implemented

func HandleNick

func HandleNick(s Server, c Client, m parser.Message) error

NICK

func HandlePart

func HandlePart(s Server, c Client, m parser.Message) error

PART

func HandlePing

func HandlePing(s Server, c Client, m parser.Message) error

PING

func HandlePrivmsg

func HandlePrivmsg(s Server, c Client, m parser.Message) error

PRIVMSG

func HandleQuit

func HandleQuit(s Server, c Client, m parser.Message) error

QUIT

func HandleTopic

func HandleTopic(s Server, c Client, m parser.Message) error

TOPIC

func HandleUser

func HandleUser(s Server, c Client, m parser.Message) error

USER

func HandleWho

func HandleWho(s Server, c Client, m parser.Message) error

WHO

reply format: "<channel> <user> <host> <server> <nick> ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] :<hopcount> <real name>" */

func NewClient

func NewClient(srv Server, c net.Conn) *ircClient

Allocate a new Client

func Numeric

func Numeric(server string, c Client, code string, msg ...string)

func Privmsg

func Privmsg(to, from Client, msg string) error

func SplitPrefix

func SplitPrefix(prefix string) (nick, user, host string)

Types

type Channel

type Channel interface {
	Name() string
	Join(c Client) error
	Part(c Client) error
	Close() error
	Users() []Client
	Topic() string
	SetTopic(topic string) string
	Send(prefix, command string, args ...string) error // send a message to the client
}

func NewChannel

func NewChannel(srv Server, srvname, name string) Channel

Create a new channel

type Client

type Client interface {
	Nick() string // e.g. "foo"
	SetNick(nick string) string
	User() string // e.g. "foo"
	SetUser(user string) string
	Real() string // e.g. "Billy Joe Foo"
	SetReal(realname string) string
	Host() string                                      // e.g. "127.0.0.1"
	Prefix() string                                    // e.g., "foo!foo@127.0.0.1"
	Send(prefix, command string, args ...string) error // send a message to the client
	Join(c Channel)                                    // join user to channel
	Part(c Channel)                                    // part user from channel
	Channels() []Channel                               // list of channels user is in
}

type Config

type Config struct {
	Hostname string
	Listener net.Listener
}

type Ircd

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

func New

func New(conf Config) *Ircd

func (*Ircd) AddChannel

func (i *Ircd) AddChannel(ch Channel)

func (*Ircd) AddClient

func (i *Ircd) AddClient(c Client) error

func (*Ircd) Channels

func (i *Ircd) Channels() map[string]Channel

func (*Ircd) DoMotd

func (i *Ircd) DoMotd(c Client)

func (*Ircd) FindByNick

func (i *Ircd) FindByNick(nick string) Client

func (*Ircd) FindChannel

func (i *Ircd) FindChannel(name string) Channel

func (*Ircd) Handle

func (i *Ircd) Handle(c Client, m parser.Message) error

func (*Ircd) Name

func (i *Ircd) Name() string

func (*Ircd) Privmsg

func (i *Ircd) Privmsg(from Client, to, msg string) error

Send a PRIVMSG from Client to channel or another client by name

func (*Ircd) RemoveClient

func (i *Ircd) RemoveClient(c Client) error

func (*Ircd) Serve

func (i *Ircd) Serve() (err error)

Accept connections and serve clients until an error or a call to Stop occurs.

func (*Ircd) Stop

func (i *Ircd) Stop() error

Stop the irc server.

type MessageHandler

type MessageHandler func(s Server, c Client, m parser.Message) error

type Modeset

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

A mode set.

func NewModeset

func NewModeset() *Modeset

func (*Modeset) Clear

func (m *Modeset) Clear(r rune) (old string)

func (*Modeset) Get

func (m *Modeset) Get(r rune) (val string, ok bool)

func (*Modeset) GetString

func (m *Modeset) GetString() (modes, params string)

Get a string like +lL 10,#overflow for a channel or like +iwx for a user todo: add params

func (*Modeset) Set

func (m *Modeset) Set(r rune, val string) (old string)

type Server

type Server interface {
	Name() string
	AddClient(c Client) error
	RemoveClient(c Client) error
	Handle(c Client, m parser.Message) error

	Channels() map[string]Channel
	FindChannel(ch string) Channel
	AddChannel(ch Channel)

	FindByNick(nick string) Client
	Privmsg(from Client, to, msg string) error
}

Jump to

Keyboard shortcuts

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