framework

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHANNELS   int = 2
	FRAME_RATE int = 48000
	FRAME_SIZE int = 960
	MAX_BYTES  int = (FRAME_SIZE * 2) * 2
)
View Source
const (
	ERROR_TYPE    = -1
	VIDEO_TYPE    = 0
	PLAYLIST_TYPE = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdMap

type CmdMap map[string]CommandStruct

type Command

type Command func(Context)

type CommandHandler

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

func NewCommandHandler

func NewCommandHandler() *CommandHandler

func (CommandHandler) Get

func (handler CommandHandler) Get(name string) (*Command, bool)

func (CommandHandler) GetCmds

func (handler CommandHandler) GetCmds() CmdMap

func (CommandHandler) Register

func (handler CommandHandler) Register(name string, command Command, helpmsg string)

type CommandStruct

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

func (CommandStruct) GetHelp

func (command CommandStruct) GetHelp() string

type Config

type Config struct {
	Prefix        string `json:"prefix"`
	ServiceUrl    string `json:"service_url"`
	BotToken      string `json:"bot_token"`
	OwnerId       string `json:"owner_id"`
	UseSharding   bool   `json:"use_sharding"`
	ShardId       int    `json:"shard_id"`
	ShardCount    int    `json:"shard_count"`
	DefaultStatus string `json:"default_status"`
}

func LoadConfig

func LoadConfig(filename string) *Config

type Connection

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

func NewConnection

func NewConnection(voiceConnection *discordgo.VoiceConnection) *Connection

func (Connection) Disconnect

func (connection Connection) Disconnect()

func (*Connection) Play

func (connection *Connection) Play(ffmpeg *exec.Cmd) error

func (*Connection) Stop

func (connection *Connection) Stop()

type Context

type Context struct {
	Discord      *discordgo.Session
	Guild        *discordgo.Guild
	VoiceChannel *discordgo.Channel
	TextChannel  *discordgo.Channel
	User         *discordgo.User
	Message      *discordgo.MessageCreate
	Args         []string

	// dependency injection?
	Conf       *Config
	CmdHandler *CommandHandler
	Sessions   *SessionManager
	Youtube    *Youtube
}

func NewContext

func NewContext(discord *discordgo.Session, guild *discordgo.Guild, textChannel *discordgo.Channel,
	user *discordgo.User, message *discordgo.MessageCreate, conf *Config, cmdHandler *CommandHandler,
	sessions *SessionManager, youtube *Youtube) *Context

func (*Context) GetVoiceChannel

func (ctx *Context) GetVoiceChannel() *discordgo.Channel

func (Context) Reply

func (ctx Context) Reply(content string) *discordgo.Message

type JoinProperties

type JoinProperties struct {
	Muted    bool
	Deafened bool
}

type PlaylistVideo

type PlaylistVideo struct {
	Id string `json:"id"`
}

type Session

type Session struct {
	Queue     *SongQueue
	ChannelId string
	// contains filtered or unexported fields
}

func (Session) Play

func (sess Session) Play(song Song) error

func (*Session) Stop

func (sess *Session) Stop()

type SessionManager

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

func NewSessionManager

func NewSessionManager() *SessionManager

func (SessionManager) GetByChannel

func (manager SessionManager) GetByChannel(channelId string) (*Session, bool)

func (SessionManager) GetByGuild

func (manager SessionManager) GetByGuild(guildId string) *Session

func (*SessionManager) Join

func (manager *SessionManager) Join(discord *discordgo.Session, guildId, channelId string,
	properties JoinProperties) (*Session, error)

func (*SessionManager) Leave

func (manager *SessionManager) Leave(discord *discordgo.Session, session Session)

type Song

type Song struct {
	Media    string
	Title    string
	Duration *string
	Id       string
}

func NewSong

func NewSong(media, title, id string) *Song

func (Song) Ffmpeg

func (song Song) Ffmpeg() *exec.Cmd

type SongQueue

type SongQueue struct {
	Running bool
	// contains filtered or unexported fields
}

func (*SongQueue) Add

func (queue *SongQueue) Add(song Song)

func (*SongQueue) Clear

func (queue *SongQueue) Clear()

func (*SongQueue) Current

func (queue *SongQueue) Current() *Song

func (SongQueue) Get

func (queue SongQueue) Get() []Song

func (SongQueue) HasNext

func (queue SongQueue) HasNext() bool

func (*SongQueue) Next

func (queue *SongQueue) Next() Song

func (*SongQueue) Pause

func (queue *SongQueue) Pause()

func (*SongQueue) Set

func (queue *SongQueue) Set(list []Song)

func (*SongQueue) Start

func (queue *SongQueue) Start(sess *Session, callback func(string))

type VideoResult

type VideoResult struct {
	Media string
	Title string
}

type Youtube

type Youtube struct {
	Conf *Config
}

func (Youtube) Get

func (youtube Youtube) Get(input string) (int, *string, error)

func (Youtube) Playlist

func (youtube Youtube) Playlist(input string) (*[]PlaylistVideo, error)

func (Youtube) Video

func (youtube Youtube) Video(input string) (*VideoResult, error)

Jump to

Keyboard shortcuts

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