go_telegram/pkg/service/sonarr/admin.go

25 lines
556 B
Go
Raw Permalink Normal View History

2020-05-17 06:25:29 +00:00
package sonarr
import (
"io/ioutil"
"net/http"
"github.com/mattburchett/go_telegram/pkg/core/config"
"github.com/yanzay/tbot/v2"
)
// Status contains the Sonarr request for system status.
func Status(m *tbot.Message, config config.Config) (string, error) {
2020-05-17 06:25:29 +00:00
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
}