gircclient

package
v0.0.0-...-f5e0f87 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: ISC Imports: 13 Imported by: 0

Documentation

Overview

Package gircclient is an IRC client library.

It uses the other various gIRC-Go libraries to provide a clean, consistent interface for connecting to and interacting with IRC servers.

The Reactor is the primary handler of all new clients.

This package is in planning/pre-alpha and the API will change substantially.

Index

Constants

This section is empty.

Variables

View Source
var EventTransforms = map[string]EventTransform{
	"RPL_WELCOME": {
		StringParams: map[int]string{
			1: "message",
		},
	},
}

EventTransforms holds the set of event transformations we apply when simplifying given events.

View Source
var Numerics = map[int]string{}/* 288 elements not displayed */

Numerics is a map of IRC numerics to names. Taken from http://defs.ircdocs.horse/defs/ircnumerics.html

Functions

func SimplifyEvent

func SimplifyEvent(e eventmgr.InfoMap) error

SimplifyEvent simplifies the given event in-place. This includes better argument names, convenience attributes, and native objects instead of strings where appropriate.

Types

type ClientCapabilities

type ClientCapabilities struct {
	Available map[string]*string
	Enabled   map[string]bool
	Wanted    []string
}

ClientCapabilities holds the capabilities that can and have been enabled on a ServerConnection.

func NewClientCapabilities

func NewClientCapabilities() ClientCapabilities

NewClientCapabilities returns a newly-initialised ClientCapabilities.

func (*ClientCapabilities) AddCaps

func (cc *ClientCapabilities) AddCaps(tags ...string)

AddCaps adds capabilities from LS lists to our Available map.

func (*ClientCapabilities) AddWantedCaps

func (cc *ClientCapabilities) AddWantedCaps(caps ...string)

AddWantedCaps adds the given capabilities to our list of capabilities that we want from the server.

func (*ClientCapabilities) DelCaps

func (cc *ClientCapabilities) DelCaps(caps ...string)

DelCaps removes the given capabilities.

func (*ClientCapabilities) EnableCaps

func (cc *ClientCapabilities) EnableCaps(caps ...string)

EnableCaps enables the given capabilities.

func (*ClientCapabilities) ToRequestLine

func (cc *ClientCapabilities) ToRequestLine() string

ToRequestLine returns a line of capabilities to request, to be used in a CAP REQ line.

type EventTransform

type EventTransform struct {
	// StringParams maps the given parameter (int) to the given key in the
	// InfoMap as a string.
	StringParams map[int]string
	// IntParams maps the given parameter (int) to the given key in the InfoMap
	// as an integer.
	IntParams map[int]string
}

EventTransform holds a set of event transformations that should take place when simplifying the given event.

type Reactor

type Reactor struct {
	ServerConnections map[string]*ServerConnection
	// contains filtered or unexported fields
}

Reactor is the start-point for gircclient. It creates and manages ServerConnections.

func NewReactor

func NewReactor() Reactor

NewReactor returns a new, empty Reactor.

func (*Reactor) CreateServer

func (r *Reactor) CreateServer(name string) *ServerConnection

CreateServer creates a ServerConnection and returns it.

func (*Reactor) RegisterEvent

func (r *Reactor) RegisterEvent(direction string, name string, handler eventmgr.HandlerFn, priority int)

RegisterEvent registers an event with all current and new ServerConnections.

func (*Reactor) Shutdown

func (r *Reactor) Shutdown(message string)

Shutdown shuts down all ServerConnections.

type ServerConnection

type ServerConnection struct {
	Name            string
	Connected       bool
	Registered      bool
	Casemapping     ircmap.MappingType
	CommandPrefixes []string

	// internal stuff
	RawConnection net.Conn

	// data we keep track of
	Features ServerFeatures
	Caps     ClientCapabilities

	// details users must supply before connection
	Nick          string
	InitialNick   string
	FallbackNicks []string

	InitialUser     string
	InitialRealName string
	ConnectionPass  string

	// options
	SimplifyEvents bool
	// contains filtered or unexported fields
}

ServerConnection is a connection to a single server.

func (*ServerConnection) Casefold

func (sc *ServerConnection) Casefold(message string) (string, error)

Casefold folds the given string using the server's casemapping.

func (*ServerConnection) Connect

func (sc *ServerConnection) Connect(address string, ssl bool, tlsconfig *tls.Config) error

Connect connects to the given address.

func (*ServerConnection) Disconnect

func (sc *ServerConnection) Disconnect()

Disconnect closes the IRC socket. It is used when writing your own event loop.

func (*ServerConnection) IsChannel

func (sc *ServerConnection) IsChannel(target string) bool

IsChannel returns true if the given target is a channel.

func (*ServerConnection) JoinChannel

func (sc *ServerConnection) JoinChannel(name string, key string, useKey bool)

JoinChannel joins a channel, or marks the channel as to be joined after registration.

func (*ServerConnection) Msg

func (sc *ServerConnection) Msg(tags map[string]string, target string, message string, escaped bool)

Msg sends a message to the given target.

func (*ServerConnection) Notice

func (sc *ServerConnection) Notice(tags map[string]string, target string, message string, escaped bool)

Notice sends a notice to the given target.

func (*ServerConnection) ProcessIncomingLine

func (sc *ServerConnection) ProcessIncomingLine(line string)

ProcessIncomingLine processes the incoming IRC line. This is used when writing a custom event loop.

func (*ServerConnection) ReceiveLoop

func (sc *ServerConnection) ReceiveLoop()

ReceiveLoop runs a loop of receiving and dispatching new messages.

func (*ServerConnection) RegisterCommand

func (sc *ServerConnection) RegisterCommand(name string, handler eventmgr.HandlerFn, priority int)

RegisterCommand registers a command to be called via the configured prefix or the client's nickname (e.g !help, "GoshuBot: help")

func (*ServerConnection) RegisterEvent

func (sc *ServerConnection) RegisterEvent(direction string, name string, handler eventmgr.HandlerFn, priority int)

RegisterEvent registers a new handler for the given event.

The standard directions are "in" and "out".

'name' can either be the name of an event, "all", or "raw". Note that "all" will not catch "raw" events, but will catch all others.

func (*ServerConnection) Send

func (sc *ServerConnection) Send(tags map[string]string, prefix string, command string, params ...string) error

Send sends an IRC message to the server. If the message cannot be converted to a raw IRC line, an error is returned.

func (*ServerConnection) Shutdown

func (sc *ServerConnection) Shutdown(message string)

Shutdown closes the connection to the server.

func (*ServerConnection) WaitForConnection

func (sc *ServerConnection) WaitForConnection()

WaitForConnection waits for the serverConnection to become available. This is used when writing a custom event loop.

type ServerFeatures

type ServerFeatures map[string]interface{}

ServerFeatures holds a map of server features (RPL_ISUPPORT).

func (*ServerFeatures) Parse

func (sf *ServerFeatures) Parse(tokens ...string)

Parse the given RPL_ISUPPORT-type tokens and add them to our support list.

Jump to

Keyboard shortcuts

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