示例#1
0
        public async Task DoShow()
        {
            var commentResult = await _instaApi.CommentMediaAsync("", "Hi there!");

            Console.WriteLine(commentResult.Succeeded
                ? $"Comment created: {commentResult.Value.Pk}, text: {commentResult.Value.Text}"
                : $"Unable to create comment: {commentResult.Info.Message}");
        }
示例#2
0
        private async Task ExecuteQueueLikePhotosAsync(Queue queue, InstaBotContext db)
        {
            var tags = queue.LoadId.Split(' ');

            foreach (var tag in tags)
            {
                var top = await _api.GetExploreFeedAsync(PaginationParameters.MaxPagesToLoad(0));

                var media = top.Value.Medias.FirstOrDefault();

                //var foundPhotos = await _api.GetTagFeedAsync(tag, PaginationParameters.MaxPagesToLoad(0));
                //var media = foundPhotos.Value.Medias.FirstOrDefault();

                var isPhotoAlreadyLiked = db.UserActivityHistories.Any(x =>
                                                                       x.PostedImageURI == media.InstaIdentifier && x.Queue.QueueType == QueueType.LikePhoto);

                if (isPhotoAlreadyLiked)
                {
                    break;
                }

                await _api.LikeMediaAsync(media.InstaIdentifier);

                var rand            = new Random();
                var isNeedToComment = rand.Next(3);
                if (isNeedToComment == 1)
                {
                    var randNumber   = rand.Next(0, comments.Length);
                    var instaComment = await _api.CommentMediaAsync(media.InstaIdentifier, comments[randNumber]);

                    Console.WriteLine("Photo liked and commented!" + Environment.NewLine + instaComment.Info);
                }
                else
                {
                    Console.WriteLine("Photo liked only!");
                }


                queue.LastActivity = DateTime.UtcNow;
                db.UserActivityHistories.Add(new UserActivityHistory
                {
                    Queue          = queue,
                    CreatedOn      = DateTime.UtcNow,
                    PostedImageURI = media.InstaIdentifier,
                });
                await db.SaveChangesAsync();

                Thread.Sleep(1000);
            }
        }
示例#3
0
        public static async void Comentario(List <Seguidores> seguidores)
        {
            var x1 = "ab";
            var x2 = "ab";
            var x3 = "ab";
            List <Seguidores> TresNomes = new List <Seguidores>();
            int cont = 0;

            foreach (var item in seguidores)
            {
                //var resto = cont % 3;
                if (cont == 0)
                {
                    Seguidores seguir = new Seguidores();
                    seguir.meseguem = item.meseguem;
                    x1 = seguir.meseguem;


                    //var Comentario = await api.CommentMediaAsync("1864758539671613875", "@" + TresNomes);
                }

                if (cont == 1)
                {
                    Seguidores seguir = new Seguidores();
                    seguir.meseguem = item.meseguem;
                    x2 = seguir.meseguem;

                    //var Comentario = await api.CommentMediaAsync("1864758539671613875", "@" + TresNomes);
                }

                if (cont == 2)
                {
                    Seguidores seguir = new Seguidores();
                    seguir.meseguem = item.meseguem;
                    x3 = seguir.meseguem;
                    Console.WriteLine("o primeiro" + x1 + "o segundo" + x2 + "o terceiro" + x3);
                    cont = -1;
                    var Comentario = await api.CommentMediaAsync("1864758539671613875", "@" + x1 + "  " + "@" + x2 + "  " + "@" + x3);
                }


                cont = cont + 1;
            }
        }
示例#4
0
        public async Task <IResult <InstaComment> > CommentPost(string uri)
        {
            var mediaId = await _instaApi.GetMediaIdFromUrlAsync(new Uri(uri));

            return(await _instaApi.CommentMediaAsync(mediaId.Value, "Круто"));
        }
 public async static Task Comment(string post_id, string comment_text)
 {
     await _instaApi.CommentMediaAsync(post_id, comment_text);
 }
示例#6
0
        private static async void RunCommentTaskAsync(TaskModel t, IInstaApi api)
        {
            List <InstaMedia> medias = new List <InstaMedia>();

            foreach (var search in t.Searches)
            {
                if (search.InUsers)
                {
                    var _tempList = new List <InstaUserShort>();

                    foreach (var inString in search.GetInStrings())
                    {
                        var _temp = await api.SearchUsersAsync(inString);

                        if (_temp.Succeeded)
                        {
                            _tempList.AddRange(_temp.Value);
                        }
                    }

                    _tempList = await Helper.GetFilteredUsersAsync(_tempList, t.Searches, api, 10);

                    foreach (var user in _tempList)
                    {
                        var _userMedia = await api.GetUserMediaAsync(user.UserName, PaginationParameters.MaxPagesToLoad(5));

                        if (_userMedia.Succeeded)
                        {
                            medias.AddRange(_userMedia.Value);
                        }
                    }
                }

                if (search.InPosts)
                {
                    var _temp = await api.GetUserTimelineFeedAsync(PaginationParameters.MaxPagesToLoad(5));

                    if (_temp.Succeeded)
                    {
                        medias.AddRange(_temp.Value.Medias.ToList());
                    }
                }

                var filteredMedia = await Helper.GetFilteredMediaAsync(medias, t.Searches, api, 5);

                foreach (var media in filteredMedia)
                {
                    var result = await api.CommentMediaAsync(media.InstaIdentifier, await Helper.ConstructCaptionTextAsync(t.GetValues().Text, t.Searches, api));

                    if (result.Succeeded)
                    {
                        t.TaskExecuted();
                        Helper.Log($"Task Executed: {t.Name} - {t.TaskType.ToString()} {Environment.NewLine} {JsonConvert.SerializeObject(result.Value)}");
                    }
                    else
                    {
                        Helper.Log(JsonConvert.SerializeObject(result.Info));
                    }
                }
            }
        }
