コード例 #1
0
 public static List<string> GetLatestFollowers()
 {
     var returnList = new List<string>();
     try
     {
         var request = WebRequest.Create("https://nightdev.com/hosted/followers.php?channel=" + SettingsManager.GetSetting("twitch_channel").ToLower() + "&limit=10");
         string text;
         var response = (HttpWebResponse)request.GetResponse();
         // ReSharper disable once AssignNullToNotNullAttribute
         using (var sr = new StreamReader(response.GetResponseStream()))
         {
             text = sr.ReadToEnd();
         }
         var followers = text.Split(',');
         foreach (var followerName in followers.Select(follower => follower.Split(' ')).Select(followerVar => string.IsNullOrEmpty(followerVar[0]) ? followerVar[2] : followerVar[1]).Where(followerName => !Followers.Contains(followerName)))
         {
             returnList.Add(followerName);
             Followers.Add(followerName);
             using (var db = new FollowDB())
             {
                 db.Insert(new Follower
                 {
                     Name = followerName
                 });
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.StackTrace);
     }
     return returnList;
 }
コード例 #2
0
 public static List<string> GetFollowers()
 {
     var returnList = new List<string>();
     using (var db = new FollowDB())
     {
         var query = from p in db.Followers select p;
         returnList.AddRange(query.ToList().Select(follower => follower.Name));
     }
     return returnList;
 }