From d7a1276f1fa41d8760bcef2c917ba3db45fd7503 Mon Sep 17 00:00:00 2001 From: nomadics9 Date: Mon, 30 Dec 2024 03:28:36 +0300 Subject: [PATCH] fixes --- Dockerfile | 1 + main.go | 12 +++++++----- watchTV.sh | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 36dc852..a428224 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ RUN printf '#!/bin/sh\n\n' > /entrypoint.sh && \ printf 'git config --global --add safe.directory /data/alaskartv/docker-ci\n' >> /entrypoint.sh && \ printf 'git config --global --add safe.directory /data/alaskartv/androidtv-ci\n\n' >> /entrypoint.sh && \ # Finally, run the main app + printf 'crond -b\n' >> /entrypoint.sh && \ printf 'exec /app/api-server\n' >> /entrypoint.sh && \ chmod +x /entrypoint.sh diff --git a/main.go b/main.go index f247c5f..1bea3e1 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,8 @@ func updateVersion(repoPath string, serviceName string) error { "curl", "-X", "POST", fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", botToken), "-d", fmt.Sprintf("chat_id=%s", chatid), - "-d", fmt.Sprintf("text=GO-SERVER: %s updated to %s", serviceName, newVersion), + "-d", fmt.Sprintf("text=Alaskar-api: %s updated to %s", serviceName, newVersion), + "-d", fmt.Sprintf("parse_mode=HTML"), }, } @@ -92,7 +93,7 @@ func bumpVersionTv(repoPath string) { func notifyHandler(c *gin.Context) { var data struct { Name string `json:"name"` - Image string `json:"image"` + Message string `json:"message"` } if err := c.ShouldBindJSON(&data); err != nil { @@ -103,20 +104,21 @@ func notifyHandler(c *gin.Context) { if data.Name == "" { data.Name = "unknown" } - if data.Image == "" { - data.Image = "unknown" + if data.Message == "" { + data.Message = "unknown" } godotenv.Load(".botenv") botToken := os.Getenv("BOT_TOKEN") chatid := os.Getenv("CHAT_ID") - message := fmt.Sprintf("Service '%s' was updated to image '%s'", data.Name, data.Image) + message := fmt.Sprintf("Alaskar-api: %s \n \n %s", data.Name, data.Message) telegramAPI := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", botToken) resp, err := http.PostForm(telegramAPI, url.Values{ "chat_id": {chatid}, "text": {message}, + "parse_mode": {"HTML"}, }) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to send Telegram message"}) diff --git a/watchTV.sh b/watchTV.sh index 64526d2..6f00bcb 100755 --- a/watchTV.sh +++ b/watchTV.sh @@ -17,5 +17,5 @@ if [ "$latest_release" != "$version" ]; then curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \ -d chat_id="$CHAT_ID" \ -d text="🚀 New Release Detected: $latest_release on $REPO_OWNER/$REPO_NAME" - curl -X POST "http://alaskar-api:8080/api/alaskartv" + curl -X POST "http://api-server:9090/api/alaskartv" fi