From eae49ebe1875848468774ab3f9be3b56b1e11071 Mon Sep 17 00:00:00 2001 From: cws Date: Sat, 30 Sep 2017 12:53:37 -0400 Subject: [PATCH] twitch: Add URL to stream when streams are active --- plugins/twitch/twitch.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/twitch/twitch.go b/plugins/twitch/twitch.go index da16cb2..4a5c1a0 100644 --- a/plugins/twitch/twitch.go +++ b/plugins/twitch/twitch.go @@ -27,6 +27,12 @@ type Twitcher struct { 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 { Data []struct { ID string `json:"id"` @@ -218,7 +224,7 @@ func (p *TwitchPlugin) checkTwitch(channel string, twitcher *Twitcher, alwaysPri if game == "" { p.Bot.SendMessage(channel, twitcher.name+" is not streaming.") } 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 == "" { if twitcher.game != "" { @@ -227,7 +233,7 @@ func (p *TwitchPlugin) checkTwitch(channel string, twitcher *Twitcher, alwaysPri twitcher.game = "" } else { 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 }