mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 20:01:17 +00:00
Fix: Do not send update when not asked to
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
43849052e1
commit
2eb12900b9
1 changed files with 32 additions and 34 deletions
|
@ -90,42 +90,40 @@ func (r *twitchWatcher) updateChannelFromAPI(channel string, sendUpdate bool) er
|
|||
return nil
|
||||
}
|
||||
|
||||
if r.ChannelStatus[channel] == nil {
|
||||
r.ChannelStatus[channel] = &status
|
||||
}
|
||||
|
||||
if r.ChannelStatus[channel].Category != status.Category {
|
||||
log.WithFields(log.Fields{
|
||||
"channel": channel,
|
||||
"category": status.Category,
|
||||
}).Debug("Twitch metadata changed")
|
||||
go handleMessage(nil, nil, eventTypeTwitchCategoryUpdate, map[string]interface{}{
|
||||
"category": status.Category,
|
||||
})
|
||||
}
|
||||
|
||||
if r.ChannelStatus[channel].Title != status.Title {
|
||||
log.WithFields(log.Fields{
|
||||
"channel": channel,
|
||||
"title": status.Title,
|
||||
}).Debug("Twitch metadata changed")
|
||||
go handleMessage(nil, nil, eventTypeTwitchTitleUpdate, map[string]interface{}{
|
||||
"title": status.Title,
|
||||
})
|
||||
}
|
||||
|
||||
if r.ChannelStatus[channel].IsLive != status.IsLive {
|
||||
log.WithFields(log.Fields{
|
||||
"channel": channel,
|
||||
"isLive": status.IsLive,
|
||||
}).Debug("Twitch metadata changed")
|
||||
|
||||
evt := eventTypeTwitchStreamOnline
|
||||
if !status.IsLive {
|
||||
evt = eventTypeTwitchStreamOffline
|
||||
if sendUpdate && r.ChannelStatus[channel] != nil {
|
||||
if r.ChannelStatus[channel].Category != status.Category {
|
||||
log.WithFields(log.Fields{
|
||||
"channel": channel,
|
||||
"category": status.Category,
|
||||
}).Debug("Twitch metadata changed")
|
||||
go handleMessage(nil, nil, eventTypeTwitchCategoryUpdate, map[string]interface{}{
|
||||
"category": status.Category,
|
||||
})
|
||||
}
|
||||
|
||||
go handleMessage(nil, nil, evt, nil)
|
||||
if r.ChannelStatus[channel].Title != status.Title {
|
||||
log.WithFields(log.Fields{
|
||||
"channel": channel,
|
||||
"title": status.Title,
|
||||
}).Debug("Twitch metadata changed")
|
||||
go handleMessage(nil, nil, eventTypeTwitchTitleUpdate, map[string]interface{}{
|
||||
"title": status.Title,
|
||||
})
|
||||
}
|
||||
|
||||
if r.ChannelStatus[channel].IsLive != status.IsLive {
|
||||
log.WithFields(log.Fields{
|
||||
"channel": channel,
|
||||
"isLive": status.IsLive,
|
||||
}).Debug("Twitch metadata changed")
|
||||
|
||||
evt := eventTypeTwitchStreamOnline
|
||||
if !status.IsLive {
|
||||
evt = eventTypeTwitchStreamOffline
|
||||
}
|
||||
|
||||
go handleMessage(nil, nil, evt, nil)
|
||||
}
|
||||
}
|
||||
|
||||
r.ChannelStatus[channel] = &status
|
||||
|
|
Loading…
Reference in a new issue