示例#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);
            }
        }
示例#2
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");
            }
        }