irc

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypingUnspec = iota
	TypingActive
	TypingPaused
	TypingDone
)

Values taken by the "@+typing=" client tag. TypingUnspec means the value or tag is absent.

View Source
const (
	ModeTypeA int = iota
	ModeTypeB
	ModeTypeC
	ModeTypeD
)

Mode types available in the CHANMODES 005 token.

Variables

View Source
var SupportedCapabilities = map[string]struct{}{
	"away-notify":      {},
	"batch":            {},
	"cap-notify":       {},
	"echo-message":     {},
	"extended-monitor": {},
	"invite-notify":    {},
	"message-tags":     {},
	"multi-prefix":     {},
	"server-time":      {},
	"sasl":             {},
	"setname":          {},
	"standard-replies": {},

	"draft/chathistory":               {},
	"draft/event-playback":            {},
	"draft/read-marker":               {},
	"soju.im/bouncer-networks-notify": {},
	"soju.im/bouncer-networks":        {},
	"soju.im/search":                  {},
}

SupportedCapabilities is the set of capabilities supported by this library.

Functions

func CasemapASCII

func CasemapASCII(name string) string

CasemapASCII of name is the canonical representation of name according to the ascii casemapping.

func CasemapRFC1459

func CasemapRFC1459(name string) string

CasemapRFC1459 of name is the canonical representation of name according to the rfc-1459 casemapping.

func ChanInOut

func ChanInOut(conn net.Conn) (in <-chan Message, out chan<- Message)

Types

type BouncerNetworkEvent

type BouncerNetworkEvent struct {
	ID     string
	Name   string
	Delete bool
}

type Cap

type Cap struct {
	Name   string
	Value  string
	Enable bool
}

Cap is a capability token in "CAP" server responses.

func ParseCaps

func ParseCaps(caps string) (diff []Cap)

ParseCaps parses the last argument (capability list) of "CAP LS/LIST/NEW/DEL" server responses.

type Channel

type Channel struct {
	Name      string           // the name of the channel.
	Members   map[*User]string // the set of members associated with their membership.
	Topic     string           // the topic of the channel, or "" if absent.
	TopicWho  *Prefix          // the name of the last user who set the topic.
	TopicTime time.Time        // the last time the topic has been changed.
	Read      time.Time        // the time until which messages were read.
	// contains filtered or unexported fields
}

Channel is a joined channel.

type ErrorEvent

type ErrorEvent struct {
	Severity Severity
	Code     string
	Message  string
}

type Event

type Event interface{}

type HistoryEvent

type HistoryEvent struct {
	Target   string
	Messages []Event
}

type HistoryRequest

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

func (*HistoryRequest) After

func (r *HistoryRequest) After(t time.Time)

func (*HistoryRequest) Before

func (r *HistoryRequest) Before(t time.Time)

func (*HistoryRequest) Latest added in v0.3.0

func (r *HistoryRequest) Latest()

func (*HistoryRequest) Targets

func (r *HistoryRequest) Targets(start time.Time, end time.Time)

func (*HistoryRequest) WithLimit

func (r *HistoryRequest) WithLimit(limit int) *HistoryRequest

type HistoryTargetsEvent

type HistoryTargetsEvent struct {
	Targets map[string]time.Time
}

type InfoEvent added in v0.3.0

type InfoEvent struct {
	Prefix  string
	Message string
}

type InviteEvent

type InviteEvent struct {
	Inviter string
	Invitee string
	Channel string
}

type Member

type Member struct {
	PowerLevel   string
	Name         *Prefix
	Away         bool
	Disconnected bool
	Self         bool // Added by senpai
}

Member is a token in RPL_NAMREPLY's last parameter.

func ParseNameReply

func ParseNameReply(trailing string, prefixes string) (names []Member)

ParseNameReply parses the last parameter of RPL_NAMREPLY, according to the membership prefixes of the server.

type Message

type Message struct {
	Tags    map[string]string
	Prefix  *Prefix
	Command string
	Params  []string
}

Message is the representation of an IRC message.

func NewMessage

func NewMessage(command string, params ...string) Message

func ParseMessage

func ParseMessage(line string) (msg Message, err error)

ParseMessage parses the message from the given string, which must be trimmed of "\r\n" beforehand.

func (*Message) IsReply

