fixed twitch authentication
This commit is contained in:
@@ -36,7 +36,7 @@ func NewAuthenticationManager(clientId, clientSecret string) *AuthenticationMana
|
||||
}
|
||||
|
||||
func (a *AuthenticationManager) GetAccessToken() (*AccessToken, error) {
|
||||
if a.accesToken != nil && a.accesToken.Expiry.After(time.Now()) {
|
||||
if a.accesToken != nil && a.accesToken.Token != "" && a.accesToken.Expiry.After(time.Now()) {
|
||||
return a.accesToken, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,11 @@ func (c *Client) PollStream(channel string, liveChannel chan<- *StreamInfo) erro
|
||||
return err
|
||||
}
|
||||
|
||||
if len(sr.Data) == 0 {
|
||||
liveChannel <- &StreamInfo{UserName: channel, IsLive: false}
|
||||
return nil
|
||||
}
|
||||
|
||||
s := sr.Data[0]
|
||||
started, _ := time.Parse(time.RFC3339, s.StartedAt)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package twitch
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type addUserReq struct {
|
||||
@@ -26,3 +27,14 @@ func MonitorUserHandler(m *Monitor) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func GetMonitoredUsers(m *Monitor) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
it := m.GetMonitoredUsers()
|
||||
|
||||
if err := json.NewEncoder(w).Encode(slices.Collect(it)); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user