mejorando updating
This commit is contained in:
+16
-8
@@ -9,6 +9,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
//"strings"
|
//"strings"
|
||||||
"time"
|
"time"
|
||||||
|
//"errors"
|
||||||
|
|
||||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||||
)
|
)
|
||||||
@@ -51,7 +52,7 @@ func telegramBot(botToken string, chatID int64) {
|
|||||||
theHostInfo := sendInfo()
|
theHostInfo := sendInfo()
|
||||||
bot, err := tgbotapi.NewBotAPI(botToken)
|
bot, err := tgbotapi.NewBotAPI(botToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
updateConfig := tgbotapi.NewUpdate(0)
|
updateConfig := tgbotapi.NewUpdate(0)
|
||||||
updateConfig.Timeout = 30
|
updateConfig.Timeout = 30
|
||||||
@@ -80,7 +81,7 @@ func telegramBot(botToken string, chatID int64) {
|
|||||||
msg := tgbotapi.NewMessage(chatID, data)
|
msg := tgbotapi.NewMessage(chatID, data)
|
||||||
_, err := bot.Send(msg)
|
_, err := bot.Send(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,17 +89,23 @@ func telegramBot(botToken string, chatID int64) {
|
|||||||
func umount(h HostInfo) string {
|
func umount(h HostInfo) string {
|
||||||
switch h.hostname {
|
switch h.hostname {
|
||||||
case "alfa":
|
case "alfa":
|
||||||
cmd := exec.Command("umount", "/home/kar/pelis/pelis")
|
cmd := exec.Command("umount", "/home/kar/pelis/")
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
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)
|
return string(output)
|
||||||
case "jellyfin":
|
|
||||||
|
case "jellyfin ":
|
||||||
cmd := exec.Command("umount", "/mnt/pelis")
|
cmd := exec.Command("umount", "/mnt/pelis")
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
outErr := err.Error()
|
||||||
|
return string(outErr)
|
||||||
}
|
}
|
||||||
return string(output)
|
return string(output)
|
||||||
}
|
}
|
||||||
@@ -110,7 +117,7 @@ func main() {
|
|||||||
botToken := os.Getenv(telegramTokenID)
|
botToken := os.Getenv(telegramTokenID)
|
||||||
tgChatId := os.Getenv(telegramChatID)
|
tgChatId := os.Getenv(telegramChatID)
|
||||||
|
|
||||||
chatID, err := strconv.ParseInt(tgChatId, 10, 20)
|
chatID, err := strconv.ParseInt(tgChatId, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -119,6 +126,7 @@ func main() {
|
|||||||
if checkId() {
|
if checkId() {
|
||||||
telegramBot(botToken, chatID)
|
telegramBot(botToken, chatID)
|
||||||
} else {
|
} else {
|
||||||
return
|
fmt.Println("Programa no tiene privilegios suficientes")
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user