Example #1
0
        public async Task PoststatusAsync(string status, Visibility visibility)
        {
            var response = await client.PostStatus(status, visibility);

            Logger.NLogInfo($"Post Toot on {Instance}.");
            Logger.NLogInfo($"Toot message is {status}.");
        }
Example #2
0
 public MastdonHelper(MastodonAuthSet mastdonAuthSet)
 {
     appRegistration = mastdonAuthSet.AppRegistration;
     Instance        = appRegistration.Instance;
     acsessToken     = mastdonAuthSet.AccessToken;
     Logger.NLogInfo($"Constructer OK on {Instance}.");
 }
Example #3
0
        private async Task <IEnumerable <Account> > GetFriends()
        {
            var friends = await client.GetAccountFollowing(CurrentUser.Id);

            Logger.NLogInfo($"Get Friends EnumrateList on {Instance}.");
            return(friends);
        }
Example #4
0
        public async Task <IEnumerable <Status> > GetMentionsTimeLineAsync()
        {
            var menstionsTileline = await client.GetNotifications();

            Logger.NLogInfo($"GetMentionsTimeline on {Instance}.");
            return(menstionsTileline.Where(e => e.Type == "mention").Select(e => e.Status));
        }
Example #5
0
        public async Task <IEnumerable <Status> > SearchTagTimeLineAsync(int _count, string keyword)
        {
            var tweets = await client.GetTagTimeline(keyword, false);

            Logger.NLogInfo($"Search keyword is {keyword} on {Instance}.");
            return(tweets);
        }
Example #6
0
        public async Task Initializer()
        {
            client = new MastodonClient(appRegistration, acsessToken);

            CurrentUser = await GetCurrentUser();

            Followers = await GetFollowers();

            Friends = await GetFriends();

            Logger.NLogInfo($"Initializer OK on {Instance}.");
        }
Example #7
0
 public IEnumerable <Account> FollowBack()
 {
     foreach (var user in Followers)
     {
         if (Friends.FirstOrDefault(e => e.Id == user.Id) == null)
         {
             client.Follow(user.Id);
             Logger.NLogInfo($"FollowBack to {user.UserName} on {Instance}.");
             yield return(user);
         }
     }
 }
Example #8
0
        public async Task ReplyAsync(int tweetId, Visibility visibillity, string message)
        {
            try
            {
                await client.PostStatus(message, visibillity, (int)tweetId);

                Logger.NLogInfo($"Retoot is {tweetId},Visibillity is {visibillity.ToString()} on {Instance}.");
            }
            catch (System.Exception e)
            {
                Console.WriteLine($"MastodonHelperError!:{e.Message}");
            }
        }
Example #9
0
        public async Task <IEnumerable <Account> > RemoveBack()
        {
            var users = new List <Account>();
            var haveNotRemovedUsers = GetHaveNotRemovedUsers();

            foreach (var user in haveNotRemovedUsers)
            {
                await client.Unfollow(user.Id);

                Logger.NLogInfo($"UnFollowBack to {user.UserName} on {Instance}.");
                users.Add(user);
            }
            return(users);
        }
Example #10
0
        public async Task ReToot(int id)
        {
            try
            {
                var result = await client.Reblog(id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;

                throw;
            }

            Logger.NLogInfo($"Retoot is {id} on {Instance}.");
        }
Example #11
0
        public async Task FavouriteAsync(int id)
        {
            await client.Favourite(id);

            Logger.NLogInfo($"Fovourite is {id} on {Instance}.");
        }
Example #12
0
 private async Task <Account> GetCurrentUser()
 {
     Logger.NLogInfo($"GetCurrentUser on {Instance}.");
     return(await client.GetCurrentUser());
 }
Example #13
0
 public async Task <IEnumerable <Status> > GetTimeLineAsync()
 {
     Logger.NLogInfo($"GetHomeTimeline on {Instance}.");
     return(await client.GetHomeTimeline());
 }