irc

package
v0.0.0-...-994b9a9 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RPL_WELCOME  = "001" // Welcome to the Internet Relay Network
	RPL_YOURHOST = "002" // Your host is running version...
	RPL_CREATED  = "003" // Server creation date
	RPL_MYINFO   = "004" // Server information
	RPL_ISUPPORT = "005" // Supported server features
	RPL_BOUNCE   = "010" // Bounce to a different server

	RPL_USERHOST = "302" // User host information
	RPL_ISON     = "303" // ISON response
	RPL_AWAY     = "301" // Away message
	RPL_UNAWAY   = "305" // You are no longer marked as away
	RPL_NOWAWAY  = "306" // You have been marked as away

	RPL_WHOISUSER     = "311" // WHOIS user information
	RPL_WHOISSERVER   = "312" // WHOIS server information
	RPL_WHOISOPERATOR = "313" // WHOIS operator status
	RPL_WHOISIDLE     = "317" // WHOIS idle time
	RPL_ENDOFWHOIS    = "318" // End of WHOIS list
	RPL_WHOISCHANNELS = "319" // Channels the user is on

	RPL_LISTSTART     = "321" // Start of channel listing
	RPL_LIST          = "322" // Channel listing
	RPL_LISTEND       = "323" // End of channel listing
	RPL_CHANNELMODEIS = "324" // Channel mode
	RPL_CREATIONTIME  = "329" // Channel creation time

	RPL_NOTOPIC      = "331" // No topic is set
	RPL_TOPIC        = "332" // Channel topic
	RPL_TOPICWHOTIME = "333" // Who set the topic and when (often non-standard)

	RPL_INVITING  = "341" // Invitation to channel
	RPL_SUMMONING = "342" // Summoning a user (obsolete)

	RPL_VERSION  = "351" // Server version
	RPL_WHOREPLY = "352" // WHO reply
	RPL_ENDOFWHO = "315" // End of WHO list

	RPL_NAMREPLY   = "353" // Names in a channel
	RPL_ENDOFNAMES = "366" // End of NAMES list

	RPL_LINKS      = "364" // Links list
	RPL_ENDOFLINKS = "365" // End of LINKS list

	RPL_BANLIST      = "367" // Ban list
	RPL_ENDOFBANLIST = "368" // End of ban list
	RPL_INFO         = "371" // INFO response
	RPL_MOTD         = "372" // Message of the Day
	RPL_ENDOFINFO    = "374" // End of INFO list
	RPL_MOTDSTART    = "375" // Start of MOTD
	RPL_ENDOFMOTD    = "376" // End of MOTD

	RPL_YOUREOPER = "381" // You are now an IRC operator
	RPL_REHASHING = "382" // Rehashing server configuration
	RPL_TIME      = "391" // Server time

	RPL_USERSTART  = "392" // Start of user listing (obsolete)
	RPL_USERS      = "393" // User list (obsolete)
	RPL_ENDOFUSERS = "394" // End of user listing (obsolete)
	RPL_NOUSERS    = "395" // No users (obsolete)
)

IRC RPL_ numeric constants

View Source
const (
	ERR_NOSUCHNICK        = "401"
	ERR_NOSUCHCHANNEL     = "403"
	ERR_UNKNOWNCOMMAND    = "421"
	ERR_NONICKNAMEGIVEN   = "431"
	ERR_NICKNAMEINUSE     = "433"
	ERR_NOTONCHANNEL      = "442"
	ERR_NOTREGISTERED     = "451"
	ERR_NEEDMOREPARAMS    = "461"
	ERR_ALREADYREGISTERED = "462"
	ERR_UNKNOWNMODE       = "472"
	ERR_CHANOPRIVSNEEDED  = "482"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanUserMap

type ChanUserMap map[string]*User

func (ChanUserMap) MarshalJSON

func (ucm ChanUserMap) MarshalJSON() ([]byte, error)

func (*ChanUserMap) UnmarshalJSON

func (ucm *ChanUserMap) UnmarshalJSON(data []byte) error

type Channel

type Channel struct {
	*sync.Mutex `json:"-"`
	Name        string
	Users       ChanUserMap
	Topic       string
	TopicTime   time.Time
	TopicWho    string
}

Channel represents an IRC channel

func NewChannel

func NewChannel(name string) *Channel

func (*Channel) Nick

func (ch *Channel) Nick(nick string) *User

type Server

type Server struct {
	*sync.Mutex `json:"-"`
	Name        string
	Users       UserMap
	Channels    map[string]*Channel
	MOTD        func() string `json:"-"`
	// AutoJoin causes Local() users to automatically join channels they
	// get messages for.
	AutoJoin bool
	// contains filtered or unexported fields
}

Server represents the IRC server

func NewServer

func NewServer() *Server

func (*Server) Channel

func (s *Server) Channel(name string) *Channel

func (*Server) ConnectTNC

func (s *Server) ConnectTNC(addr string, tncport int) error

ConnectTNC connects to a TNC (let's be honest here, it's direwolf) via tcp.

func (*Server) Exit

func (s *Server) Exit(err error)

func (*Server) Load

func (s *Server) Load(path string) error

func (*Server) Nick

func (s *Server) Nick(nick string) *User

func (*Server) Notice

func (s *Server) Notice(sender *User, target string, msg string)

func (*Server) OpenTNC

func (s *Server) OpenTNC(path string) error

OpenTNC opens a file (likely a pty) for a TNC. This can be used for a real hardware serial port TNC, or direwolf's pty interface to its kiss TNC.

func (*Server) PersistState

func (s *Server) PersistState(path string)

func (*Server) PingPong

func (s *Server) PingPong()

func (*Server) Privmsg

func (s *Server) Privmsg(sender *User, target string, msg string)

func (*Server) Save

func (s *Server) Save(path string) error

Save saves the radiouser list and channels to path. This can be restored with Load(path).

func (*Server) Serve

func (s *Server) Serve(listenAddr string) error

type User

type User struct {
	Nick     string
	Callsign string
	RealName string
	LastSeen time.Time
	// contains filtered or unexported fields
}

User represents a connected IRC client

func NewUser

func NewUser(nick string, wr io.Writer) *User

func (*User) ID

func (u *User) ID() string

ID generates a user id in the form of <nick>!<user>@<Real Name>. ID converts spaces to underscores for Real Name.

func (*User) Local

func (u *User) Local() bool

Local returns true if the user is connected via TCP. This is used to distinguish users sending messages via radio. Local() for radio users will return false.

func (*User) Parse

func (u *User) Parse(id string)

Parse breaks apart a nick!user@host identifier into its constituent parts and populates the User struct with the values. Since The majority of users should be remote via TNC/Radio, tracking hostname doesn't make much sense, so we use the host field to store the Real Name. When we encode a user identifier via the ID() method, spaces are converted to underscores.

func (*User) Status

func (u *User) Status() string

Status returns H or G if a user is "Here" or "Gone". This is based on LastSeen time. Any messaages within the last hour marks a user as here and gone otherwise. Only PRIVMSG and NOTICE update LastSeen time.

func (*User) String

func (u *User) String() string

func (*User) Write

func (u *User) Write(buf []byte) (n int, err error)

Write writes to the user, in discrete lines, buffering if we did not get a line-feed.

type UserMap

type UserMap map[string]*User

Jump to

Keyboard shortcuts

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