Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 27th, 2011  |  syntax: C#  |  size: 2.09 KB  |  views: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. if (e.Data.MessageArray[0] == "!streams")
  2.             {
  3.                 try
  4.                 {
  5.                     WebClient webclient = new WebClient();
  6.                     var data = webclient.DownloadString("http://api.justin.tv/api/stream/list.json?channel=dotademon");
  7.                     JArray ja = JArray.Parse(data);
  8.  
  9.                     WebClient webclient2 = new WebClient();
  10.                     var data2 = webclient2.DownloadString("http://api.justin.tv/api/stream/list.json?channel=trixilulz");
  11.                     JArray ja2 = JArray.Parse(data2);
  12.  
  13.                     WebClient webclient3 = new WebClient();
  14.                     var data3 = webclient3.DownloadString("http://api.justin.tv/api/stream/list.json?channel=thepremierleague");
  15.                     JArray ja3 = JArray.Parse(data3);
  16.  
  17.                     //http://stackoverflow.com/questions/8649984/c-sharp-issue-with-a-json-string-if-value-is-null
  18.  
  19.                    
  20.                     var sb = new StringBuilder("Live right now: ");
  21.                     if (ja.Count > 0)
  22.                     {
  23.                         sb.Append(string.Format((char)3 + "03EG.Demon" + (char)15 + " - Viewers: {0} - http://www.justin.tv/dotademon ", ja[0]["channel_count"]));
  24.  
  25.                         if (ja2.Count > 0)
  26.                         {
  27.                             sb.Append(string.Format((char)3 + "03Mouz.Trixi" + (char)15 + " - Viewers: {0} - http://www.justin.tv/trixilulz ", ja2[0]["channel_count"]));
  28.  
  29.                             if (ja3.Count > 0)
  30.                             {
  31.                                 sb.Append(string.Format((char)3 + "03The Premier League" + (char)15 + " - Viewers: {0} - http://www.justin.tv/thepremierleague ", ja3[0]["channel_count"]));
  32.                             }
  33.                         }
  34.                         irc.SendMessage(SendType.Message, e.Data.Channel, sb.ToString());
  35.                     }
  36.  
  37.                     else if (ja.Count == 0)
  38.                     {
  39.                         irc.SendMessage(SendType.Message, e.Data.Channel, "All JTV streams are offline");
  40.                     }