Documentation ¶
Index ¶
- Variables
- func DownloadMultipleYoutubeVideo(input string) (*[]VideoInfo, error)
- func DownloadSingleYoutubeVideo(input string) (*[]VideoInfo, error)
- func DownloadYoutubeVideo(input string) (*[]VideoInfo, error)
- func Insert(vi *VideoInfo, mc *discordgo.Message, ctx *Context)
- func JoinUserVoiceChannel(session *discordgo.Session, userID string) (*discordgo.VoiceConnection, error)
- func MaybePlaySong(ds *discordgo.Session, mc *discordgo.Message, ctx *Context)
- func PlayAudioFile(v *discordgo.VoiceConnection, filename string, stop <-chan bool)
- func ReceivePCM(v *discordgo.VoiceConnection, c chan *discordgo.Packet)
- func RemoveSong(guildID string, store *Store)
- func SendPCM(v *discordgo.VoiceConnection, pcm <-chan []int16)
- func UpsertUserInfo(db *sql.DB, user *discordgo.User) error
- type Context
- type HandlerFunc
- type Mux
- func (m *Mux) ConnectDB(filename string)
- func (m *Mux) ListRoutes(ds *discordgo.Session)
- func (m *Mux) Match(msg string) (*Route, error)
- func (m *Mux) OnMessageCreate(ds *discordgo.Session, mc *discordgo.MessageCreate)
- func (m *Mux) Route(pattern []string, desc string, cb HandlerFunc) (*Route, error)
- type Route
- type Song
- type Store
- type VideoInfo
Constants ¶
This section is empty.
Variables ¶
var OnError = func(str string, err error) { prefix := "dgVoice: " + str if err != nil { os.Stderr.WriteString(prefix + ": " + err.Error()) } else { os.Stderr.WriteString(prefix) } }
OnError gets called when an error is encountered. By default logs to STDERR
Functions ¶
func DownloadMultipleYoutubeVideo ¶
DownloadMultipleYoutubeVideo will download an entire youtube playlist video a url to the playlist is required.
func DownloadSingleYoutubeVideo ¶
DownloadSingleYoutubeVideo will download a single youtube video when a search term or a direct link is provided.
func DownloadYoutubeVideo ¶
DownloadYoutubeVideo will parse the input and grab the appropriate video. The input can either be a search term or a direct link to a single video or a playlist.
func JoinUserVoiceChannel ¶
func JoinUserVoiceChannel(session *discordgo.Session, userID string) (*discordgo.VoiceConnection, error)
JoinUserVoiceChannel ...
func MaybePlaySong ¶
MaybePlaySong will check if there is anything playing on the related Guild, if there is not and there is something in the queue it will start playing the next video in the queue.
func PlayAudioFile ¶
func PlayAudioFile(v *discordgo.VoiceConnection, filename string, stop <-chan bool)
PlayAudioFile will play the given filename to the already connected Discord voice server/channel. voice websocket and udp socket must already be setup before this will work.
func ReceivePCM ¶
func ReceivePCM(v *discordgo.VoiceConnection, c chan *discordgo.Packet)
ReceivePCM will receive on the the Discordgo OpusRecv channel and decode the opus audio into PCM then send it on the provided channel.
func RemoveSong ¶
RemoveSong will remove the song at the front of the queue for the related Guild
func SendPCM ¶
func SendPCM(v *discordgo.VoiceConnection, pcm <-chan []int16)
SendPCM will receive on the provied channel encode received PCM data into Opus then send that to Discordgo
Types ¶
type Context ¶
type Context struct { Fields []string Content string DatabaseConnection *sql.DB GuildID string IsDirected bool IsPrivate bool HasPrefix bool HasMention bool HasMentionFirst bool Info *Store }
Context holds extra data that is passed along to route handlers This way processing some of this only need to happen once
type HandlerFunc ¶
HandlerFunc is the function signature required for a message route handler
type Mux ¶
type Mux struct { Routes []*Route Default *Route Prefix string DatabaseConnection *sql.DB Info *Store }
Mux is the main struct for all mux methods.
func (*Mux) ConnectDB ¶
ConnectDB will connect the multiplexer to a database that holds information about the users on the discord server
func (*Mux) ListRoutes ¶
ListRoutes will list all of the routes into the chat
func (*Mux) OnMessageCreate ¶
func (m *Mux) OnMessageCreate(ds *discordgo.Session, mc *discordgo.MessageCreate)
OnMessageCreate is a DiscordGo Event Handler function. This function will receive all Discord message and parse themm for matches to registered routes.
type Route ¶
type Route struct { Pattern []string Description string Help string Run HandlerFunc }
Route holds information about a specific message route handler