ergo

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package ergo manages the lifecycle of the Ergo IRC server subprocess.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureBinary

func EnsureBinary(binaryPath, destDir string) (string, error)

EnsureBinary checks that the ergo binary exists at binaryPath. If it does not, it downloads the latest release from GitHub into destDir and returns the path to the installed binary.

binaryPath is the configured path (may be just "ergo" meaning look in PATH). destDir is where to install if not found.

func GenerateConfig

func GenerateConfig(cfg config.ErgoConfig) ([]byte, error)

GenerateConfig renders an ircd.yaml from the given ErgoConfig.

Types

type APIClient

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

APIClient is an HTTP client for Ergo's management API.

func NewAPIClient

func NewAPIClient(addr, token string) *APIClient

NewAPIClient returns a new APIClient pointed at addr with the given bearer token.

func (*APIClient) AccountInfo

func (c *APIClient) AccountInfo(name string) (*AccountInfoResponse, error)

AccountInfo fetches details about a NickServ account.

func (*APIClient) ChangePassword

func (c *APIClient) ChangePassword(name, passphrase string) error

ChangePassword updates the passphrase of an existing NickServ account.

func (*APIClient) ListChannels

func (c *APIClient) ListChannels() (*ListChannelsResponse, error)

ListChannels returns all channels currently active on the server.

func (*APIClient) RegisterAccount

func (c *APIClient) RegisterAccount(name, passphrase string) error

RegisterAccount creates a NickServ account via saregister.

func (*APIClient) Rehash

func (c *APIClient) Rehash() error

Rehash reloads Ergo's configuration file.

func (*APIClient) Status

func (c *APIClient) Status() (*StatusResponse, error)

Status returns the Ergo server status.

type AccountInfoResponse

type AccountInfoResponse struct {
	Success      bool     `json:"success"`
	AccountName  string   `json:"accountName"`
	Email        string   `json:"email"`
	RegisteredAt string   `json:"registeredAt"`
	Channels     []string `json:"channels"`
}

AccountInfoResponse is the response from /v1/ns/info.

type ChannelInfo

type ChannelInfo struct {
	Name       string `json:"name"`
	UserCount  int    `json:"userCount"`
	Topic      string `json:"topic"`
	Registered bool   `json:"registered"`
}

ChannelInfo is a single channel entry from /v1/list.

type ListChannelsResponse

type ListChannelsResponse struct {
	Success  bool          `json:"success"`
	Channels []ChannelInfo `json:"channels"`
}

ListChannelsResponse is the response from /v1/list.

type Manager

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

Manager manages the Ergo IRC server subprocess.

func NewManager

func NewManager(cfg config.ErgoConfig, log *slog.Logger) *Manager

NewManager creates a new Manager. Call Start to launch the Ergo process.

func (*Manager) API

func (m *Manager) API() *APIClient

API returns the Ergo HTTP API client. Available after Start succeeds.

func (*Manager) Rehash

func (m *Manager) Rehash() error

Rehash reloads the Ergo config. Call after writing a new ircd.yaml.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start manages the Ergo IRC server. In managed mode (the default), it writes the Ergo config, starts the subprocess, waits for health, then keeps it alive with exponential backoff restarts. In external mode (cfg.External=true), it skips subprocess management and simply waits for the external ergo instance to become healthy, then blocks until ctx is done. Either way, Start blocks until ctx is cancelled.

func (*Manager) UpdateConfig added in v1.2.3

func (m *Manager) UpdateConfig(cfg config.ErgoConfig) error

UpdateConfig replaces the Ergo config, regenerates ircd.yaml, and rehashes. Use when scuttlebot.yaml Ergo settings change at runtime.

type StatusResponse

type StatusResponse struct {
	Success   bool   `json:"success"`
	Version   string `json:"version"`
	StartTime string `json:"start_time"`
	Users     struct {
		Total int `json:"total"`
		Max   int `json:"max"`
	} `json:"users"`
	Channels int `json:"channels"`
}

StatusResponse is the response from /v1/status.

Jump to

Keyboard shortcuts

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