mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add uptime command
This commit is contained in:
parent
09b60730ae
commit
737a9f6259
2 changed files with 37 additions and 0 deletions
30
pkg/commands/uptime.go
Normal file
30
pkg/commands/uptime.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gempir/go-twitch-irc/v2"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Uptime(channel string, target string, client *twitch.Client) {
|
||||||
|
resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/api/v1/twitch/channel/%s/uptime", target))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
client.Say(channel, "Something went wrong FeelsBadMan")
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
client.Say(channel, "Something went wrong FeelsBadMan")
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
client.Say(channel, string(body))
|
||||||
|
|
||||||
|
}
|
|
@ -75,6 +75,13 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u
|
||||||
commands.Weather(message.Channel, message.Message[9:len(message.Message)], twitchClient)
|
commands.Weather(message.Channel, message.Message[9:len(message.Message)], twitchClient)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
case "uptime":
|
||||||
|
if msgLen == 1 {
|
||||||
|
commands.Uptime(message.Channel, message.Channel, twitchClient)
|
||||||
|
} else {
|
||||||
|
commands.Uptime(message.Channel, cmdParams[1], twitchClient)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue