Phase 4: Bots & Extensibility
Backend: - internal/bot/auth.go: bot token generation and verification - internal/bot/handlers.go: bot CRUD (create, list, get, update, delete, server management, token regen) - internal/bot/commands.go: slash command registration and management - internal/webhook/handlers.go: webhook CRUD and execution endpoint - internal/webhook/token.go: webhook token generation - internal/db/db.go: bots, bot_servers, slash_commands, webhooks tables - internal/gateway/events.go: BOT_JOIN, BOT_LEAVE event constants - cmd/server/main.go: wired bot, webhook, invite routes Frontend: - stores/bot.ts: Zustand store for bot management - BotManager.tsx: bot list, create, edit, delete, add to server, token display - CommandManager.tsx: slash command CRUD per bot - SlashCommandPopup.tsx: / command autocomplete popup - App.tsx: /bots and /bots/:id/commands routes Examples: - examples/modbot/: auto-delete banned words, /kick, /ban, /purge commands - examples/welcome/: welcome message on member join
This commit is contained in:
@@ -8,16 +8,20 @@ import (
|
||||
"os"
|
||||
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/auth"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/bot"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/channel"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/config"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/db"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/gateway"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/giphy"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/invite"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/message"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/middleware"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/reaction"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/server"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/upload"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/voice"
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/webhook"
|
||||
"github.com/go-chi/chi/v5"
|
||||
chimw "github.com/go-chi/chi/v5/middleware"
|
||||
)
|
||||
@@ -148,6 +152,31 @@ func main() {
|
||||
voice.NewHandler(database.DB, voiceClient, hub).RegisterRoutes(r)
|
||||
})
|
||||
}
|
||||
|
||||
// Reactions
|
||||
r.Route("/messages/{messageID}/reactions", func(r chi.Router) {
|
||||
reaction.NewHandler(database.DB, hub).RegisterRoutes(r)
|
||||
})
|
||||
|
||||
// Bots
|
||||
r.Route("/bots", func(r chi.Router) {
|
||||
bot.NewHandler(database.DB).RegisterRoutes(r)
|
||||
})
|
||||
|
||||
// Bot slash commands
|
||||
r.Route("/bots/{botID}/commands", func(r chi.Router) {
|
||||
bot.NewCommandHandler(database.DB).RegisterCommandRoutes(r)
|
||||
})
|
||||
|
||||
// Webhooks (protected: create/delete)
|
||||
r.Route("/channels/{channelID}/webhooks", func(r chi.Router) {
|
||||
webhook.NewHandler(database.DB, hub).RegisterRoutes(r)
|
||||
})
|
||||
|
||||
// Invites
|
||||
r.Route("/invites", func(r chi.Router) {
|
||||
invite.NewHandler(database.DB).RegisterRoutes(r)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -156,6 +185,11 @@ func main() {
|
||||
r.Get("/files/*", uploadHandler.Serve)
|
||||
}
|
||||
|
||||
// Public webhook execution (no auth required)
|
||||
r.Post("/webhooks/{webhookID}/{token}", func(w http.ResponseWriter, r *http.Request) {
|
||||
webhook.NewHandler(database.DB, hub).Execute(w, r)
|
||||
})
|
||||
|
||||
// Static file serving for production (SPA)
|
||||
staticDir := "/srv/web"
|
||||
if _, err := os.Stat(staticDir); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user