示例#7
0
        private async void ProcessHashtag(string tag)
        {
            try {
                // ищем информацию о теге
                var hashtagInfo = await api.GetHashtagInfo(tag);

                if (hashtagInfo.Succeeded)
                {
                    //logBox.Items.Add("Hashtag: #" + hashtagInfo.Value.Name + ", media count = " + hashtagInfo.Value.MediaCount);
                    // получаем ленту с постами по хештегу
                    var tagFeed = await api.GetTagFeedAsync(hashtagInfo.Value.Name, PaginationParameters.MaxPagesToLoad(5));

                    int count = actionCount < (tagFeed.Value.Medias.Count) ? actionCount : tagFeed.Value.Medias.Count;
                    foreach (var media in tagFeed.Value.Medias.Take(count))
                    {
                        if (chk_boxLike.Checked)
                        {
                            // ставим лайки каждому посту
                            var likeResult = await api.LikeMediaAsync(media.InstaIdentifier);

                            var resultString = likeResult.Value ? "liked" : "not liked";
                            if (media.Images.Count > 0)
                            {
                                logger.WriteLog($"Hashtag: #{hashtagInfo.Value.Name}, URI:{media.Images[0].URI}");
                            }
                            logger.WriteLog($" Post URI: https://www.instagram.com/p/{media.Code}");
                            logger.WriteLog($"User: {media.User.UserName} {resultString}");
                        }
                        if (chk_follow.Checked)
                        {
                            // подписываемся на автора картинки
                            var followResult = await api.FollowUserAsync(media.User.Pk);

                            var resultString = followResult.Succeeded ? "followed" : "not folowwed";
                            logger.WriteLog($"{resultString} {media.User.UserName}");
                            folowingUsers.Add(media.User.Pk.ToString());
                        }
                        if (chk_boxComment.Checked && commentsArr.Length > 0)
                        {
                            // ставим случайный комментарий автору фотки
                            Random rnd      = new Random();
                            int    randIndx = rnd.Next(0, commentsArr.Length - 1);
                            string comment  = commentsArr[randIndx];

                            var commentResult = await api.CommentMediaAsync(media.InstaIdentifier, comment);

                            var resultString = commentResult.Succeeded ? "comented" : "not comented";
                            logger.WriteLog($"{resultString}");
                            logger.WriteLog($"-------------------------------------------------------------");
                        }
                        if (media.Images.Count > 1)
                        {
                            PrintImage(media.Images[1].URI);
                        }
                        progressBar.Increment(1);
                    }
                }
            } catch (Exception ex)
            {
                logger.CloseLog();
                MessageBox.Show(ex.ToString());
            }
        }
