Bigger and better rewrite.
This commit is contained in:
24
pkg/service/sonarr/admin.go
Normal file
24
pkg/service/sonarr/admin.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user