runtime

package
v0.0.0-...-27d56bb Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDiscordHelper

func NewDiscordHelper(session *discordgo.Session) shared.Helper

NewDiscordHelper creates a new DiscordHelper with the given Discord session

Types

type DiscordHelper

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

DiscordHelper implements the Helper interface using an actual Discord session

func (*DiscordHelper) ApplicationCommandCreate

func (h *DiscordHelper) ApplicationCommandCreate(appID string, guildID string, cmd *discordgo.ApplicationCommand) (*discordgo.ApplicationCommand, error)

func (*DiscordHelper) ApplicationCommandDelete

func (h *DiscordHelper) ApplicationCommandDelete(appID, guildID, cmdID string) error

func (*DiscordHelper) ApplicationCommandEdit

func (h *DiscordHelper) ApplicationCommandEdit(appID, guildID, cmdID string, cmd *discordgo.ApplicationCommand) (*discordgo.ApplicationCommand, error)

func (*DiscordHelper) ApplicationCommands

func (h *DiscordHelper) ApplicationCommands(appID, guildID string) ([]*discordgo.ApplicationCommand, error)

func (*DiscordHelper) Channel

func (h *DiscordHelper) Channel(channelID string) (*discordgo.Channel, error)

func (*DiscordHelper) ChannelDelete

func (h *DiscordHelper) ChannelDelete(channelID string) (*discordgo.Channel, error)

func (*DiscordHelper) ChannelEdit

func (h *DiscordHelper) ChannelEdit(channelID string, data *discordgo.ChannelEdit) (*discordgo.Channel, error)

func (*DiscordHelper) ChannelMessage

func (h *DiscordHelper) ChannelMessage(channelID, messageID string) (*discordgo.Message, error)

func (*DiscordHelper) ChannelMessageDelete

func (h *DiscordHelper) ChannelMessageDelete(channelID, messageID string) error

func (*DiscordHelper) ChannelMessageEdit

func (h *DiscordHelper) ChannelMessageEdit(channelID, messageID, content string) (*discordgo.Message, error)

func (*DiscordHelper) ChannelMessageEditComplex

func (h *DiscordHelper) ChannelMessageEditComplex(m *discordgo.MessageEdit) (*discordgo.Message, error)

func (*DiscordHelper) ChannelMessageSend

func (h *DiscordHelper) ChannelMessageSend(channelID string, content string) (*discordgo.Message, error)

func (*DiscordHelper) ChannelMessageSendComplex

func (h *DiscordHelper) ChannelMessageSendComplex(channelID string, data *discordgo.MessageSend) (*discordgo.Message, error)

func (*DiscordHelper) ChannelMessageSendEmbed

func (h *DiscordHelper) ChannelMessageSendEmbed(channelID string, embed *discordgo.MessageEmbed) (*discordgo.Message, error)

func (*DiscordHelper) ChannelMessageSendEmbeds

func (h *DiscordHelper) ChannelMessageSendEmbeds(channelID string, embeds []*discordgo.MessageEmbed) (*discordgo.Message, error)

func (*DiscordHelper) ChannelMessages

func (h *DiscordHelper) ChannelMessages(channelID string, limit int, beforeID, afterID, aroundID string) ([]*discordgo.Message, error)

func (*DiscordHelper) ChannelTyping

func (h *DiscordHelper) ChannelTyping(channelID string) error

func (*DiscordHelper) Gateway

func (h *DiscordHelper) Gateway() (string, error)

func (*DiscordHelper) GatewayBot

func (h *DiscordHelper) GatewayBot() (*discordgo.GatewayBotResponse, error)

func (*DiscordHelper) Guild

func (h *DiscordHelper) Guild(guildID string) (*discordgo.Guild, error)

func (*DiscordHelper) GuildChannels

func (h *DiscordHelper) GuildChannels(guildID string) ([]*discordgo.Channel, error)

func (*DiscordHelper) GuildMember

func (h *DiscordHelper) GuildMember(guildID, userID string) (*discordgo.Member, error)

func (*DiscordHelper) GuildMembers

