mirror of https://github.com/velour/catbase.git
Merge pull request #142 from velour/twitchfix
twitch: check gameID instead of title
This commit is contained in:
commit
86e662b181
|
@ -24,7 +24,7 @@ type TwitchPlugin struct {
|
|||
|
||||
type Twitcher struct {
|
||||
name string
|
||||
game string
|
||||
gameID string
|
||||
}
|
||||
|
||||
func (t Twitcher) URL() string {
|
||||
|
@ -63,7 +63,7 @@ func New(b bot.Bot) *TwitchPlugin {
|
|||
if _, ok := p.twitchList[twitcherName]; !ok {
|
||||
p.twitchList[twitcherName] = &Twitcher{
|
||||
name: twitcherName,
|
||||
game: "",
|
||||
gameID: "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func (p *TwitchPlugin) serveStreaming(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
status := "NO."
|
||||
if twitcher.game != "" {
|
||||
if twitcher.gameID != "" {
|
||||
status = "YES."
|
||||
}
|
||||
context := map[string]interface{}{"Name": twitcher.name, "Status": status}
|
||||
|
@ -207,26 +207,27 @@ func (p *TwitchPlugin) checkTwitch(channel string, twitcher *Twitcher, alwaysPri
|
|||
}
|
||||
|
||||
games := s.Data
|
||||
game := ""
|
||||
gameID, title := "", ""
|
||||
if len(games) > 0 {
|
||||
game = games[0].Title
|
||||
gameID = games[0].GameID
|
||||
title = games[0].Title
|
||||
}
|
||||
streamWord := p.config.Get("Twitch.StreamWord", "streaming")
|
||||
if alwaysPrintStatus {
|
||||
if game == "" {
|
||||
if gameID == "" {
|
||||
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s is not %s.", twitcher.name, streamWord))
|
||||
} else {
|
||||
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s is %s %s at %s", twitcher.name, streamWord, game, twitcher.URL()))
|
||||
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s is %s %s at %s", twitcher.name, streamWord, title, twitcher.URL()))
|
||||
}
|
||||
} else if game == "" {
|
||||
if twitcher.game != "" {
|
||||
} else if gameID == "" {
|
||||
if twitcher.gameID != "" {
|
||||
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s just stopped %s.", twitcher.name, streamWord))
|
||||
}
|
||||
twitcher.game = ""
|
||||
twitcher.gameID = ""
|
||||
} else {
|
||||
if twitcher.game != game {
|
||||
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s is %s %s at %s", twitcher.name, streamWord, game, twitcher.URL()))
|
||||
if twitcher.gameID != gameID {
|
||||
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s is %s %s at %s", twitcher.name, streamWord, title, twitcher.URL()))
|
||||
}
|
||||
twitcher.game = game
|
||||
twitcher.gameID = gameID
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func makeTwitchPlugin(t *testing.T) (*TwitchPlugin, *bot.MockBot) {
|
|||
|
||||
c.twitchList["drseabass"] = &Twitcher{
|
||||
name: "drseabass",
|
||||
game: "",
|
||||
gameID: "",
|
||||
}
|
||||
|
||||
return c, mb
|
||||
|
|
Loading…
Reference in New Issue