irc

package
v0.0.0-...-db1fe24 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Logger log15.Logger
)

Functions

func ConnectionReactor

func ConnectionReactor(conn *Connection, reactorCtl <-chan bool)

func ConvertSlashCommand

func ConvertSlashCommand(fullcmd string) (string, error)

func IsChannel

func IsChannel(target string) bool

func IsDirect

func IsDirect(msg string, currentNick string) bool

func StripNickOnDirect

func StripNickOnDirect(msg string, nick string) string

Types

type Connection

type Connection struct {
	// Name of the network (e.g. freenode, efnet, localhost)
	Name string
	// Network configuration
	Config config.ConnectionConfig

	// Channel used to capture messages coming in from IRC
	In <-chan string
	// Channel used to send messages to IRC
	Out chan<- string

	// How many messages we have recieved. Reset when tenyks is restarted.
	MessagesRecved uint
	// How mant messages we have sent. Reset when tenyks is restarted.
	MessagesSent uint
	// Created holds the datetime the connection was created.
	Created time.Time
	// Handler registry. These handle various commands from IRC.
	Registry *HandlerRegistry
	// Channel used to tell things to wait for the connection to succeed before spawning goroutines.
	ConnectWait chan bool
	// Last PONG recieved from the network.
	LastPong time.Time
	// Channel for the connection watchdog.
	PongIn chan bool
	// Current channels tenyks is in. Jnerula hates state and I don't care.
	Channels *list.List
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(name string, conf config.ConnectionConfig) *Connection

NewConnection will create a new instance of an irc.Connection. It will return *irc.Connection

func (*Connection) AddHandler

func (conn *Connection) AddHandler(name string, fn ircfn)

func (*Connection) BootstrapHandler

func (conn *Connection) BootstrapHandler(msg *Message)

func (*Connection) CTCPHandler

func (conn *Connection) CTCPHandler(msg *Message)

func (*Connection) Connect

func (conn *Connection) Connect() chan bool

Connect is a goroutine that returns a channel that is true if connected successfully and false if not. It returns a bool channel that when closed or is passed true means success.

func (*Connection) ConnectedHandler

func (conn *Connection) ConnectedHandler(msg *Message)

func (*Connection) Disconnect

func (conn *Connection) Disconnect()

Disconnect will hangup the connection with IRC and reset channels and other important bootstrap attributes back to the defaults.

func (*Connection) GetChannelElement

func (conn *Connection) GetChannelElement(channel string) *list.Element

func (*Connection) GetCurrentNick

func (conn *Connection) GetCurrentNick() string

GetCurrentNick will return the nick currently being used in the IRC connection It returns a string

func (*Connection) GetInfo

func (conn *Connection) GetInfo() []string

func (*Connection) IsConnected

func (conn *Connection) IsConnected() bool

IsConnected can be called to detemine if a connection is still connected. It returns a bool

func (*Connection) IsInChannel

func (conn *Connection) IsInChannel(channel string) bool

func (*Connection) JoinChannel

func (conn *Connection) JoinChannel(channel string)

func (*Connection) NickInUseHandler

func (conn *Connection) NickInUseHandler(msg *Message)

func (*Connection) PartChannel

func (conn *Connection) PartChannel(channel string)

func (*Connection) PingHandler

func (conn *Connection) PingHandler(msg *Message)

func (*Connection) PongHandler

func (conn *Connection) PongHandler(msg *Message)

func (*Connection) SendPing

func (conn *Connection) SendPing(msg *Message)

func (*Connection) String

func (conn *Connection) String() string

type Handler

type Handler struct {
	Fn func(...interface{})
}

func NewHandler

func NewHandler(fn func(...interface{})) *Handler

type HandlerRegistry

type HandlerRegistry struct {
	Handlers   map[string]*list.List
	RegistryMu *sync.Mutex
}

func NewHandlerRegistry

func NewHandlerRegistry() *HandlerRegistry

func (*HandlerRegistry) AddHandler

func (h *HandlerRegistry) AddHandler(name string, handler *Handler)

type IRCConnections

type IRCConnections map[string]*Connection

type Message

type Message struct {
	Prefix   string
	Nick     string
	Ident    string
	Host     string
	Command  string
	Trail    string
	Params   []string
	SentAt   time.Time
	RawMsg   string
	Conn     *Connection
	IsParsed bool
}

func ParseMessage

func ParseMessage(rawMsg string) *Message

Parses a message string from an IRC server

func (*Message) GetDMString

func (m *Message) GetDMString(newMsg string) string

func (*Message) String

func (m *Message) String() string

Jump to

Keyboard shortcuts

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