modified: handlers/dashboard.go modified: main.go modified: services/openrouter.go modified: templates/dashboard.html
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"whatsapp-bot/db"
|
|
"whatsapp-bot/handlers"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func main() {
|
|
|
|
// 1. Load the .env file
|
|
err := godotenv.Load()
|
|
if err != nil {
|
|
log.Println("Warning: No .env file found. Hope you set your vars manually, seki.")
|
|
}
|
|
|
|
db.Init()
|
|
|
|
r := gin.Default()
|
|
|
|
// Load templates so Gin knows where to find your HTML
|
|
r.LoadHTMLGlob("templates/*")
|
|
|
|
// Routes
|
|
r.GET("/webhook", handlers.VerifyWebhook)
|
|
r.POST("/webhook", handlers.HandleMessage)
|
|
r.GET("/dashboard", handlers.ShowDashboard)
|
|
|
|
r.DELETE("/admin/appointment/:id", handlers.DeleteAppointmentHandler)
|
|
r.POST("/admin/appointment", handlers.CreateAppointmentHandler)
|
|
r.PUT("/admin/appointment/:id", handlers.UpdateAppointmentHandler)
|
|
|
|
r.POST("/admin/chat", handlers.NewChatHandler) // THE BUTTON HITS THIS
|
|
r.DELETE("/admin/chat/:id", handlers.DeleteChatHandler) // <--- ADD THIS
|
|
r.PUT("/admin/chat/:id/rename", handlers.RenameChatHandler) // <--- ADD THIS
|
|
r.GET("/admin/chat/:id/messages", handlers.GetMessagesHandler)
|
|
r.POST("/admin/chat/:id/message", handlers.PostMessageHandler)
|
|
|
|
// A little something for the root so you don't get a 404 again, seki
|
|
r.GET("/", func(c *gin.Context) {
|
|
c.JSON(200, gin.H{"message": "Bot is running. Go to /dashboard"})
|
|
})
|
|
|
|
r.Run(":9090") // Using your port 9090 from the screenshot
|
|
}
|