irc

package
v0.0.0-...-8887655 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConn

func NewConn(server, channel, userTelegram string, backup bool, h func(e *event)) (*ircconn, error)

Types

type IRCMessage

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

ircMessage is a message received on IRC by a connection, sent over to the Manager.

type Manager

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

Manager maintains a set of IRC connections to a server and channel. Its has three interfaces to the outside world:

  • control, from the owner of Manager (eg. a bridge to another protocol) that allows sending messages as a given user and to subscribe to notifications
  • events, from IRC connections, to update the manager about a connection state (lifecycle or nick change)
  • subscriptions, that pass received messages from IRC to a channel requested by control.

The Manager will maintain exactly one 'receiver', which is an IRC connection that is used as a source of truth for messages on an IRC channel. This will either be an existing connection for a user, or a 'backup' connection that will close as soon as a real/named connection exists and is fully connected.

func NewManager

func NewManager(max int, server, channel string, login string) *Manager

func (*Manager) Event

func (m *Manager) Event(e *event)

func (*Manager) MarkDead

func (m *Manager) MarkDead(i *ircconn)

Event: mark a given connection as dead.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run maintains the main logic of the Manager - servicing control and event messages, and ensuring there is a receiver on the given channel.

func (*Manager) SendMessage

func (m *Manager) SendMessage(ctx context.Context, user, text string) error

Control: send a message to IRC.

func (*Manager) Subscribe

func (m *Manager) Subscribe(c chan *Notification)

Control: subscribe to notifiactions.

func (*Manager) UpdateNickmap

func (m *Manager) UpdateNickmap(conn *ircconn, nick string)

Event: a connection has a new nick.

type Notification

type Notification struct {
	// A new message appeared on the channel
	Message *NotificationMessage
	// Nicks of our connections have changed
	Nickmap *map[string]string
}

Notifications are sent to subscribers when things happen on IRC

type NotificationMessage

type NotificationMessage struct {
	// Nick is the IRC nickname of the sender
	Nick string
	// Message is the plaintext message from IRC
	Message string
}

NotificationMessage is a message that happened in the connected IRC channel

Jump to

Keyboard shortcuts

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