Skip to content

kofany/go-ircevo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

337 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

go-ircevo

Go Reference Go Report Card License Go Version

Fork of go-ircevent by Thomas Jager

Credits


A robust, production-ready IRC client library for Go 1.23+ with advanced features optimized for mass deployments.

✨ Features

  • πŸ”„ Smart Error Handling - Intelligent ERROR categorization and reconnection strategies
  • πŸ‘€ Advanced Nick Management - Atomic operations with RFC 2812 compliance
  • πŸ” Authentication - SASL (PLAIN/EXTERNAL), server passwords, client certificates
  • 🌐 Connectivity - SOCKS5/HTTP proxy support, TLS/SSL, WebIRC
  • πŸ’¬ DCC Chat - Full DCC CHAT protocol support
  • 🏭 Mass Deployment Ready - Tested with 500+ concurrent connections
  • πŸ“Š Health Monitoring - Real socket health checks with activity monitoring
  • 🎯 Event System - Flexible callback-based event handling
  • πŸ”§ IRCv3 - CAP negotiation, message tags, SASL authentication

πŸ†• What's New in v1.3.1

Nick Retry Fixes - keepalive no longer retries nickname changes from the ping loop:

  • πŸ‘€ Controlled Recovery: Connection.AutoNickRecoveryPostRegistration = false now also clears failed post-registration nick attempts back to the confirmed current nick
  • πŸ“‘ Keepalive Safety: pingLoop only sends PING and never retries NICK
  • βœ… Registration Safety: pre-001 nickname recovery is unchanged, so initial registration can still recover from collisions

See CHANGELOG.md for detailed release notes.

πŸ“¦ Installation

# Latest version
go get github.com/kofany/go-ircevo

# Specific version (recommended for production)
go get github.com/kofany/go-ircevo@v1.3.1

Requirements: Go 1.23 or higher

πŸš€ Quick Start

package main

import (
    "log"
    irc "github.com/kofany/go-ircevo"
)

func main() {
    conn := irc.IRC("mynick", "myuser")
    conn.RealName = "My Real Name"
    
    conn.AddCallback("001", func(e *irc.Event) {
        conn.Join("#mychannel")
    })
    
    conn.AddCallback("PRIVMSG", func(e *irc.Event) {
        log.Printf("<%s> %s", e.Nick, e.Message())
    })
    
    if err := conn.Connect("irc.example.com:6667"); err != nil {
        log.Fatal(err)
    }
    
    conn.Loop()
}

πŸ“š Documentation

🎯 Key Features

Smart Error Handling

Automatically categorizes IRC ERROR messages and handles them intelligently:

conn.SmartErrorHandling = true
conn.HandleErrorAsDisconnect = true
conn.MaxRecoverableReconnects = 3  // Limit reconnection attempts

Error Categories:

  • PermanentError - Bans, permanent blocks (no reconnect)
  • ServerError - Server overload, host limits (reconnect with delay)
  • NetworkError - Network issues, timeouts (immediate reconnect)
  • RecoverableError - Temporary issues (normal reconnect with limit)

Advanced Nick Management

RFC 2812 compliant with atomic operations:

conn.Nick("newnick")

// Disable automatic fallback nick generation after registration.
// Pre-registration recovery remains enabled.
conn.AutoNickRecoveryPostRegistration = false

status := conn.GetNickStatus()
if status.Confirmed {
    log.Printf("Nick confirmed: %s", status.Current)
}

SASL Authentication

conn.UseSASL = true
conn.SASLLogin = "username"
conn.SASLPassword = "password"
conn.SASLMech = "PLAIN"  // or "EXTERNAL"

TLS/SSL Support

conn.UseTLS = true
conn.TLSConfig = &tls.Config{
    InsecureSkipVerify: false,
    Certificates: []tls.Certificate{cert},
}

Proxy Support

conn.ProxyConfig = &irc.ProxyConfig{
    Type:     "socks5",
    Address:  "127.0.0.1:9050",  // Tor
    Username: "",
    Password: "",
}

DCC Chat

conn.DCCManager = irc.NewDCCManager()

conn.AddCallback("PRIVMSG", func(e *irc.Event) {
    if strings.Contains(e.Message(), "!dcc") {
        conn.InitiateDCCChat(e.Nick)
    }
})

🏭 Production Features

Mass Deployment Optimization

Designed and tested for running hundreds of concurrent connections:

conn.EnableTimeoutFallback = false  // Prevent ghost bots (default)
conn.SmartErrorHandling = true
conn.MaxRecoverableReconnects = 3

Connection Health Validation

if conn.ValidateConnectionState() {
    log.Println("Connection healthy")
}

if conn.Connected() {
    log.Println("Fully connected and registered")
}

Custom QUIT Messages

conn.QuitMessage = "Bot shutting down for maintenance"
conn.Quit()  // Sends: QUIT :Bot shutting down for maintenance

πŸ“Š Event System

Register callbacks for any IRC command or numeric:

conn.AddCallback("JOIN", func(e *irc.Event) {
    log.Printf("%s joined %s", e.Nick, e.Arguments[0])
})

conn.AddCallback("PRIVMSG", func(e *irc.Event) {
    if e.Message() == "!ping" {
        conn.Privmsg(e.Arguments[0], "pong!")
    }
})

conn.AddCallback("*", func(e *irc.Event) {
    log.Printf("Event: %s", e.Code)
})

πŸ”§ Configuration Options

conn := irc.IRC("nick", "user")

// Connection settings
conn.Server = "irc.example.com:6667"
conn.Password = "serverpass"
conn.RealName = "My Real Name"

// Timing configuration
conn.Timeout = 300 * time.Second
conn.PingFreq = 15 * time.Minute
conn.KeepAlive = 4 * time.Minute

// Behavior configuration
conn.SmartErrorHandling = true
conn.HandleErrorAsDisconnect = true
conn.EnableTimeoutFallback = false
conn.MaxRecoverableReconnects = 3

// Debug mode
conn.Debug = true
conn.VerboseCallbackHandler = true

πŸ“– Examples

Check out the examples/ directory for complete working examples:

🀝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

πŸ“ License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

πŸ“ž Support

πŸ—ΊοΈ Roadmap

  • IRCv3.3 compliance
  • File transfer support (DCC SEND)
  • Connection pooling
  • Metrics and observability
  • More SASL mechanisms (SCRAM-SHA-256)

go-ircevo - Production-ready IRC for Go

About

An evolved and enhanced version of the go-ircevent library for advanced IRC interactions, featuring DCC, SASL, proxy support, and extended message handling.

Resources

License

Contributing

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages