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 {
|
type Twitcher struct {
|
||||||
name string
|
name string
|
||||||
game string
|
gameID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Twitcher) URL() string {
|
func (t Twitcher) URL() string {
|
||||||
|
@ -63,7 +63,7 @@ func New(b bot.Bot) *TwitchPlugin {
|
||||||
if _, ok := p.twitchList[twitcherName]; !ok {
|
if _, ok := p.twitchList[twitcherName]; !ok {
|
||||||
p.twitchList[twitcherName] = &Twitcher{
|
p.twitchList[twitcherName] = &Twitcher{
|
||||||
name: twitcherName,
|
name: twitcherName,
|
||||||
game: "",
|
gameID: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func (p *TwitchPlugin) serveStreaming(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
status := "NO."
|
status := "NO."
|
||||||
if twitcher.game != "" {
|
if twitcher.gameID != "" {
|
||||||
status = "YES."
|
status = "YES."
|
||||||
}
|
}
|
||||||
context := map[string]interface{}{"Name": twitcher.name, "Status": status}
|
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
|
games := s.Data
|
||||||
game := ""
|
gameID, title := "", ""
|
||||||
if len(games) > 0 {
|
if len(games) > 0 {
|
||||||
game = games[0].Title
|
gameID = games[0].GameID
|
||||||
|
title = games[0].Title
|
||||||
}
|
}
|
||||||
streamWord := p.config.Get("Twitch.StreamWord", "streaming")
|
streamWord := p.config.Get("Twitch.StreamWord", "streaming")
|
||||||
if alwaysPrintStatus {
|
if alwaysPrintStatus {
|
||||||
if game == "" {
|
if gameID == "" {
|
||||||
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s is not %s.", twitcher.name, streamWord))
|
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s is not %s.", twitcher.name, streamWord))
|
||||||
} else {
|
} 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 == "" {
|
} else if gameID == "" {
|
||||||
if twitcher.game != "" {
|
if twitcher.gameID != "" {
|
||||||
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s just stopped %s.", twitcher.name, streamWord))
|
p.Bot.Send(bot.Message, channel, fmt.Sprintf("%s just stopped %s.", twitcher.name, streamWord))
|
||||||
}
|
}
|
||||||
twitcher.game = ""
|
twitcher.gameID = ""
|
||||||
} else {
|
} else {
|
||||||
if twitcher.game != game {
|
if twitcher.gameID != gameID {
|
||||||
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()))
|
||||||
}
|
}
|
||||||
twitcher.game = game
|
twitcher.gameID = gameID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ func makeTwitchPlugin(t *testing.T) (*TwitchPlugin, *bot.MockBot) {
|
||||||
|
|
||||||
c.twitchList["drseabass"] = &Twitcher{
|
c.twitchList["drseabass"] = &Twitcher{
|
||||||
name: "drseabass",
|
name: "drseabass",
|
||||||
game: "",
|
gameID: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, mb
|
return c, mb
|
||||||
|
|
Loading…
Reference in New Issue