From 798567ee5dd6b51bb37d4fbb3f50660ab44aff52 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 18 Sep 2016 18:30:18 +0200 Subject: [PATCH] Fixed twitch stream, and response messages. --- .../Searches/Commands/StreamNotifications.cs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/NadekoBot/Modules/Searches/Commands/StreamNotifications.cs b/NadekoBot/Modules/Searches/Commands/StreamNotifications.cs index 1513d0e7..f1bfb084 100644 --- a/NadekoBot/Modules/Searches/Commands/StreamNotifications.cs +++ b/NadekoBot/Modules/Searches/Commands/StreamNotifications.cs @@ -109,13 +109,13 @@ namespace NadekoBot.Modules.Searches.Commands cachedStatuses.TryAdd(hitboxUrl, result); return result; case StreamNotificationConfig.StreamType.Twitch: - var twitchUrl = $"https://api.twitch.tv/kraken/streams/{Uri.EscapeUriString(stream.Username)}"; + var twitchUrl = $"https://api.twitch.tv/kraken/streams/{Uri.EscapeUriString(stream.Username)}?client_id=67w6z9i09xv2uoojdm9l0wsyph4hxo6"; if (checkCache && cachedStatuses.TryGetValue(twitchUrl, out result)) return result; response = await SearchHelper.GetResponseStringAsync(twitchUrl).ConfigureAwait(false); data = JObject.Parse(response); isLive = !string.IsNullOrWhiteSpace(data["stream"].ToString()); - result = new Tuple(isLive, isLive ? data["stream"]["viewers"].ToString() : "0"); + result = new Tuple(isLive, isLive ? data["stream"]["viewers"].ToString() : stream.Username); cachedStatuses.TryAdd(twitchUrl, result); return result; case StreamNotificationConfig.StreamType.Beam: @@ -131,7 +131,7 @@ namespace NadekoBot.Modules.Searches.Commands default: break; } - return new Tuple(false, "0"); + return new Tuple(false, "NOT_FOUND"); } internal override void Init(CommandGroupBuilder cgb) @@ -180,7 +180,11 @@ namespace NadekoBot.Modules.Searches.Commands })); if (streamStatus.Item1) { - await e.Channel.SendMessage($"`Streamer {streamStatus.Item2} is online.`"); + await e.Channel.SendMessage($"`Streamer {stream} is online with {streamStatus.Item2} viewers.`"); + } + else + { + await e.Channel.SendMessage($"`Streamer {stream} is offline.`"); } } catch @@ -209,7 +213,11 @@ namespace NadekoBot.Modules.Searches.Commands })); if (streamStatus.Item1) { - await e.Channel.SendMessage($"`Streamer {streamStatus.Item2} is online.`"); + await e.Channel.SendMessage($"`Streamer {stream} is online with {streamStatus.Item2} viewers.`"); + } + else + { + await e.Channel.SendMessage($"`Streamer {stream} is offline.`"); } } catch @@ -238,7 +246,11 @@ namespace NadekoBot.Modules.Searches.Commands })); if (streamStatus.Item1) { - await e.Channel.SendMessage($"`Streamer {streamStatus.Item2} is online.`"); + await e.Channel.SendMessage($"`Streamer {stream} is online with {streamStatus.Item2} viewers.`"); + } + else + { + await e.Channel.SendMessage($"`Streamer {stream} is offline.`"); } } catch