discussion

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interceptor added in v0.3.0

func Interceptor(q *Queue) gb.Interceptor

Returns an interceptor. Have to nest functions so that the Interceptor can access the Queue

Types

type Queue

type Queue struct {
	Q        []*Topic  `json:"q"`        // hide the internal list from the user
	Modified time.Time `json:"modified"` // time last modified
}

Slice for simplicity, no need to make it a heap-based PQ

func NewQueue

func NewQueue() *Queue

Create a new Queue, initializes the underlying slice and updates Modified

func (*Queue) Add

func (q *Queue) Add(t *Topic) error

Add a Topic to the queue

func (*Queue) Attach

func (q *Queue) Attach(n, s string) error

attach a string to the list of sources

func (*Queue) Bump

func (q *Queue) Bump(s string) error

Moves the Topic of the specified name to the front of the Queue

func (*Queue) Detach

func (q *Queue) Detach(n string, i int) error

remove a source (by index) from the specified topic

func (*Queue) Len

func (q *Queue) Len() int

Get the number of topics in the queue

func (*Queue) List

func (q *Queue) List() []*Topic

Return all topics in the Queue

func (*Queue) Load added in v0.3.0

func (q *Queue) Load(path string) error

load data into queue from JSON

func (*Queue) Next

func (q *Queue) Next() (*Topic, error)

Return the first topic in the queue. Does not remove the topic from the queue

func (*Queue) Remove

func (q *Queue) Remove(s string) error

Removes a Topic of the specified name from the Queue, does nothing if the name is not found

func (*Queue) Save added in v0.3.0

func (q *Queue) Save(path string) error

Save the state of the queue to JSON

func (*Queue) Skip

func (q *Queue) Skip(s string) error

moves the specified Topic to the end of the Queue

type QueueCommand

type QueueCommand int

Enum for commands for discussion queues

const (
	QError QueueCommand = iota
	QAdd
	QRemove
	QNext
	QBump
	QSkip
	QAttach
	QDetach
	QList
)

func ArgToQueueCommand

func ArgToQueueCommand(arg string) QueueCommand

parse a string arg into a QueueCommand

func (QueueCommand) String

func (qc QueueCommand) String() string

type Topic

type Topic struct {
	Name        string    `json:"name"`        // the name of the topic
	Description string    `json:"description"` // longer description of the topic
	Sources     []string  `json:"sources"`     // an optional list of links to source articles
	Modified    time.Time `json:"modified"`
	Created     time.Time `json:"created"`
	CreatedBy   string    `json:"created_by"` // original author username of the topic
}

Defines data for a discrete discussion topic

func (*Topic) Embed added in v0.3.0

func (t *Topic) Embed() *discordgo.MessageEmbed

Built in Embed function for Topics, primarily used for queue.Next()

Jump to

Keyboard shortcuts

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