func (h *DiscordHelper) GuildMembers(guildID string, after string, limit int) ([]*discordgo.Member, error)

func (*DiscordHelper) GuildRoles

func (h *DiscordHelper) GuildRoles(guildID string) ([]*discordgo.Role, error)

func (*DiscordHelper) InteractionRespond

func (h *DiscordHelper) InteractionRespond(interaction *discordgo.Interaction, resp *discordgo.InteractionResponse) error

func (*DiscordHelper) InteractionResponseDelete

func (h *DiscordHelper) InteractionResponseDelete(interaction *discordgo.Interaction) error

func (*DiscordHelper) InteractionResponseEdit

func (h *DiscordHelper) InteractionResponseEdit(interaction *discordgo.Interaction, newresp *discordgo.WebhookEdit) (*discordgo.Message, error)

func (*DiscordHelper) MessageReactionAdd

func (h *DiscordHelper) MessageReactionAdd(channelID, messageID, emojiID string) error

func (*DiscordHelper) MessageReactionRemove

func (h *DiscordHelper) MessageReactionRemove(channelID, messageID, emojiID, userID string) error

func (*DiscordHelper) MessageReactionsRemoveAll

func (h *DiscordHelper) MessageReactionsRemoveAll(channelID, messageID string) error

func (*DiscordHelper) ThreadJoin

func (h *DiscordHelper) ThreadJoin(threadID string) error

func (*DiscordHelper) ThreadLeave

func (h *DiscordHelper) ThreadLeave(threadID string) error

func (*DiscordHelper) ThreadMemberAdd

func (h *DiscordHelper) ThreadMemberAdd(threadID, memberID string) error

func (*DiscordHelper) ThreadMemberRemove

func (h *DiscordHelper) ThreadMemberRemove(threadID, memberID string) error

func (*DiscordHelper) ThreadStart

func (h *DiscordHelper) ThreadStart(channelID, name string, typ discordgo.ChannelType, archiveDuration int) (*discordgo.Channel, error)

func (*DiscordHelper) User

func (h *DiscordHelper) User(userID string) (*discordgo.User, error)

func (*DiscordHelper) UserChannelCreate

func (h *DiscordHelper) UserChannelCreate(recipientID string) (*discordgo.Channel, error)

func (*DiscordHelper) UserChannelPermissions

func (h *DiscordHelper) UserChannelPermissions(userID, channelID string) (int64, error)

func (*DiscordHelper) VoiceRegions

func (h *DiscordHelper) VoiceRegions() ([]*discordgo.VoiceRegion, error)

func (*DiscordHelper) WebhookCreate

func (h *DiscordHelper) WebhookCreate(channelID, name, avatar string) (*discordgo.Webhook, error)

func (*DiscordHelper) WebhookExecute

func (h *DiscordHelper) WebhookExecute(webhookID, token string, wait bool, data *discordgo.WebhookParams) (*discordgo.Message, error)

type HelperClientImpl

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

HelperClientImpl implements the Helper interface for runtime-side operations. This is usually not needed since runtime provides helpers, but included for completeness.

func (*HelperClientImpl) ApplicationCommandCreate

func (h *HelperClientImpl) ApplicationCommandCreate(appID string, guildID string, cmd *discordgo.ApplicationCommand) (*discordgo.ApplicationCommand, error)

func (*HelperClientImpl) ApplicationCommandDelete

func (h *HelperClientImpl) ApplicationCommandDelete(appID, guildID, cmdID string) error

func (*HelperClientImpl) ApplicationCommandEdit

func (h *HelperClientImpl) ApplicationCommandEdit(appID, guildID, cmdID string, cmd *discordgo.ApplicationCommand) (*discordgo.ApplicationCommand, error)

func (*HelperClientImpl) ApplicationCommands

func (h *HelperClientImpl) ApplicationCommands(appID, guildID string) ([]*discordgo.ApplicationCommand, error)

func (*HelperClientImpl) Channel

func (h *HelperClientImpl) Channel(channelID string) (*discordgo.Channel, error)

func (*HelperClientImpl) ChannelDelete

func (h *HelperClientImpl) ChannelDelete(channelID string) (*discordgo.Channel, error)

