25 lines
663 B
Go
25 lines
663 B
Go
package chat
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
twitch "github.com/gempir/go-twitch-irc/v4"
|
|
twitchapi "streambot_twitch/internal/twitchapi"
|
|
)
|
|
|
|
func HandleUptimeCommand(client *twitch.Client, apiClient *twitchapi.Client, message twitch.PrivateMessage, user twitch.User, channel string) {
|
|
msg := strings.ToLower(message.Message)
|
|
if !strings.HasPrefix(msg, "!uptime") {
|
|
return
|
|
}
|
|
|
|
uptime, err := apiClient.GetStreamUptime(channel)
|
|
if err != nil {
|
|
client.Say(channel, fmt.Sprintf("@%s Stream is currently offline or error occoured.", user.DisplayName))
|
|
return
|
|
}
|
|
|
|
client.Say(channel, fmt.Sprintf("@%s Stream has been live for %s", user.DisplayName, uptime))
|
|
}
|