Bigger and better rewrite.

This commit is contained in:
2020-05-17 01:25:29 -05:00
parent aeac9e4e26
commit 7c6b9c4a74
7 changed files with 184 additions and 55 deletions

View File

@ -0,0 +1,24 @@
package sonarr
import (
"io/ioutil"
"net/http"
"github.com/mattburchett/go_telegram/pkg/core/config"
"github.com/yanzay/tbot/v2"
)
// SonarrStatus contains the Sonarr request for system status.
func SonarrStatus(m *tbot.Message, config config.Config) (string, error) {
r, err := http.Get(config.Sonarr.URL + "system/status?apikey=" + config.Sonarr.APIKey)
if err != nil {
return "Failed to contact Sonarr for data", err
}
rd, err := ioutil.ReadAll(r.Body)
if err != nil {
return "Failed to read Sonarr status data.", err
}
return string(rd), err
}