actually count things properly
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
stryan 2021-10-26 14:33:22 -04:00
parent 67fe7dea38
commit 6f22f580dd
2 changed files with 11 additions and 6 deletions

View File

@ -152,10 +152,7 @@ func main() {
for _, v := range vtubers { for _, v := range vtubers {
v.Update() v.Update()
if v.IsLive() { if v.IsLive() {
CurrStreamCnt = CurrStreamCnt + 1
if CurrStreamCnt > MostStreamCnt {
MostStreamCnt = CurrStreamCnt
}
for _, room := range rooms { for _, room := range rooms {
//check to see if already embeded //check to see if already embeded
var content YoutubeWidget var content YoutubeWidget
@ -182,7 +179,6 @@ func main() {
} else { } else {
//Not live, check to see if there's any embeds and remove them //Not live, check to see if there's any embeds and remove them
for _, room := range rooms { for _, room := range rooms {
CurrStreamCnt = CurrStreamCnt - 1
var content YoutubeWidget var content YoutubeWidget
err = client.StateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, &content) err = client.StateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, &content)
if err == nil && content.ID != "" { if err == nil && content.ID != "" {

View File

@ -78,13 +78,22 @@ func (v *Vtuber) Update() error {
found := false found := false
for _, s := range sl.Streams { for _, s := range sl.Streams {
if s.Status == "live" { if s.Status == "live" {
if v.CurrentStream != s.ID {
v.TotalStreams = v.TotalStreams + 1
CurrStreamCnt = CurrStreamCnt + 1
if CurrStreamCnt > MostStreamCnt {
MostStreamCnt = CurrStreamCnt
}
}
v.CurrentStream = s.ID v.CurrentStream = s.ID
v.CurrentStreamTitle = s.Title v.CurrentStreamTitle = s.Title
v.TotalStreams = v.TotalStreams + 1
found = true found = true
} }
} }
if !found { if !found {
if v.CurrentStream != "" {
CurrStreamCnt = CurrStreamCnt - 1
}
v.CurrentStream = "" v.CurrentStream = ""
v.CurrentStreamTitle = "" v.CurrentStreamTitle = ""
} }