From 9f02e73dc36d9d606cec4e9bf338bb5610a673b2 Mon Sep 17 00:00:00 2001 From: Hein Date: Tue, 25 Feb 2025 13:54:18 +0200 Subject: [PATCH] Telegram --- .gitignore | 1 + cmd/apisrv/main.go | 6 +++++- config.sample.json | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1071b66..d218076 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ go.work.sum # env file .env vivotek_events.log +config.json diff --git a/cmd/apisrv/main.go b/cmd/apisrv/main.go index fac30f8..3046d0e 100644 --- a/cmd/apisrv/main.go +++ b/cmd/apisrv/main.go @@ -75,6 +75,8 @@ func initConfig() error { } state.Logger = log.New(logOutput, "VIVOTEK-API: ", log.LstdFlags) + + fmt.Printf("Config loaded, handing off logs to %s...\n", state.Config.LogFile) return nil } @@ -296,6 +298,7 @@ var startTime time.Time func main() { startTime = time.Now() + fmt.Print("Starting NVR API...\n") // Initialize configuration if err := initConfig(); err != nil { @@ -309,7 +312,8 @@ func main() { // Start the HTTP server serverAddr := fmt.Sprintf(":%s", state.Config.ServerPort) - state.Logger.Printf("Starting Vivotek NVR Event Handler API on %s", serverAddr) + state.Logger.Printf("Starting NVR Event Handler API on %s", serverAddr) + fmt.Printf("Starting NVR Event Handler API on %s\n", serverAddr) if err := http.ListenAndServe(serverAddr, nil); err != nil { state.Logger.Fatalf("Failed to start server: %v", err) } diff --git a/config.sample.json b/config.sample.json index 1f0dfee..1377028 100644 --- a/config.sample.json +++ b/config.sample.json @@ -1,11 +1,11 @@ { "server_port": "8080", "log_file": "vivotek_events.log", - "notify_url": "https://your-notification-service.com/webhook", + "notify_url": "", "auth_username": "admin", "auth_password": "your-secure-password", - "telegram_enabled": true, - "telegram_token": "YOUR_TELEGRAM_BOT_TOKEN", + "telegram_enabled": false, + "telegram_token": "7131547115:AAFq0IwkaFHU_tKS3dep28x2CjadCVkTIPs", "telegram_chat_id": "YOUR_CHAT_ID" } \ No newline at end of file