func (*HelperClientImpl) ChannelEdit

func (h *HelperClientImpl) ChannelEdit(channelID string, data *discordgo.ChannelEdit) (*discordgo.Channel, error)

func (*HelperClientImpl) ChannelMessage

func (h *HelperClientImpl) ChannelMessage(channelID, messageID string) (*discordgo.Message, error)

func (*HelperClientImpl) ChannelMessageDelete

func (h *HelperClientImpl) ChannelMessageDelete(channelID, messageID string) error

func (*HelperClientImpl) ChannelMessageEdit

func (h *HelperClientImpl) ChannelMessageEdit(channelID, messageID, content string) (*discordgo.Message, error)

func (*HelperClientImpl) ChannelMessageEditComplex

func (h *HelperClientImpl) ChannelMessageEditComplex(m *discordgo.MessageEdit) (*discordgo.Message, error)

func (*HelperClientImpl) ChannelMessageSend

func (h *HelperClientImpl) ChannelMessageSend(channelID string, content string) (*discordgo.Message, error)

Minimal implementation for interface compliance - just enough to satisfy shared.Helper interface

func (*HelperClientImpl) ChannelMessageSendComplex

func (h *HelperClientImpl) ChannelMessageSendComplex(channelID string, data *discordgo.MessageSend) (*discordgo.Message, error)

func (*HelperClientImpl) ChannelMessageSendEmbed

func (h *HelperClientImpl) ChannelMessageSendEmbed(channelID string, embed *discordgo.MessageEmbed) (*discordgo.Message, error)

func (*HelperClientImpl) ChannelMessageSendEmbeds

func (h *HelperClientImpl) ChannelMessageSendEmbeds(channelID string, embeds []*discordgo.MessageEmbed) (*discordgo.Message, error)

func (*HelperClientImpl) ChannelMessages

func (h *HelperClientImpl) ChannelMessages(channelID string, limit int, beforeID, afterID, aroundID string) ([]*discordgo.Message, error)

func (*HelperClientImpl) ChannelTyping

func (h *HelperClientImpl) ChannelTyping(channelID string) error

func (*HelperClientImpl) Gateway

func (h *HelperClientImpl) Gateway() (string, error)

func (*HelperClientImpl) GatewayBot

func (h *HelperClientImpl) GatewayBot() (*discordgo.GatewayBotResponse, error)

func (*HelperClientImpl) Guild

func (h *HelperClientImpl) Guild(guildID string) (*discordgo.Guild, error)

func (*HelperClientImpl) GuildChannels

func (h *HelperClientImpl) GuildChannels(guildID string) ([]*discordgo.Channel, error)

func (*HelperClientImpl) GuildMember

func (h *HelperClientImpl) GuildMember(guildID, userID string) (*discordgo.Member, error)

func (*HelperClientImpl) GuildMembers

func (h *HelperClientImpl) GuildMembers(guildID string, after string, limit int) ([]*discordgo.Member, error)

func (*HelperClientImpl) GuildRoles

func (h *HelperClientImpl) GuildRoles(guildID string) ([]*discordgo.Role, error)

func (*HelperClientImpl) InteractionRespond

func (h *HelperClientImpl) InteractionRespond(interaction *discordgo.Interaction, resp *discordgo.InteractionResponse) error

func (*HelperClientImpl) InteractionResponseEdit

func (h *HelperClientImpl) InteractionResponseEdit(interaction *discordgo.Interaction, newresp *discordgo.WebhookEdit) (*discordgo.Message, error)

func (*HelperClientImpl) MessageReactionAdd

func (h *HelperClientImpl) MessageReactionAdd(channelID, messageID, emojiID string) error

func (*HelperClientImpl) MessageReactionRemove

func (h *HelperClientImpl) MessageReactionRemove(channelID, messageID, emojiID, userID string) error

func (*HelperClientImpl) MessageReactionsRemoveAll

func (h *HelperClientImpl) MessageReactionsRemoveAll(channelID, messageID string) error

func (*HelperClientImpl) ThreadJoin

func (h *HelperClientImpl) ThreadJoin(threadID string) error

