server

package
v1.0.0-echo Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearMessages

func ClearMessages(db *sql.DB) error

func ConvertPluginMessage

func ConvertPluginMessage(pluginMsg sdk.Message) shared.Message

ConvertPluginMessage converts a plugin message to a shared message

func CreateSchema

func CreateSchema(db *sql.DB)

func GetRecentMessages

func GetRecentMessages(db *sql.DB) []shared.Message

func InitDB

func InitDB(filepath string) *sql.DB

func InsertEncryptedMessage

func InsertEncryptedMessage(db *sql.DB, encryptedMsg *shared.EncryptedMessage)

InsertEncryptedMessage stores an encrypted message in the database

func InsertMessage

func InsertMessage(db *sql.DB, msg shared.Message)

func ServeWs

func ServeWs(hub *Hub, db *sql.DB, adminList []string, adminKey string) http.HandlerFunc

Types

type Client

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

type Config

type Config struct {
	Port     int      `json:"port"`
	Admins   []string `json:"admins"`
	AdminKey string   `json:"admin_key"`
}

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig loads configuration from a JSON file (for backward compatibility)

func LoadConfigFromDir

func LoadConfigFromDir(configDir string) (Config, error)

LoadConfigFromDir loads configuration from a directory, checking for JSON config files

type Hub

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

func NewHub

func NewHub() *Hub

func (*Hub) BanUser

func (h *Hub) BanUser(username string, adminUsername string)

BanUser adds a user to the ban list

func (*Hub) CleanupExpiredBans

func (h *Hub) CleanupExpiredBans()

CleanupExpiredBans removes expired bans from the ban list

func (*Hub) IsUserBanned

func (h *Hub) IsUserBanned(username string) bool

IsUserBanned checks if a user is currently banned

func (*Hub) KickUser

func (h *Hub) KickUser(username string, adminUsername string)

KickUser kicks a user by username (admin command)

func (*Hub) Run

func (h *Hub) Run()

func (*Hub) UnbanUser

func (h *Hub) UnbanUser(username string, adminUsername string) bool

UnbanUser removes a user from the ban list

type PluginCommandHandler

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

PluginCommandHandler handles plugin-related commands

func NewPluginCommandHandler

func NewPluginCommandHandler(pluginManager *manager.PluginManager) *PluginCommandHandler

NewPluginCommandHandler creates a new plugin command handler

func (*PluginCommandHandler) GetPluginMessageChannel

func (h *PluginCommandHandler) GetPluginMessageChannel() <-chan sdk.Message

GetPluginMessageChannel returns the channel for receiving messages from plugins

func (*PluginCommandHandler) HandlePluginCommand

func (h *PluginCommandHandler) HandlePluginCommand(cmd string, args []string, isAdmin bool) (string, error)

HandlePluginCommand handles plugin-related commands

func (*PluginCommandHandler) SendMessageToPlugins

func (h *PluginCommandHandler) SendMessageToPlugins(msg shared.Message)

SendMessageToPlugins sends a message to all enabled plugins

func (*PluginCommandHandler) UpdateUserListForPlugins

func (h *PluginCommandHandler) UpdateUserListForPlugins(users []string)

UpdateUserListForPlugins updates the user list for plugins

type UserList

type UserList struct {
	Users []string `json:"users"`
}

type WSMessage

type WSMessage struct {
	Type string          `json:"type"`
	Data json.RawMessage `json:"data"`
}

Jump to

Keyboard shortcuts

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