Esempio n. 1
0
        public static async void RunFeeder()
        {
            while (_isRunning)
            {
                var switchRes = await NetUtills.GetRss(SwitchPricesUrl);

                foreach (var res in switchRes.Items)
                {
                    var text = res.Title.Text;
                    if (_storedData.Contains(text))
                    {
                        continue;
                    }

                    var cgPrice = RegexUtills.GetPrices(text);

                    if (!(cgPrice.InitPrice >= MinInitPrice) || cgPrice.Percent < MinDiscount)
                    {
                        continue;
                    }
                    await _channel.SendMessageAsync($"@everyone\nNew: {text}");

                    _storedData.Add(text);
                }

                await Task.Delay(1 * 1000);

                var ps4Res = await NetUtills.GetRss(Ps4PriceUrl);

                foreach (var res in ps4Res.Items)
                {
                    var text = res.Title.Text;
                    if (_storedData.Contains(text))
                    {
                        continue;
                    }

                    var cgPrice = RegexUtills.GetPrices(text);

                    if (!(cgPrice.InitPrice >= MinInitPrice) || cgPrice.Percent < MinDiscount)
                    {
                        continue;
                    }
                    await _channel.SendMessageAsync($"@everyone\nNew: {text}");

                    _storedData.Add(text);
                }

                Logger.Info("Prices are checked");
                //1 hour
                await Task.Delay(1 * 60 * 60 * 1000);
            }
        }
Esempio n. 2
0
        public static async void RuAnimeFeeder()
        {
            await PreStartMethod();

            while (_isRunning)
            {
                await FindNewData();

                var animeData = (from item in _animeDataCached
                                 where item.WatchingStatus == 1 || item.WatchingStatus == 6
                                 select RegexUtills.RemoveChars(item.GetAllNames())).ToList();

                Logger.Info(string.Join(" ", animeData));

                var rssData = await NetUtills.GetRss(NyaUrl);

                var pattern = await GetCurrentPattern();

                foreach (var entry in rssData.Items)
                {
                    if (!entry.Title.Text.Contains(pattern) ||
                        !entry.Title.Text.Contains("1080p") ||
                        RssFeedList.Contains(entry.Title.Text))
                    {
                        continue;
                    }

                    var title = entry.Title.Text.Replace(pattern, "");
                    title = RegexUtills.FixRssTitle(title);

                    foreach (var data in from s in animeData
                             where s.Contains(title)
                             select $"@everyone\nNew series: {entry.Title.Text}\n[Link]({entry.Links[0].Uri})")
                    {
                        await _channel.SendMessageAsync(data);

                        RssFeedList.Add(entry.Title.Text);
                        break;
                    }
                }

                Logger.Info("Rss has been read");
                await Task.Delay(300 * 1000);
            }
        }
Esempio n. 3
0
        public static async Task <List <string> > GetTopCommentsFromLastPost(string groupName, int count)
        {
            var posts       = new List <string>();
            var targetGroup = new Group("", "");

            var found = false;

            foreach (var group in _groups.Where(group =>
                                                RegexUtills.GetLevenshteinDistancePercent(group.Name, groupName) >= 60))
            {
                targetGroup = group;
                found       = true;
            }

            if (!found)
            {
                posts.Add("Can't found such group");
                return(posts);
            }

            var lastPost = await VkApi.GetNewPost(targetGroup);

            var rawComments = await VkApi.GetCommentsFromPost(targetGroup, lastPost.Id);

            var comments = rawComments.OrderByDescending(comment => comment.Likes).ToList();

            if (count > rawComments.Count)
            {
                foreach (var comment in comments)
                {
                    posts.Add(comment.ToString());
                }
            }
            else
            {
                for (var i = 0; i < count; i++)
                {
                    posts.Add(comments[i].ToString());
                }
            }

            return(posts);
        }
Esempio n. 4
0
        public static async Task GetDiscountsConsole(string type, int minInitPrice, int minDiscount)
        {
            string url;
            var    messagesSent = new List <string>();

            if (type.Equals("ps4"))
            {
                url = Ps4PriceUrl;
            }
            else if (type.Equals("switch"))
            {
                url = SwitchPricesUrl;
            }
            else
            {
                await _channel.SendMessageAsync("Typo in console type");

                return;
            }

            var res = await NetUtills.GetRss(url);

            foreach (var item in res.Items)
            {
                var text = item.Title.Text;

                var cgPrice = RegexUtills.GetPrices(text);

                if (!(cgPrice.InitPrice >= minInitPrice) || cgPrice.Percent < minDiscount)
                {
                    continue;
                }
                await _channel.SendMessageAsync($"{text}");

                messagesSent.Add(item.Title.Text);
            }

            if (messagesSent.Count == 0)
            {
                await _channel.SendMessageAsync("No items found");
            }
        }