Documentation
¶
Overview ¶
Package ergo manages the lifecycle of the Ergo IRC server subprocess.
Index ¶
- func EnsureBinary(binaryPath, destDir string) (string, error)
- func GenerateConfig(cfg config.ErgoConfig) ([]byte, error)
- type APIClient
- func (c *APIClient) AccountInfo(name string) (*AccountInfoResponse, error)
- func (c *APIClient) ChangePassword(name, passphrase string) error
- func (c *APIClient) ListChannels() (*ListChannelsResponse, error)
- func (c *APIClient) RegisterAccount(name, passphrase string) error
- func (c *APIClient) Rehash() error
- func (c *APIClient) Status() (*StatusResponse, error)
- type AccountInfoResponse
- type ChannelInfo
- type ListChannelsResponse
- type Manager
- type StatusResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureBinary ¶
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 ¶
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 ¶
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 ¶
RegisterAccount creates a NickServ account via saregister.
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) Start ¶
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.