data

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package data contains data types used by discoirc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Less

func Less(a EventID, b EventID) bool

Types

type Channel

type Channel struct {
	Name       string
	Connection Connection

	Topic    string
	Presence Presence
	Mode     string
}

Channel represents the state of a user's presence in a channel.

type ChannelState

type ChannelState struct {
	Network, Channel string
	Presence         Presence
	// TODO: This representation is incorrect.
	// A user's mode is for the network, not to the channel.
	ChannelMode, UserMode string

	Topic   string
	Members int

	Unread      int
	LastMessage Event
}

ChannelState summarizes the state of a channel.

type Connection

type Connection struct {
	Network string
	Nick    string
	State   ConnectionState
}

Connection represents a user's relation with an IRC network.

type ConnectionState

type ConnectionState int

ConnectionState represents the status of a user's connection to an IRC network.

const (
	Disconnected ConnectionState = iota
	Connecting
	Connected
)

type Event

type Event struct {
	EventID

	Contents string
}

An Event represents an event in IRC, e.g. a message.

func (*Event) String

func (e *Event) String() string

type EventID

type EventID struct {
	Epoch int
	Seq   uint
}

An EventID is a unique, sequenceable identifier for an event. Within a scope, e.g. a channel, events are lexicographically ordered- by epoch, then by sequence. An Epoch may be ticked over when a log file rolls over, when a server disconnects, or in other circumstances. Usually, it represents when there was a potential discontinuity in events. Epochs may be negative because they may extend indefinitely into the past, e.g. via logfiles or an external log server.

type EventList

type EventList []Event

func NewEvents

func NewEvents(es []Event) EventList

NewEvents returns a new EventList, ensuring that it is sorted.

func (EventList) Len

func (e EventList) Len() int

func (EventList) Less

func (e EventList) Less(i, j int) bool

func (EventList) SelectMinMax

func (e EventList) SelectMinMax(min, max EventID) []Event

Select returns a slice from its receiver with those within the EventRange.

func (EventList) SelectMinSize

func (e EventList) SelectMinSize(min EventID, n uint) []Event

SelectMinSize selects at most n Events starting from min.

func (EventList) SelectSize

func (e EventList) SelectSize(n uint) []Event

SelectSize selects the most recent n events.

func (EventList) SelectSizeMax

func (e EventList) SelectSizeMax(n uint, max EventID) []Event

SelectMaxSize selects at most n Events ending at max.

func (EventList) Swap

func (e EventList) Swap(i, j int)

type Events

type Events interface {
	SelectSize(uint) []Event
	SelectSizeMax(uint, EventID) []Event
	SelectMinSize(EventID, uint) []Event
	SelectMinMax(EventID, EventID) []Event
}

type NetworkState

type NetworkState struct {
	Network, Nick string
	State         ConnectionState
	// TODO: make UserMode and ChannelMode their own types
	UserMode string
}

type Presence

type Presence int

Presence is a user's presence, or lack thereof, in a channel.

const (
	NotPresent Presence = iota
	Joined
)

Jump to

Keyboard shortcuts

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