func (msg *Message) IsReply() bool

IsReply reports whether the message command is a server reply.

func (*Message) ParseParams

func (msg *Message) ParseParams(out ...*string) error

func (*Message) String

func (msg *Message) String() string

String returns the protocol representation of the message, without an ending "\r\n".

func (*Message) Time

func (msg *Message) Time() (t time.Time, ok bool)

Time returns the time when the message has been sent, if present.

func (*Message) TimeOrNow

func (msg *Message) TimeOrNow() time.Time

TimeOrNow returns the time when the message has been sent, or time.Now() if absent.

func (Message) WithTag

func (msg Message) WithTag(key, value string) Message

type MessageEvent

type MessageEvent struct {
	User            string
	Target          string
	TargetIsChannel bool
	Command         string
	Content         string
	Time            time.Time
}

type ModeChange

type ModeChange struct {
	Enable bool
	Mode   byte
	Param  string
}

func ParseChannelMode

func ParseChannelMode(mode string, params []string, chanmodes [4]string, membershipModes string) ([]ModeChange, error)

ParseChannelMode parses a MODE message for a channel, according to the CHANMODES of the server.

type ModeChangeEvent

type ModeChangeEvent struct {
	Channel string
	Mode    string
	Time    time.Time
}

type Prefix

type Prefix struct {
	Name string
	User string
	Host string
}

func ParsePrefix

func ParsePrefix(s string) (p *Prefix)

ParsePrefix parses a "nick!user@host" combination (or a prefix) from the given string.

func (*Prefix) Copy

func (p *Prefix) Copy() *Prefix

Copy makes a copy of the prefix, but doesn't copy the internal strings.

func (*Prefix) String

func (p *Prefix) String() string

String returns the "nick!user@host" representation of the prefix.

type ReadEvent

type ReadEvent struct {
	Target    string
	Timestamp time.Time
}

type RegisteredEvent

type RegisteredEvent struct{}

type SASLClient

type SASLClient interface {
	Early() bool
	Handshake() (mech string)
	Respond(challenge string) (res string, err error)
}

type SASLPlain

type SASLPlain struct {
	Username string
	Password string
}

func (*SASLPlain) Early

func (auth *SASLPlain) Early() bool

func (*SASLPlain) Handshake

func (auth *SASLPlain) Handshake() (mech string)

func (*SASLPlain) Respond

func (auth *SASLPlain) Respond(challenge string) (res string, err error)

type SearchEvent

type SearchEvent struct {
	Messages []MessageEvent
}

type SelfJoinEvent

type SelfJoinEvent struct {
	Channel   string
	Requested bool // whether we recently requested to join that channel
	Topic     string
	Read      time.Time
}

type SelfNickEvent

type SelfNickEvent struct {
	FormerNick string
}

type SelfPartEvent

type SelfPartEvent struct {
	Channel string
}

type Session

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

func NewSession

func NewSession(out chan<- Message, params SessionParams) *Session

func (*Session) Away added in v0.3.0

func (s *Session) Away(message string)

func (*Session) Casemap

func (s *Session) Casemap(name string) string

func (*Session) ChangeMode

func (s *Session) ChangeMode(channel, flags string, args []string)

func (*Session) ChangeNick

func (s *Session) ChangeNick(nick string)

func (*Session) ChangeTopic

func (s *Session) ChangeTopic(channel, topic string)

func (*Session) ChannelsSharedWith

func (s *Session) ChannelsSharedWith(name string) []string

func (*Session) Close

func (s *Session) Close()

func (*Session) HandleMessage

func (s *Session) HandleMessage(msg Message) (Event, error)

func (*Session) HasCapability

func (s *Session) HasCapability(capability string) bool

HasCapability reports whether the given capability has been negotiated successfully.

func (*Session) Invite

func (s *Session) Invite(nick, channel string)

func (*Session) IsChannel

func (s *Session) IsChannel(name string) bool

func (*Session) IsMe

func (s *Session) IsMe(nick string) bool

func (*Session) Join

func (s *Session) Join(channel, key string)

func (*Session) Kick

func (s *Session) Kick(nick, channel, comment string)

func (*Session) List added in v0.3.0

func (s *Session) List(pattern string)

func (*Session) MonitorAdd

