Merge pull request #81 from velour/linkify_twitch

twitch: Add URL to stream when streams are active
This commit is contained in:
Chris Sexton 2017-09-30 12:55:18 -04:00 committed by GitHub
commit 4122dc6b48
1 changed files with 8 additions and 2 deletions

View File

@ -27,6 +27,12 @@ type Twitcher struct {
game string game string
} }
func (t Twitcher) URL() string {
u, _ := url.Parse("https://twitch.tv/")
u2, _ := url.Parse(t.name)
return u.ResolveReference(u2).String()
}
type stream struct { type stream struct {
Data []struct { Data []struct {
ID string `json:"id"` ID string `json:"id"`
@ -218,7 +224,7 @@ func (p *TwitchPlugin) checkTwitch(channel string, twitcher *Twitcher, alwaysPri
if game == "" { if game == "" {
p.Bot.SendMessage(channel, twitcher.name+" is not streaming.") p.Bot.SendMessage(channel, twitcher.name+" is not streaming.")
} else { } else {
p.Bot.SendMessage(channel, twitcher.name+" is streaming "+game+".") p.Bot.SendMessage(channel, twitcher.name+" is streaming "+game+" at "+twitcher.URL())
} }
} else if game == "" { } else if game == "" {
if twitcher.game != "" { if twitcher.game != "" {
@ -227,7 +233,7 @@ func (p *TwitchPlugin) checkTwitch(channel string, twitcher *Twitcher, alwaysPri
twitcher.game = "" twitcher.game = ""
} else { } else {
if twitcher.game != game { if twitcher.game != game {
p.Bot.SendMessage(channel, twitcher.name+" just started streaming "+game+".") p.Bot.SendMessage(channel, twitcher.name+" just started streaming "+game+" at "+twitcher.URL())
} }
twitcher.game = game twitcher.game = game
} }