queue

package
v0.0.0-...-b62c219 Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LPut puts elements into the list at the specified index
	// Keys:
	// - list to put the elements into
	// Values:
	// - ...json.Marshalled map[int]string where K is position and V is the value to insert
	LPut = redis.NewScript(_escFSMustString(false, "/redis_scripts/lput.lua"))

	// LOverride resets the elements in a list
	// Keys:
	// - list to override
	// Values:
	// - ...values to insert
	LOverride = redis.NewScript(_escFSMustString(false, "/redis_scripts/loverride.lua"))

	// LMove moves an element in a list
	// Keys:
	// - the list to move the elements in
	// Values:
	// - (int) from index
	// - (int) to index
	LMove = redis.NewScript(_escFSMustString(false, "/redis_scripts/lmove.lua"))

	// LShuffle shuffles a list
	// Keys:
	// - the list to shuffle
	// Values:
	// - randomization seed
	LShuffle = redis.NewScript(_escFSMustString(false, "/redis_scripts/lshuffle.lua"))

	// LRevSplice splices a list in reverse
	// Keys:
	// - the list to splice
	// Values:
	// - (int) start: the index to start splicing at
	// - (int) deleteCount: the number of elements to remove
	// - ...elements to insert
	LRevSplice = redis.NewScript(_escFSMustString(false, "/redis_scripts/lrevsplice.lua"))

	// MultiRPopLPush moves multiple elements from the right of one list to the left of another
	// Keys:
	// - RPop list
	// - LPush list
	// Values:
	// - (int) count: number of elements to move
	MultiRPopLPush = redis.NewScript(_escFSMustString(false, "/redis_scripts/multirpoplpush.lua"))
)

Functions

This section is empty.

Types

type Queue

type Queue interface {
	Add(guildID uint64, tracks []string) error
	Set(guildID uint64, tracks []string) error
	Put(guildID uint64, tracks map[int]string) error
	Unshift(guildID uint64, tracks ...string) error
	Remove(guildID uint64, index int) error
	Next(guildID uint64, count int) ([]string, error)
	Move(guildID uint64, from, to int) error
	Shuffle(guildID uint64) ([]string, error)
	Splice(guildID uint64, start, deleteCount int, tracks ...string) ([]string, error)
	Trim(guildID uint64, start, end int) error
	NowPlaying(guildID uint64) (string, error)
	List(guildID uint64, index int, count uint) ([]string, error)
}

Queue represents a store of songs

type RedisQueue

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

RedisQueue represents a song queue in redis

func Redis

func Redis(c *redis.Client) *RedisQueue

Redis makes a new Redis queue

func (*RedisQueue) Add

func (q *RedisQueue) Add(guildID uint64, tracks []string) error

Add adds songs to the end queue

func (*RedisQueue) List

func (q *RedisQueue) List(guildID uint64, index int, count uint) (tracks []string, err error)

List lists the songs in the queue

func (*RedisQueue) Move

func (q *RedisQueue) Move(guildID uint64, from, to int) error

Move moves songs in the list by index

func (*RedisQueue) Next

func (q *RedisQueue) Next(guildID uint64, count int) (skipped []string, err error)

Next advances the playlist

func (*RedisQueue) NowPlaying

func (q *RedisQueue) NowPlaying(guildID uint64) (np string, err error)

NowPlaying gets the currently playing track

func (*RedisQueue) Put

func (q *RedisQueue) Put(guildID uint64, tracks map[int]string) error

Put puts the specified elements into the queue at the specified positions

func (*RedisQueue) Remove

func (q *RedisQueue) Remove(guildID uint64, index int) error

Remove removes a song from the queue at the index

func (*RedisQueue) Set

func (q *RedisQueue) Set(guildID uint64, tracks []string) error

Set overwrites songs in the queue

func (*RedisQueue) Shuffle

func (q *RedisQueue) Shuffle(guildID uint64) (list []string, err error)

Shuffle shuffles the queue

func (*RedisQueue) Splice

func (q *RedisQueue) Splice(guildID uint64, start, deleteCount int, tracks ...string) (list []string, err error)

Splice splices the queue

func (*RedisQueue) Trim

func (q *RedisQueue) Trim(guildID uint64, start, end int) error

Trim trims the queue

func (*RedisQueue) Unshift

func (q *RedisQueue) Unshift(guildID uint64, tracks ...string) error

Unshift adds songs to the front of the queue

Jump to

Keyboard shortcuts

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