func (s *Session) MonitorAdd(target string)

func (*Session) MonitorRemove

func (s *Session) MonitorRemove(target string)

func (*Session) Names

func (s *Session) Names(target string) []Member

Names returns the list of users in the given target, or nil if the target is not a known channel or nick in the session. The list is sorted according to member name.

func (*Session) NetID

func (s *Session) NetID() string

func (*Session) NewHistoryRequest

func (s *Session) NewHistoryRequest(target string) *HistoryRequest

func (*Session) Nick

func (s *Session) Nick() string

func (*Session) NickCf

func (s *Session) NickCf() string

NickCf is our casemapped nickname.

func (*Session) Part

func (s *Session) Part(channel, reason string)

func (*Session) PrivMsg

func (s *Session) PrivMsg(target, content string)

func (*Session) Quit

func (s *Session) Quit(reason string)

func (*Session) ReadGet

func (s *Session) ReadGet(target string)

func (*Session) ReadSet

func (s *Session) ReadSet(target string, timestamp time.Time)

func (*Session) Search

func (s *Session) Search(target, text string)

func (*Session) Send added in v0.3.0

func (s *Session) Send(command string, params ...string)

func (*Session) SendRaw

func (s *Session) SendRaw(raw string)

func (*Session) Topic

func (s *Session) Topic(channel string) (topic string, who *Prefix, at time.Time)

func (*Session) Typing

func (s *Session) Typing(target string)

func (*Session) TypingStop

func (s *Session) TypingStop(target string)

func (*Session) TypingStops

func (s *Session) TypingStops() <-chan Typing

func (*Session) Typings

func (s *Session) Typings(target string) []string

Typings returns the list of nickname who are currently typing.

func (*Session) Users

func (s *Session) Users() []string

Users returns the list of all known nicknames.

func (*Session) Who added in v0.2.0

func (s *Session) Who(target string)

func (*Session) Whois

func (s *Session) Whois(nick string)

func (*Session) Whowas added in v0.3.0

func (s *Session) Whowas(nick string)

type SessionParams

type SessionParams struct {
	Nickname string
	Username string
	RealName string
	NetID    string
	Auth     SASLClient
}

SessionParams defines how to connect to an IRC server.

type Severity

type Severity int

Severity is the severity of a server reply.

const (
	SeverityNote Severity = iota
	SeverityWarn
	SeverityFail
)

func ReplySeverity

func ReplySeverity(reply string) Severity

ReplySeverity returns the severity of a server reply.

type TopicChangeEvent

type TopicChangeEvent struct {
	Channel string
	Topic   string
	Time    time.Time
}

type Typing

type Typing struct {
	Target string
	Name   string
}

Typing is an event of Name actively typing in Target.

type Typings

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

Typings keeps track of typing notification timeouts.

func NewTypings

func NewTypings() *Typings

NewTypings initializes the Typings structures and filtering coroutine.

func (*Typings) Active

func (ts *Typings) Active(target, name string)

Active should be called when a user is typing to some target.

func (*Typings) Close

func (ts *Typings) Close()

Close cleanly closes all channels and stops all goroutines.

func (*Typings) Done

func (ts *Typings) Done(target, name string)

Done should be called when a user is done typing to some target.

func (*Typings) List

func (ts *Typings) List(target string) []string

func (*Typings) Stops

func (ts *Typings) Stops() <-chan Typing

Stops is a channel that transmits typing timeouts.

type User

type User struct {
	Name         *Prefix // the nick, user and hostname of the user if known.
	Away         bool    // whether the user is away or not
	Disconnected bool    // can only be true for monitored users.
}

User is a known IRC user.

type UserJoinEvent

type UserJoinEvent struct {
	User    string
	Channel string
	Time    time.Time
}

type UserNickEvent

type UserNickEvent struct {
	User       string
	FormerNick string
	Time       time.Time
}

type UserOfflineEvent

type UserOfflineEvent struct {
	User string
}

type UserOnlineEvent

type UserOnlineEvent struct {
	User string
}

type UserPartEvent

type UserPartEvent struct {
	User    string
	Channel string
	Time    time.Time
}

type UserQuitEvent

type UserQuitEvent struct {
	User     string
	Channels []string
	Time     time.Time
}

Jump to

Keyboard shortcuts

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