func (*HelperClientImpl) ThreadLeave

func (h *HelperClientImpl) ThreadLeave(threadID string) error

func (*HelperClientImpl) ThreadMemberAdd

func (h *HelperClientImpl) ThreadMemberAdd(threadID, memberID string) error

func (*HelperClientImpl) ThreadMemberRemove

func (h *HelperClientImpl) ThreadMemberRemove(threadID, memberID string) error

func (*HelperClientImpl) ThreadStart

func (h *HelperClientImpl) ThreadStart(channelID, name string, typ discordgo.ChannelType, archiveDuration int) (*discordgo.Channel, error)

func (*HelperClientImpl) User

func (h *HelperClientImpl) User(userID string) (*discordgo.User, error)

func (*HelperClientImpl) UserChannelCreate

func (h *HelperClientImpl) UserChannelCreate(recipientID string) (*discordgo.Channel, error)

func (*HelperClientImpl) UserChannelPermissions

func (h *HelperClientImpl) UserChannelPermissions(userID, channelID string) (int64, error)

func (*HelperClientImpl) VoiceRegions

func (h *HelperClientImpl) VoiceRegions() ([]*discordgo.VoiceRegion, error)

func (*HelperClientImpl) WebhookCreate

func (h *HelperClientImpl) WebhookCreate(channelID, name, avatar string) (*discordgo.Webhook, error)

func (*HelperClientImpl) WebhookExecute

func (h *HelperClientImpl) WebhookExecute(webhookID, token string, wait bool, data *discordgo.WebhookParams) (*discordgo.Message, error)

type HelperServerImpl

type HelperServerImpl struct {
	proto.UnimplementedHelperServer
	Impl shared.Helper // Helper implementation that provides Discord operations
	// contains filtered or unexported fields
}

HelperServerImpl implements the Helper gRPC server for the runtime-side. This server receives calls from the module and provides actual Discord operations.

func (*HelperServerImpl) Channel

Channel handles getting a channel by ID.

func (*HelperServerImpl) ChannelDelete

ChannelDelete handles deleting a channel.

func (*HelperServerImpl) ChannelEdit

ChannelEdit handles editing a channel.

func (*HelperServerImpl) ChannelMessage

ChannelMessage handles retrieving a single message from a channel.

func (*HelperServerImpl) ChannelMessageDelete

ChannelMessageDelete handles deleting a message from a channel.

func (*HelperServerImpl) ChannelMessageEdit

ChannelMessageEdit handles editing a message with simple text content.

func (*HelperServerImpl) ChannelMessageEditComplex

ChannelMessageEditComplex handles editing a message with complex data.

func (*HelperServerImpl) ChannelMessageSend

ChannelMessageSend handles sending a simple text message.

func (*HelperServerImpl) ChannelMessageSendComplex

ChannelMessageSendComplex handles sending a complex message with attachments, embeds, etc.

func (*HelperServerImpl) ChannelMessageSendEmbed

ChannelMessageSendEmbed handles sending a message with a single embed.

func (*HelperServerImpl) ChannelMessageSendEmbeds

ChannelMessageSendEmbeds handles sending a message with multiple embeds.

func (*HelperServerImpl) ChannelMessages

ChannelMessages handles retrieving multiple messages from a channel.

func (*HelperServerImpl) ChannelTyping

ChannelTyping handles sending typing indicator.

func (*HelperServerImpl) Guild

Guild handles getting a guild by ID.

func (*HelperServerImpl) GuildChannels

GuildChannels handles getting channels in a guild.

func (*HelperServerImpl) GuildMember

GuildMember handles getting a specific member in a guild.

func (*HelperServerImpl) GuildMembers

GuildMembers handles getting members in a guild.

func (*HelperServerImpl) GuildRoles

GuildRoles handles getting roles in a guild.

func (*HelperServerImpl) InteractionRespond

InteractionRespond handles responding to an interaction.

func (*HelperServerImpl) InteractionResponseEdit

InteractionResponseEdit handles editing an interaction response.

func (*HelperServerImpl) User

User handles getting a user by ID.

