quotes

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package quotes implements a plugin to save and replay quotes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(b bot.Bot, f string)

Register registers the plugin with a bot.

Types

type Quote

type Quote struct {
	ID              int    `json:"-"` // ignore ID in JSON as it's the map key
	Added, By, Text string `json:",omitempty"`
}

A Quote represents a quote text, added by a nick at a given time.

func (Quote) String

func (q Quote) String() string

String formats a single quote.

type Quotes

type Quotes struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Quotes is the main structure to hold quotes in the plugin.

func NewQuotes

func NewQuotes() *Quotes

NewQuotes creates a new initialized Quotes.

func (*Quotes) Add

func (q *Quotes) Add(by, text string) Quote

Add adds a new quote and return it.

func (*Quotes) Delete

func (q *Quotes) Delete(id int) bool

Delete removes a quote by its ID and returns whether it was there.

func (*Quotes) Empty

func (q *Quotes) Empty() bool

Empty returns whether there are no quotes yet.

func (*Quotes) Get

func (q *Quotes) Get(id int) (Quote, bool)

Get obtains a quote by its ID, boolean if found.

func (*Quotes) Random

func (q *Quotes) Random() Quote

Random picks a random quote (empty if no quotes).

func (*Quotes) Search

func (q *Quotes) Search(term string) []Quote

Search finds quotes with simple contains or regexp.

Jump to

Keyboard shortcuts

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