private void InitScoreConfig(string file) { Writeln(Cyan, $"Init score config to {file}"); var content = new ScoreConfig().ToString(); File.WriteAllText(file, content); }
internal static async Task <List <(IUser, double)> > GetBotsOrDead(double minScore) { using (var spinner = new Spinner("Loading your details")) { var me = User.GetAuthenticatedUser(); spinner.Message = "Loading your friends"; var friends = await me.GetFriendIdsAsync(int.MaxValue); spinner.Message = "Loading your followers"; var followers = await me.GetFollowersAsync(int.MaxValue); var scoringConfig = new ScoreConfig(); spinner.Message = "Determining scores"; var result = followers .Where(_ => !friends.Contains(_.Id)) .Select(follower => (Follower: follower, Score: Score(follower, scoringConfig))) .Where(_ => _.Score > minScore) .OrderBy(_ => _.Follower.Name); spinner.Done(); return(result.ToList()); } }
private static double Score(IUser follower, ScoreConfig scoring) { var result = 0.0; if (scoring.DefaultProfileImage.Enabled && follower.DefaultProfileImage == scoring.DefaultProfileImage.Value) { result += scoring.DefaultProfileImage.Impact; } if (scoring.DescriptionLength.Enabled && follower.Description.Length <= scoring.DescriptionLength.Value) { result += scoring.DescriptionLength.Impact; } if (scoring.Favourites.Enabled && follower.FavouritesCount <= scoring.Favourites.Value) { result += scoring.Favourites.Impact; } if (scoring.FriendsLessThan.Enabled && follower.FriendsCount <= scoring.FriendsLessThan.Value) { result += scoring.FriendsLessThan.Impact; } if (scoring.LocationLength.Enabled && follower.Location.Length <= scoring.LocationLength.Value) { result += scoring.LocationLength.Impact; } if (scoring.FollowersLarge.Enabled && follower.FollowersCount >= scoring.FollowersLarge.Value) { result += scoring.FollowersLarge.Impact; } if (scoring.FollowersExtraLarge.Enabled && follower.FollowersCount >= scoring.FollowersExtraLarge.Value) { result += scoring.FollowersExtraLarge.Impact; } if (scoring.TweetsLessThan.Enabled && follower.StatusesCount <= scoring.TweetsLessThan.Value) { result += scoring.TweetsLessThan.Impact; } if (scoring.ZeroTweets.Enabled && follower.StatusesCount == scoring.ZeroTweets.Value) { result += scoring.ZeroTweets.Impact; } if (follower.Status != null) { if (scoring.TweetedInLastWeek.Enabled && follower.Status.CreatedAt > DateTime.Now.Subtract(TimeSpan.FromDays(7))) { result -= scoring.TweetedInLastWeek.Impact; } if (scoring.TweetedMoreThan90Days.Enabled && follower.Status.CreatedAt < DateTime.Now.Subtract(TimeSpan.FromDays(90))) { result += scoring.TweetedMoreThan90Days.Impact; } if (scoring.TweetedMoreThan1Year.Enabled && follower.Status.CreatedAt < DateTime.Now.Subtract(TimeSpan.FromDays(365))) { result += scoring.TweetedMoreThan1Year.Impact; } } if (scoring.FollowingMoreThan.Enabled && follower.FriendsCount >= scoring.FollowingMoreThan.Value) { result += scoring.FollowingMoreThan.Impact; } return(result); }