示例#8
0
        async System.Threading.Tasks.Task MassComment()
        {
            Stat        = true;
            userInfoLog = await api.GetCurrentUserAsync();

            EventFromMyClass(this, new MyEventMessage($"[{userInfoLog.Value.UserName}][{DateTime.Now.ToString("HH:mm:ss")}][{Info()}] Комментирование запущено"));
            EventFromMyClass(this,
                             new MyEventMessage(
                                 $"[{userInfoLog.Value.UserName}][{DateTime.Now:HH:mm:ss}][{Info()}] Загружаю базу."));
            try
            {
                string[] stringID = System.IO.File.ReadAllLines(setting.FileNameBaseId);
                foreach (string str in stringID)
                {
                    try
                    {
                        usersID.Add(Convert.ToInt64(str));
                        usersIDcopy.Add(Convert.ToInt64(str));
                    }
                    catch { continue; }
                }
            }
            catch (Exception e)
            {
                EventFromMyClass(null,
                                 new MyEventMessage(
                                     $"[{userInfoLog.Value.UserName}][{DateTime.Now.ToString("HH:mm:ss")}][{Info()}] ОШИБКА: {e.Message}"));
            }

            EventUpdateGrid(this, new UpdateGridEvent($"{userInfoLog.Value.UserName}:Комментинг:{CountComment}/{usersID.Count}:{UpdateInfoUser(await api.GetUserInfoByIdAsync(userInfoLog.Value.Pk))}:" +
                                                      $"Выполняется"));

            foreach (long id in usersID)
            {
                try
                {
                    if (_source == null || _source.IsCancellationRequested)
                    {
                        break;
                    }

                    var infoUser = await api.GetUserInfoByIdAsync(id);

                    int pages = setting.CountCommnetUnderPublish;
                    Thread.Sleep(100);
                    var media = await api.GetUserMediaAsync(
                        infoUser.Value.Username,
                        PaginationParameters.MaxPagesToLoad(pages % 18 == 0 ? pages : pages + 1));     //Учет загруки страниц

                    var mediaList = media.Value.ToList();

                    for (int i = 0; i < setting.CountPublishComment; i++)
                    {
                        if (_source == null || _source.IsCancellationRequested)
                        {
                            break;
                        }

                        for (int y = 0; y < setting.CountCommnetUnderPublish; y++)
                        {
                            if (_source == null || _source.IsCancellationRequested)
                            {
                                break;
                            }

                            int random = rnd.Next(0, setting.Message.Length);
                            await api.CommentMediaAsync(mediaList[0].Pk, setting.Message[random]);

                            CountComment++;
                            CountPause++;
                            EventFromMyClass(this, new MyEventMessage($"[{userInfoLog.Value.UserName}][{DateTime.Now.ToString("HH:mm:ss")}][{Info()}] Прокомментировал запись пользователя: {infoUser.Value.Username}. Количество комментариев: {CountComment}"));
                            EventUpdateGrid(this, new UpdateGridEvent($"{userInfoLog.Value.UserName}:Комментинг:{CountComment}/{usersID.Count}:{UpdateInfoUser(await api.GetUserInfoByIdAsync(userInfoLog.Value.Pk))}:" +
                                                                      $"Выполняется"));
                            if (y != setting.CountCommnetUnderPublish - 1)
                            {
                                int randomDelayUser = rnd.Next(setting.DelayOneUserMin, setting.DelayOneUserMax + 1);
                                EventFromMyClass(this,
                                                 new MyEventMessage(
                                                     $"[{userInfoLog.Value.UserName}][{DateTime.Now.ToString("HH:mm:ss")}][{Info()}] Задержка на пользователя {randomDelayUser} сек"));
                                if (timer != null)
                                {
                                    timer.Dispose();
                                }
                                timer = new Timer(CancelDelay, null, 1000 * randomDelayUser, Timeout.Infinite);
                                ew.Reset();
                                ew.WaitOne();
                            } //Учет задержки на пользователя
                        }
                    }

                    if (setting.ChekedDeleteBase)
                    {
                        usersIDcopy.Remove(id);
                    }


                    Delay();                                     //Задержка в сек.

                    if (setting.CommentCountMax <= CountComment) //Проверка лимита комментариев
                    {
                        EventFromMyClass(this, new MyEventMessage($"[{userInfoLog.Value.UserName}][{DateTime.Now.ToString("HH:mm:ss")}][{Info()}] Превышено максимальное количество комментариев. Завершение задачи."));
                        Save();
                        EventUpdateGrid(this, new UpdateGridEvent($"{userInfoLog.Value.UserName}:Комментинг:{CountComment}/{usersID.Count}:{UpdateInfoUser(await api.GetUserInfoByIdAsync(userInfoLog.Value.Pk))}:" +
                                                                  $"Завершено"));
                        return;
                    }

                    if (setting.CheckedPause) //Учет паузы
                    {
                        if (setting.PauseLimit <= CountPause)
                        {
                            CountPause = 0;
                            EventFromMyClass(this, new MyEventMessage($"[{userInfoLog.Value.UserName}][{DateTime.Now.ToString("HH:mm:ss")}][{Info()}] Пауза на " + setting.PauseTime + " минут"));
                            EventUpdateGrid(this, new UpdateGridEvent($"{userInfoLog.Value.UserName}:Комментинг:{CountComment}/{usersID.Count}:{UpdateInfoUser(await api.GetUserInfoByIdAsync(userInfoLog.Value.Pk))}:" +
                                                                      $"Пауза"));
                            if (timer != null)
                            {
                                timer.Dispose();
                            }
                            timer = new Timer(CancelDelay, null, 1000 * setting.PauseTime, Timeout.Infinite);
                            ew.Reset();
                            ew.WaitOne();
                        }
                    }
                }

                catch (Exception e)
                {
                    EventFromMyClass(this, new MyEventMessage($"[{userInfoLog.Value.UserName}][{DateTime.Now.ToString("HH:mm:ss")}][{Info()}] ОШИБКА: {e.Message}"));
                    continue;
                }
            }

            Stat = false;
            EventFromMyClass(this, new MyEventMessage($"[{userInfoLog.Value.UserName}][{DateTime.Now.ToString("HH:mm:ss")}][{Info()}] Выполнено"));
            EventUpdateGrid(this, new UpdateGridEvent($"{userInfoLog.Value.UserName}:Комментинг:{CountComment}/{usersID.Count}:{UpdateInfoUser(await api.GetUserInfoByIdAsync(userInfoLog.Value.Pk))}:" +
                                                      $"Завершено"));
            Save();
        }