soundboard

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: MIT Imports: 28 Imported by: 0

README

Soundboard

Soundboard plugin for YAGPDB

Folder structure:

Sounds waiting:

soundboard/queue/guildid/soundhash.extension

Transcoded sounds

soundboard/ready/guildid/soundhash.dca

Documentation

Index

Constants

View Source
const (
	MaxGuildSounds        = 50
	MaxGuildSoundsPremium = 250
)

Variables

View Source
var (
	ErrVoiceSendTimeout = errors.New("Voice send timeout")
)
View Source
var (
	Silence = []byte{0xF8, 0xFF, 0xFE}
)

Functions

func DownloadNewSoundFile added in v1.4.1

func DownloadNewSoundFile(r io.Reader, w io.Writer, limit int) (tooBig bool, err error)

func HandleDelete

func HandleDelete(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func HandleGetCP

func HandleGetCP(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func HandleNew

func HandleNew(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func HandleUpdate

func HandleUpdate(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)

func KeySoundLock

func KeySoundLock(id uint) string

func ListSounds

func ListSounds(config *SoundboardConfig, ms *dstate.MemberState) string

func MaxSoundsForContext added in v1.6.0

func MaxSoundsForContext(ctx context.Context) int

func RegisterPlugin

func RegisterPlugin()

func RequestPlaySound

func RequestPlaySound(guildID int64, channelID, channelRanFrom int64, soundID uint) (queued bool)

RequestPlaySound either queues up a sound to be played in an existing player or creates a new one

func SoundFilePath

func SoundFilePath(id uint, status TranscodingStatus) string

Types

type PlayRequest

type PlayRequest struct {
	ChannelID      int64
	GuildID        int64
	CommandRanFrom int64
	Sound          uint
}

type Plugin

type Plugin struct{}

func (*Plugin) AddCommands added in v1.4.1

func (p *Plugin) AddCommands()

func (*Plugin) BotInit added in v1.4.1

func (p *Plugin) BotInit()

func (*Plugin) GetGuildConfig

func (p *Plugin) GetGuildConfig(ctx context.Context, guildID int64, dest configstore.GuildConfig) (err error)

GetGuildConfig returns a GuildConfig item from db

func (*Plugin) InitWeb

func (p *Plugin) InitWeb()

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) SetGuildConfig

func (p *Plugin) SetGuildConfig(ctx context.Context, conf configstore.GuildConfig) error

SetGuildConfig saves the GuildConfig struct

func (*Plugin) SetIfLatest

func (p *Plugin) SetIfLatest(ctx context.Context, conf configstore.GuildConfig) (updated bool, err error)

SetIfLatest saves it only if the passedLatest time is the latest version

func (*Plugin) StopBot

func (p *Plugin) StopBot(wg *sync.WaitGroup)

type SoundboardConfig

type SoundboardConfig struct {
	configstore.GuildConfigModel

	Sounds []*SoundboardSound `gorm:"ForeignKey:GuildID;AssociationForeignKey:GuildID"`
}

func (*SoundboardConfig) GetName

func (sc *SoundboardConfig) GetName() string

type SoundboardSound

type SoundboardSound struct {
	common.SmallModel

	GuildID      int64  `gorm:"index"`
	RequiredRole string `valid:"role,true"`
	Name         string `valid:",1,100"`
	Status       TranscodingStatus
}

func (*SoundboardSound) CanPlay

func (s *SoundboardSound) CanPlay(roles []int64) bool

type TranscodingStatus

type TranscodingStatus int
const (
	// In the transcoding queue
	TranscodingStatusQueued TranscodingStatus = iota
	// Done transcoding and ready to be played
	TranscodingStatusReady
	// Currently transcoding
	TranscodingStatusTranscoding
	// Failed transcoding, too long
	TranscodingStatusFailedLong
	// Failed transcofing, contact support
	TranscodingStatusFailedOther
)

func (TranscodingStatus) String

func (s TranscodingStatus) String() string

Jump to

Keyboard shortcuts

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