irc

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

MIT License

Copyright (c) 2025 Mikael Schultz <mikael@conf-t.se>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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 represents an IRC client with auto-reconnect and event handlers.

func New

func New(cfg config.IRCConfig, h Handlers, o Options) (*Client, error)

New creates a new IRC client with the specified config, handlers, and options.

func (*Client) Broadcast

func (c *Client) Broadcast(msg string)

Broadcast sends msg to all configured channels.

func (*Client) Close

func (c *Client) Close()

Close stops reconnect attempts (does not forcibly close the socket).

func (*Client) Quit

func (c *Client) Quit(reason string)

Quit asks the server to close the connection with a reason.

func (*Client) SendTo

func (c *Client) SendTo(channels []string, msg string)

func (*Client) Start

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

Start connects and starts an auto-reconnect loop. It returns after the first successful connection or ctx timeout.

type Handlers

type Handlers struct {
	Connected    func()
	Welcome      func(raw string)
	NickInUse    func(args []string)
	Joined       func(channel string)
	Notice       func(src, text string)
	Error        func(text string)
	Disconnected func()
}

Handlers let callers receive status events (all optional).

type Options

type Options struct {
	// DisableFlood keeps library throttling enabled unless set to false.
	// By default, flood protection is disabled (messages go out immediately).
	DisableFlood bool
	// Logger is where verbose/status logs can be written (optional).
	Logger io.Writer
}

Options configures client behaviors.

Jump to

Keyboard shortcuts

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