more data!
This commit is contained in:
parent
974e92a96d
commit
5a0d49cde6
7
config-example.json
Normal file
7
config-example.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"BotToken": "your_bot_token",
|
||||||
|
"SonarrAPIURL": "http://example.com/tv/api/",
|
||||||
|
"SonarrAPIKey": "your key",
|
||||||
|
"PlexPyAPIURL": "http://example.com/plexpy/api/v2",
|
||||||
|
"PlexPyAPIKey": "your key"
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"Token": "546410284:AAHXKhEsAB5OZTrAXCFI4kiZSFjN5i0h_wk",
|
|
||||||
"SonarrAPIURL": "http://dvr.linuxrocker.com/tv/api/",
|
|
||||||
"SonarrAPIKey": "69e7a095a1c94f42b150380864a6c92a"
|
|
||||||
}
|
|
BIN
go_telegram
BIN
go_telegram
Binary file not shown.
63
main.go
63
main.go
@ -18,38 +18,38 @@ var Config struct {
|
|||||||
SonarrAPIKey string
|
SonarrAPIKey string
|
||||||
PlexPyAPIURL string
|
PlexPyAPIURL string
|
||||||
PlexPyAPIKey string
|
PlexPyAPIKey string
|
||||||
RadarrAPIURL string
|
// RadarrAPIURL string
|
||||||
RadarrAPIKey string
|
// RadarrAPIKey string
|
||||||
CouchPotatoAPIURL string
|
// CouchPotatoAPIURL string
|
||||||
CouchPotatoAPIKey string
|
// CouchPotatoAPIKey string
|
||||||
PlexAPIURL string
|
// PlexAPIURL string
|
||||||
PlexAPIKey string
|
// PlexAPIKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
func sonarrStatus(message *tbot.Message) {
|
func sonarrStatus(message *tbot.Message) {
|
||||||
response, err := http.Get(Config.SonarrAPIURL + "system/status?apikey=" + Config.SonarrAPIKey)
|
r, err := http.Get(Config.SonarrAPIURL + "system/status?apikey=" + Config.SonarrAPIKey)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData, err := ioutil.ReadAll(response.Body)
|
rd, err := ioutil.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
message.Replyf("%s", responseData)
|
message.Replyf("%s", rd)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func sonarrVersion(message *tbot.Message) {
|
func sonarrVersion(message *tbot.Message) {
|
||||||
response, err := http.Get(Config.SonarrAPIURL + "system/status?apikey=" + Config.SonarrAPIKey)
|
r, err := http.Get(Config.SonarrAPIURL + "system/status?apikey=" + Config.SonarrAPIKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData, err := ioutil.ReadAll(response.Body)
|
rd, err := ioutil.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -58,19 +58,42 @@ func sonarrVersion(message *tbot.Message) {
|
|||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
version := Version{}
|
v := Version{}
|
||||||
jsonErr := json.Unmarshal(responseData, &version)
|
jv := json.Unmarshal(rd, &v)
|
||||||
if jsonErr != nil {
|
if jv != nil {
|
||||||
log.Fatal(jsonErr)
|
log.Fatal(jv)
|
||||||
}
|
}
|
||||||
|
|
||||||
message.Replyf("%s", version.Version)
|
message.Replyf("%s", v.Version)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// func activeSteamers(message *tbot.Message) {
|
func activeSteamers(message *tbot.Message) {
|
||||||
// response, err := http.Get(Config.PlexAPIURL + "api/v2?apikey=" + Config.PlexAPIKey + "&cmd=")
|
r, err := http.Get(Config.PlexPyAPIURL + "?apikey=" + Config.PlexPyAPIKey + "&cmd=get_activity")
|
||||||
// }
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rd, err := ioutil.ReadAll(r.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Activity struct {
|
||||||
|
StreamCount int `json:"stream_count"`
|
||||||
|
StreamCountDirectPlay int `json:"stream_count_direct_play"`
|
||||||
|
StreamCountDirectStream int `json:"stream_count_direct_stream"`
|
||||||
|
StreamCountTranscode int `json:"stream_count_transcode"`
|
||||||
|
}
|
||||||
|
|
||||||
|
a := Activity{}
|
||||||
|
ja := json.Unmarshal(rd, &a)
|
||||||
|
if ja != nil {
|
||||||
|
log.Fatal(ja)
|
||||||
|
}
|
||||||
|
|
||||||
|
message.Replyf("Stream Count: %v \nStream Count (Direct Play): %v \nStream Count (Direct Stream): %v \nStream Count (Transcode): %v", a.StreamCount, a.StreamCountDirectPlay, a.StreamCountDirectStream, a.StreamCountTranscode)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
c := flag.String("c", "./config.json", "Specify the configuration file.")
|
c := flag.String("c", "./config.json", "Specify the configuration file.")
|
||||||
@ -100,6 +123,8 @@ func main() {
|
|||||||
|
|
||||||
bot.HandleFunc("/sonarr_version", sonarrVersion)
|
bot.HandleFunc("/sonarr_version", sonarrVersion)
|
||||||
|
|
||||||
|
bot.HandleFunc("/activity", activeSteamers)
|
||||||
|
|
||||||
// Start Listening
|
// Start Listening
|
||||||
err = bot.ListenAndServe()
|
err = bot.ListenAndServe()
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user