voice

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePlayingSongEmbed

func GeneratePlayingSongEmbed(message *PlayMessage) *discordgo.MessageEmbed

GeneratePlayingSongEmbed un mensaje embed para mostrar que se está agregando una canción a la cola de reproducción.

Types

type ChatSessionImpl

type ChatSessionImpl struct {
	DiscordSession DiscordSessionWrapper // Sesión de Discord para enviar mensajes de texto y manejar la voz.
	GuildID        string                // ID del servidor de Discord al que pertenece la sesión.

	DCAStreamer codec.DCAStreamer
	// contains filtered or unexported fields
}

ChatSessionImpl representa una sesión de chat de voz en Discord.

func (*ChatSessionImpl) Close

func (session *ChatSessionImpl) Close() error

Close cierra la sesión de Discord.

func (*ChatSessionImpl) JoinVoiceChannel

func (session *ChatSessionImpl) JoinVoiceChannel(channelID string) error

JoinVoiceChannel se une a un canal de voz en Discord.

func (*ChatSessionImpl) LeaveVoiceChannel

func (session *ChatSessionImpl) LeaveVoiceChannel() error

LeaveVoiceChannel abandona el canal de voz en Discord.

func (*ChatSessionImpl) SendAudio

func (session *ChatSessionImpl) SendAudio(ctx context.Context, reader io.Reader, positionCallback func(time.Duration)) error

SendAudio envía datos de audio a través de la conexión de voz en Discord utilizando el códec DCA.

type ConnectionWrapper

type ConnectionWrapper interface {
	Disconnect() error
	Speaking(flag bool) error
	OpusSend(data []byte, mode int) (ok bool, err error)
	OpusSendChan() chan<- []byte
}

ConnectionWrapper es una interfaz que envuelve los métodos de discordgo.VoiceConnection que necesitamos mockear.

type ConnectionWrapperImpl

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

ConnectionWrapperImpl es una implementación concreta de ConnectionWrapper que envuelve una instancia de discordgo.VoiceConnection.

func (*ConnectionWrapperImpl) Disconnect

func (w *ConnectionWrapperImpl) Disconnect() error

func (*ConnectionWrapperImpl) OpusSend

func (w *ConnectionWrapperImpl) OpusSend(data []byte, mode int) (bool, error)

func (*ConnectionWrapperImpl) OpusSendChan

func (w *ConnectionWrapperImpl) OpusSendChan() chan<- []byte

func (*ConnectionWrapperImpl) Speaking

func (w *ConnectionWrapperImpl) Speaking(flag bool) error

type DiscordSessionWrapper

type DiscordSessionWrapper interface {
	ChannelVoiceJoin(guildID, channelID string, muted, deafened bool) (*discordgo.VoiceConnection, error)
	Close() error
}

DiscordSessionWrapper es una interfaz que envuelve los métodos de discordgo.Session que necesitamos mockear.

type DiscordSessionWrapperImpl

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

DiscordSessionWrapperImpl es una implementación concreta de DiscordSessionWrapper que envuelve una instancia de discordgo.Session.

func (*DiscordSessionWrapperImpl) ChannelVoiceJoin

func (w *DiscordSessionWrapperImpl) ChannelVoiceJoin(guildID, channelID string, muted, deafened bool) (*discordgo.VoiceConnection, error)

func (*DiscordSessionWrapperImpl) Close

func (w *DiscordSessionWrapperImpl) Close() error

type MockDCAStreamer

type MockDCAStreamer struct {
	mock.Mock
}

func (*MockDCAStreamer) StreamDCAData

func (m *MockDCAStreamer) StreamDCAData(ctx context.Context, dca io.Reader, opusChan chan<- []byte, positionCallback func(position time.Duration)) error

type MockDiscordSessionWrapper

type MockDiscordSessionWrapper struct {
	mock.Mock
}

func (*MockDiscordSessionWrapper) ChannelVoiceJoin

func (m *MockDiscordSessionWrapper) ChannelVoiceJoin(guildID, channelID string, muted, deafened bool) (*discordgo.VoiceConnection, error)

func (*MockDiscordSessionWrapper) Close

func (m *MockDiscordSessionWrapper) Close() error

type MockVoiceConnectionWrapper

type MockVoiceConnectionWrapper struct {
	mock.Mock
}

func (*MockVoiceConnectionWrapper) Disconnect

func (m *MockVoiceConnectionWrapper) Disconnect() error

func (*MockVoiceConnectionWrapper) OpusSend

func (m *MockVoiceConnectionWrapper) OpusSend(data []byte, mode int) (ok bool, err error)

func (*MockVoiceConnectionWrapper) OpusSendChan

func (m *MockVoiceConnectionWrapper) OpusSendChan() chan<- []byte

func (*MockVoiceConnectionWrapper) Speaking

func (m *MockVoiceConnectionWrapper) Speaking(flag bool) error

type PlayMessage

type PlayMessage struct {
	Song     *Song
	Position time.Duration
}

PlayMessage es el mensaje que se enviará al canal de texto para mostrar la canción que se está reproduciendo actualmente.

type PlayedSong

type PlayedSong struct {
	Song
	Position time.Duration
}

PlayedSong representa una canción que ha sido reproducida.

type Song

type Song struct {
	Type          string
	Title         string
	URL           string
	Playable      bool
	ThumbnailURL  *string
	Duration      time.Duration
	StartPosition time.Duration
	RequestedBy   *string
}

Song representa una canción que se puede reproducir.

func (*Song) GetHumanName

func (s *Song) GetHumanName() string

GetHumanName devuelve el nombre humano legible de la canción.

type VoiceChatSession

type VoiceChatSession interface {
	Close() error
	JoinVoiceChannel(channelID string) error
	LeaveVoiceChannel() error
	SendAudio(ctx context.Context, reader io.Reader, positionCallback func(time.Duration)) error
}

VoiceChatSession define métodos para interactuar con la sesión de voz del bot de Discord.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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