if (e.Data.MessageArray[0] == "!streams")
{
try
{
WebClient webclient = new WebClient();
var data = webclient.DownloadString("http://api.justin.tv/api/stream/list.json?channel=dotademon");
JArray ja = JArray.Parse(data);
WebClient webclient2 = new WebClient();
var data2 = webclient2.DownloadString("http://api.justin.tv/api/stream/list.json?channel=trixilulz");
JArray ja2 = JArray.Parse(data2);
WebClient webclient3 = new WebClient();
var data3 = webclient3.DownloadString("http://api.justin.tv/api/stream/list.json?channel=thepremierleague");
JArray ja3 = JArray.Parse(data3);
//http://stackoverflow.com/questions/8649984/c-sharp-issue-with-a-json-string-if-value-is-null
var sb = new StringBuilder("Live right now: ");
if (ja.Count > 0)
{
sb.Append(string.Format((char)3 + "03EG.Demon" + (char)15 + " - Viewers: {0} - http://www.justin.tv/dotademon ", ja[0]["channel_count"]));
if (ja2.Count > 0)
{
sb.Append(string.Format((char)3 + "03Mouz.Trixi" + (char)15 + " - Viewers: {0} - http://www.justin.tv/trixilulz ", ja2[0]["channel_count"]));
if (ja3.Count > 0)
{
sb.Append(string.Format((char)3 + "03The Premier League" + (char)15 + " - Viewers: {0} - http://www.justin.tv/thepremierleague ", ja3[0]["channel_count"]));
}
}
irc.SendMessage(SendType.Message, e.Data.Channel, sb.ToString());
}
else if (ja.Count == 0)
{
irc.SendMessage(SendType.Message, e.Data.Channel, "All JTV streams are offline");
}