コード例 #1
0
        public async Task SendToChannelAsync(List <IBotMessage> messages)
        {
            if (IsReady)
            {
                if (Config.bot.bargainChannelID != 0)
                {
                    var channel = Client.GetChannel(Config.bot.bargainChannelID) as IMessageChannel;
                    foreach (IBotMessage message in messages)
                    {
                        Console.WriteLine("[+] Considering message: " + message.Name);
                        if (Filter.IsDesirable(message))
                        {
                            await channel.SendMessageAsync("", false, message.GetEmbed());

                            Thread.Sleep(PostDelay);
                        }
                    }
                }

                else
                {
                    string errorMessage = "Configuration error: Bargain Channel ID should not be zero.";
                    Console.WriteLine(errorMessage);
                    Logger.GetInstance().realLogger.Error(errorMessage);
                }
            }
        }
コード例 #2
0
        public void FilterUndesirableItemTest()
        {
            IStorage      storage     = new MockStorage();
            Preferences   preferences = new Preferences(storage);
            FilterMessage filter      = new FilterMessage(preferences);

            BargainMessage message = new BargainMessage(
                "test", "900.50", "external_url", "image_url",
                "undesirable_category");

            preferences.AddCategory("test_category2");

            Assert.False(filter.IsDesirable(message));
        }
コード例 #3
0
        public void FilterUndesirablePriceTest()
        {
            IStorage      storage     = new MockStorage();
            Preferences   preferences = new Preferences(storage);
            FilterMessage filter      = new FilterMessage(preferences);

            BargainMessage message = new BargainMessage(
                "test", "1900.50", "external_url", "image_url",
                "test_category test_category2");

            preferences.AddCategory("test_category");
            preferences.AddPriceRange("test_category", new Tuple <double, double>(100.0, 1000.0));

            Assert.False(filter.IsDesirable(message));
        }