client

package
v0.0.0-...-df918ef Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: ISC Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client implements a full IRC client for use in bots. It does most of the work in connecting and otherwise handling the protocol

func New

func New(config *Config) *Client

New creates a new instance of Client.

func (*Client) CurrentNick

func (c *Client) CurrentNick() string

CurrentNick returns what the Client believes its current nick is. It is safe for concurrent use. A client created with New() will internally handle tracking nick changes.

func (*Client) DoneChan

func (c *Client) DoneChan() <-chan struct{}

DoneChan returns a channel that will be closed when the connection is closed

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

Run connects to IRC and handles messages until a disconnection occurs

func (*Client) SendMessage

func (c *Client) SendMessage(target, message string) error

SendMessage sends a PRIVMSG to the given target with the given message.

func (*Client) SendMessageChunked

func (c *Client) SendMessageChunked(target, message string) error

SendMessageChunked will use SendMessage to send your message, but if the message is over the max for an IRC message, it will split it into chunks, and send each one individually.

This is mostly intended for use with things like chatcommand.Handler that dont know how long their messages will be. If you can, you likely want to do this manually, as the chunking this uses is not intelligent at all.

func (*Client) SendMessagef

func (c *Client) SendMessagef(target, format string, args ...interface{}) error

SendMessagef is like SendMessage but with printf formatting

func (*Client) SendNotice

func (c *Client) SendNotice(target, message string) error

SendNotice sends a NOTICE to the given target with the given message

func (*Client) SendNoticeChunked

func (c *Client) SendNoticeChunked(message, target string) error

SendNoticeChunked will use SendNotice to send your message, but if the message is over the max for an IRC message, it will split it into chunks, and send each one individually.

This is mostly intended for use with things like chatcommand.Handler that dont know how long their messages will be. If you can, you likely want to do this manually, as the chunking this uses is not intelligent at all.

func (*Client) SendNoticef

func (c *Client) SendNoticef(target, format string, args ...interface{}) error

SendNoticef is like SendNotice but with printf formatting

func (*Client) SetMessageHandler

func (c *Client) SetMessageHandler(handler event.MessageHandler)

SetMessageHandler sets the callback handler for incoming IRC Messages

func (*Client) Stop

func (c *Client) Stop(message string)

Stop stops the bot, quitting with the given message if possible

func (*Client) ToggleRawLog

func (c *Client) ToggleRawLog()

ToggleRawLog enables or disables raw IRC line logging

func (*Client) WaitForExit

func (c *Client) WaitForExit()

WaitForExit blocks until the connection is closed

func (*Client) Write

func (c *Client) Write(data []byte) (int, error)

Write implements io.Writer. See WriteIRC for a nicer frontend for creating IRC lines

func (*Client) WriteIRC

func (c *Client) WriteIRC(command string, params ...string) error

WriteIRC constructs an IRC line and sends it to the server

func (*Client) WriteString

func (c *Client) WriteString(s string) (int, error)

WriteString implements io.StringWriter. See WriteIRC for a nicer frontend

type Config

type Config struct {
	Connection     connection.Config
	ServerPassword string
	Nick           string
	Username       string
	Realname       string

	SASLUsername string
	SASLPassword string

	RequestedCapabilities []string
	// contains filtered or unexported fields
}

Config is a startup configuration for a client instance

Jump to

Keyboard shortcuts

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