From fb9001d63aaa4a6e925d2b8c560a78f87eef86a5 Mon Sep 17 00:00:00 2001 From: kar Date: Tue, 14 Oct 2025 19:18:53 -0600 Subject: [PATCH] mejorando updating --- umounting.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/umounting.go b/umounting.go index 2b8dba6..91926d4 100644 --- a/umounting.go +++ b/umounting.go @@ -9,6 +9,7 @@ import ( "strconv" //"strings" "time" + //"errors" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" ) @@ -51,7 +52,7 @@ func telegramBot(botToken string, chatID int64) { theHostInfo := sendInfo() bot, err := tgbotapi.NewBotAPI(botToken) if err != nil { - log.Fatal(err) + log.Println(err) } updateConfig := tgbotapi.NewUpdate(0) updateConfig.Timeout = 30 @@ -80,7 +81,7 @@ func telegramBot(botToken string, chatID int64) { msg := tgbotapi.NewMessage(chatID, data) _, err := bot.Send(msg) if err != nil { - log.Fatal(err) + log.Println(err) } } } @@ -88,17 +89,23 @@ func telegramBot(botToken string, chatID int64) { func umount(h HostInfo) string { switch h.hostname { case "alfa": - cmd := exec.Command("umount", "/home/kar/pelis/pelis") + cmd := exec.Command("umount", "/home/kar/pelis/") output, err := cmd.CombinedOutput() if err != nil { - log.Fatal(err) + outErr := err.Error() + return string(outErr) + } + if string(output) == "" { + output = []byte("Se logro desmontar el directorio") } return string(output) - case "jellyfin": + + case "jellyfin ": cmd := exec.Command("umount", "/mnt/pelis") output, err := cmd.CombinedOutput() if err != nil { - log.Fatal(err) + outErr := err.Error() + return string(outErr) } return string(output) } @@ -110,7 +117,7 @@ func main() { botToken := os.Getenv(telegramTokenID) tgChatId := os.Getenv(telegramChatID) - chatID, err := strconv.ParseInt(tgChatId, 10, 20) + chatID, err := strconv.ParseInt(tgChatId, 10, 64) if err != nil { log.Fatal(err) } @@ -119,6 +126,7 @@ func main() { if checkId() { telegramBot(botToken, chatID) } else { - return + fmt.Println("Programa no tiene privilegios suficientes") + os.Exit(1) } }