func (*HelperServerImpl) UserChannelCreate

UserChannelCreate handles creating a DM channel with a user.

type HookClient

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

`runtime/client.go` implements the gRPC client for making calls to the module.

This part works on the runtime-side and is the gRPC client implementation for the module.

func (*HookClient) OnCreateChatMessage

func (m *HookClient) OnCreateChatMessage(message *discordgo.Message) error

OnCreateChatMessage sends a message to the plugin via RPC.

func (*HookClient) OnCreateInteraction

func (m *HookClient) OnCreateInteraction(interaction *discordgo.Interaction) error

OnCreateInteraction sends an interaction to the plugin via RPC.

func (*HookClient) OnEvent

func (m *HookClient) OnEvent(event string) error

OnEvent sends an event to the plugin via RPC.

func (*HookClient) OnInit

func (m *HookClient) OnInit(helper shared.Helper) shared.InitResponse

OnInit calls the OnInit RPC method and returns the initialization response.

type ModuleSubscription

type ModuleSubscription struct {
	ModuleID     string
	ConnectionID string
	SubmitChan   chan *VoiceTask
	RecvChan     chan *pb.VoicePacket
	Stream       pb.VoiceStream_VoiceStreamServer

	CreatedAt    time.Time
	LastActivity time.Time
	// contains filtered or unexported fields
}

ModuleSubscription represents a module's subscription to a voice session

type Plugin

type Plugin struct {
	plugin.NetRPCUnsupportedPlugin

	Helper      shared.Helper // The implementation of the Helper interface (runtime side)
	Hook        shared.Hook   // Hook client to call module's hook functions
	VoiceHelper *VoiceHelper  // Voice streaming helper
}

FlexModule uses hashicorp/go-plugin: So we need to declare a separate Plugin for the runtime and module.

`runtime/server.go` implements the gRPC server for receiving from the module.

`runtime/client.go` implements the gRPC client for making calls to the module.

func (*Plugin) GRPCClient

func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*Plugin) GRPCServer

