mejorando updating

This commit is contained in:
kar
2025-10-14 19:18:53 -06:00
parent 366ae7b611
commit fb9001d63a
+15 -7
View File
@@ -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 ":
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)
}
}