Facebook
From Coral Hamster, 5 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 213
  1.         [Command("a")]
  2.         public async Task AdminsOnline()
  3.         {
  4.             using (WebClient client = new WebClient())
  5.             {
  6.                 string[] admins = new string[]
  7.                 {
  8.                     "https://net4game.com/user/64596-roflmao/?tab=chars",
  9.                     "https://net4game.com/user/122891-gokupl/?tab=chars",
  10.                     "https://net4game.com/user/101376-grigor/?tab=chars",
  11.                     "https://net4game.com/user/125252-lenkaa/?tab=chars",
  12.                     "https://net4game.com/user/154539-darenty/?tab=chars",
  13.                     "https://net4game.com/user/141674-tajemniczaa/?tab=chars",
  14.                     "https://net4game.com/user/100757-mikeros/?tab=chars",
  15.                     "https://net4game.com/user/30093-kozji/?tab=chars",
  16.                     "https://net4game.com/user/111922-lisiek/?tab=chars",
  17.                     "https://net4game.com/user/152909-herix/?tab=chars",
  18.                     "https://net4game.com/user/161113-geast/?tab=chars",
  19.                     "https://net4game.com/user/130107-pablou/?tab=chars",
  20.                     "https://net4game.com/user/140404-mikuśka/?tab=chars",
  21.                     "https://net4game.com/user/151407-rudzia/?tab=chars",
  22.                     "https://net4game.com/user/88068-aktimel/?tab=chars",
  23.                     "https://net4game.com/user/159329-seeba/?tab=chars",
  24.                     "https://net4game.com/user/125076-peres12/?tab=chars",
  25.                     "https://net4game.com/user/55998-theluceek/?tab=chars",
  26.                     "https://net4game.com/user/162955-robxrt/?tab=chars"
  27.                 };
  28.  
  29.                 int count = 0;
  30.  
  31.                 string getBetween(string strSource, string strStart, string strEnd)
  32.                 {
  33.                     int Start, End;
  34.                     if (strSource.Contains(strStart) && strSource.Contains(strEnd))
  35.                     {
  36.                         Start = strSource.IndexOf(strStart, 0) + strStart.Length;
  37.                         End = strSource.IndexOf(strEnd, Start);
  38.                         return strSource.Substring(Start, End - Start);
  39.                     }
  40.                     else
  41.                     {
  42.                         return "";
  43.                     }
  44.                 }
  45.  
  46.                 string[] online = new string[19];
  47.  
  48.                 string htmlcodes;
  49.                 string text = String.Format("Na serwerze znajduje się **{0}** GameMasterów.", count);
  50.                 for (int i=0; i<19; i++)
  51.                 {
  52.  
  53.                     htmlcodes = client.DownloadString(admins[i]);
  54.                     string data = getBetween(htmlcodes, "<span class='hnick'>GM", "</span></a></li>");
  55.                     Console.WriteLine(i);
  56.                     Console.WriteLine(data);
  57.                     if (data.Contains("on-line"))
  58.                     {
  59.                         count++;
  60.                         online[i] = data;
  61.                     }
  62.                     if(count != 0)
  63.                     {
  64.                         text = String.Format("{0}\n\n{1}", text, online);
  65.                     }
  66.                 }
  67.                 var embed = new EmbedBuilder();
  68.                 embed.WithTitle("Rezultat wyszukiwania GM");
  69.                 embed.WithDescription(text);
  70.                 Context.Channel.SendMessageAsync("", false, embed);
  71.  
  72.                 /*string[] htmlcodes;
  73.                 htmlcodes = new string[18];
  74.  
  75.                 string text;
  76.  
  77.                 for(int i=0; i<18; i++)
  78.                 {
  79.                     text = String.Format("{0}", admins[i]);
  80.                     htmlcodes[i] = client.DownloadString(text);
  81.                     if (htmlcodes[i].Contains("new_post.png"))
  82.                     {
  83.                         Context.Channel.SendMessageAsync(":unamused: Niestety, GMy są na serwerze.");
  84.                         return;
  85.                     }
  86.                     Console.WriteLine(i);
  87.                     Thread.Sleep(500);
  88.                 }*/
  89.                 //Context.Channel.SendMessageAsync(":blush: Nie ma GMów, miłego szkodnikowania!");
  90.             }