func (p *Plugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type QueueScheduler

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

QueueScheduler processes tasks from the queue and sends to VoiceConnection

func NewQueueScheduler

func NewQueueScheduler(queue *VoiceTaskQueue, vc *discordgo.VoiceConnection, ctx context.Context, log hclog.Logger) *QueueScheduler

NewQueueScheduler creates a new queue scheduler

func (*QueueScheduler) GetStats

func (s *QueueScheduler) GetStats() (tasksProcessed, bytesSent map[string]uint64)

GetStats returns scheduler statistics

func (*QueueScheduler) Start

func (s *QueueScheduler) Start()

Start begins processing tasks from the queue

func (*QueueScheduler) Stop

func (s *QueueScheduler) Stop()

Stop stops the scheduler

type ReceiveBroadcaster

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

ReceiveBroadcaster broadcasts received voice packets to all subscribers

func NewReceiveBroadcaster

func NewReceiveBroadcaster(vc *discordgo.VoiceConnection, ctx context.Context, log hclog.Logger) *ReceiveBroadcaster

NewReceiveBroadcaster creates a new receive broadcaster

func (*ReceiveBroadcaster) GetStats

func (b *ReceiveBroadcaster) GetStats() (packetsReceived uint64, packetsDropped map[string]uint64)

GetStats returns broadcaster statistics

func (*ReceiveBroadcaster) GetSubscriberCount

func (b *ReceiveBroadcaster) GetSubscriberCount() int

GetSubscriberCount returns the number of active subscribers

func (*ReceiveBroadcaster) Start

func (b *ReceiveBroadcaster) Start()

Start begins broadcasting received voice packets

func (*ReceiveBroadcaster) Stop

func (b *ReceiveBroadcaster) Stop()

Stop stops the broadcaster

func (*ReceiveBroadcaster) Subscribe

func (b *ReceiveBroadcaster) Subscribe(moduleID string, recvChan chan *pb.VoicePacket, filter func(*discordgo.Packet) bool)

Subscribe adds a new receiver

func (*ReceiveBroadcaster) Unsubscribe

func (b *ReceiveBroadcaster) Unsubscribe(moduleID string)

Unsubscribe removes a receiver

type RuntimeClients

type RuntimeClients struct {
	Hook        shared.Hook
	Helper      shared.Helper
	VoiceStream proto.VoiceStreamClient
}

RuntimeClients wraps both Hook and Helper clients for runtime

func (*RuntimeClients) GetHelper

func (r *RuntimeClients) GetHelper() shared.Helper

GetHelper returns the Helper client

func (*RuntimeClients) GetHook

func (r *RuntimeClients) GetHook() shared.Hook

GetHook returns the Hook client

func (*RuntimeClients) GetVoiceStream

func (r *RuntimeClients) GetVoiceStream() proto.VoiceStreamClient

GetVoiceStream returns the VoiceStream client

type VoiceHelper

type VoiceHelper struct {
	pb.UnimplementedVoiceStreamServer
	// contains filtered or unexported fields
}

VoiceHelper implements the VoiceStream gRPC service

func NewVoiceHelper

func NewVoiceHelper(session *discordgo.Session, log hclog.Logger) *VoiceHelper

NewVoiceHelper creates a new voice helper

func (*VoiceHelper) GetQueueStatus

func (h *VoiceHelper) GetQueueStatus(ctx context.Context, req *pb.QueueStatusRequest) (*pb.QueueStatusResponse, error)

GetQueueStatus implements VoiceStream.GetQueueStatus

func (*VoiceHelper) VoiceJoin

VoiceJoin implements VoiceStream.VoiceJoin

func (*VoiceHelper) VoiceLeave

func (h *VoiceHelper) VoiceLeave(ctx context.Context, req *pb.VoiceLeaveRequest) (*proto.Empty, error)

VoiceLeave implements VoiceStream.VoiceLeave

func (*VoiceHelper) VoiceSpeaking

func (h *VoiceHelper) VoiceSpeaking(ctx context.Context, req *pb.VoiceSpeakingRequest) (*proto.Empty, error)

VoiceSpeaking implements VoiceStream.VoiceSpeaking

func (*VoiceHelper) VoiceStream

func (h *VoiceHelper) VoiceStream(stream pb.VoiceStream_VoiceStreamServer) error

VoiceStream implements VoiceStream.VoiceStream

type VoiceReceiver

type VoiceReceiver struct {
	ModuleID string
	RecvChan chan *pb.VoicePacket
	Filter   func(*discordgo.Packet) bool // Optional filter
}

VoiceReceiver represents a module subscribed to receive voice data

type VoiceSession

type VoiceSession struct {
	GuildID   string
	ChannelID string
	// contains filtered or unexported fields
}

VoiceSession represents a voice session for a guild

type VoiceTask

type VoiceTask struct {
	TaskID     string
	ModuleID   string
	OpusData   []byte
	Priority   int
	SubmitTime time.Time
	Timeout    time.Duration
}

VoiceTask represents a voice task in the queue

type VoiceTaskQueue

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

VoiceTaskQueue manages voice tasks with priority support

func NewVoiceTaskQueue

func NewVoiceTaskQueue() *VoiceTaskQueue

NewVoiceTaskQueue creates a new voice task queue

func (*VoiceTaskQueue) CleanExpired

func (q *VoiceTaskQueue) CleanExpired() int

CleanExpired removes expired tasks

func (*VoiceTaskQueue) Close

func (q *VoiceTaskQueue) Close()

Close closes the queue

func (*VoiceTaskQueue) Dequeue

func (q *VoiceTaskQueue) Dequeue() (*VoiceTask, error)

Dequeue removes and returns the next task (blocking)

func (*VoiceTaskQueue) Enqueue

func (q *VoiceTaskQueue) Enqueue(task *VoiceTask) error

Enqueue adds a task to the queue

func (*VoiceTaskQueue) Length

func (q *VoiceTaskQueue) Length() int

Length returns the current queue length

func (*VoiceTaskQueue) Stats

func (q *VoiceTaskQueue) Stats() (enqueued, dequeued, expired uint64)

Stats returns queue statistics

Jump to

Keyboard shortcuts

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