Пример #1
0
        private async void GetAccount(long id)
        {
            var client = new MastodonClient(Properties.Settings.Default.AppRegistration, Properties.Settings.Default.Auth);

            Account.Value = await client.GetAccount(id);

            FullName.Value = Account.Value.AccountName;
            if (!FullName.Value.Contains('@'))
            {
                Regex regex = new Regex("^https://(?<domain>[^/]*)/");
                Match match = regex.Match(Account.Value.ProfileUrl);
                FullName.Value += '@' + match.Groups["domain"].Value;
            }

            FollowingUrl.Value = Account.Value.ProfileUrl.Replace("@", "users/") + "/following";
            FollowersUrl.Value = Account.Value.ProfileUrl.Replace("@", "users/") + "/followers";
        }
Пример #2
0
        private IEnumerable <Account> GetAllAccounts(MastodonClient client, string token)
        {
            var iter          = 1;
            var usersNotFound = 0;

            for (;;)
            {
                if (iter % 100 == 0)
                {
                    Console.WriteLine($"{DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture)} - Iteration: {iter}");
                    if (usersNotFound >= 100)
                    {
                        Console.WriteLine("No users founds");
                        yield break;
                    }
                    usersNotFound = 0;
                }

                Account account = null;
                try
                {
                    account = client.GetAccount(iter, token);
                }
                catch (Exception)
                {
                    usersNotFound++;
                }

                //if (account == null) yield break;
                if (account != null)
                {
                    yield return(account);
                }

                iter++;
            }
        }