Exemplo n.º 1
0
        public void CharacterTest()
        {
            var poebot = new Poebot(_api, new MockPhoto(false), new MockLanguage(_languages));

            var message = poebot.ProcessRequest("/c Рогогомогофл");

            Assert.AreEqual(WebUtility.UrlDecode("http://poe-profile.info/profile/Rogogomogofl/Рогогомогофл"), WebUtility.UrlDecode(message?.Text));
        }
Exemplo n.º 2
0
        public void PoeNinjaBuildsTest()
        {
            var poebot = new Poebot(_api, new MockPhoto(false), new MockLanguage(_languages));

            var message = poebot.ProcessRequest("/b cyclon + starf");

            Assert.AreEqual("Билды которые используют Starforge + Cyclone:\nhttps://poe.ninja/challenge/builds?item=Starforge&skill=Cyclone", message?.Text);
        }
Exemplo n.º 3
0
        public void HelpMeTest()
        {
            var poebot = new Poebot(_api, new MockPhoto(false), new MockLanguage(_languages));

            var message = poebot.ProcessRequest("/hm star");

            Assert.AreNotEqual(null, message);
            Assert.AreEqual(true, message.Text.Split(new[] { '\r', '\n' }).Length > 1);
        }
Exemplo n.º 4
0
        public void CharacterListTest()
        {
            var poebot = new Poebot(_api, new MockPhoto(false), new MockLanguage(_languages));

            var message = poebot.ProcessRequest("/cl rogogomogofl");
            var regex   = new Regex(@"\S+\s[(]лига: .+");

            Assert.AreNotEqual(null, message);
            Assert.AreEqual(true, regex.Matches(message.Text).Count > 0);
        }
Exemplo n.º 5
0
        public void PobPartyTest()
        {
            var poebot = new Poebot(api, new MockPhoto(false), new MockLanguage(language));

            var message = poebot.ProcessRequest("https://pastebin.com/QZHfq4X9");
            var regex   = new Regex(@"https:..pob.party.share.\w+");

            Assert.AreNotEqual(null, message);
            Assert.AreEqual(true, regex.IsMatch(message.Text));
        }
Exemplo n.º 6
0
        public void WikiScreenshotTest()
        {
            var poebot = new Poebot(_api, new MockPhoto(false), new MockLanguage(_languages));

            var message = poebot.ProcessRequest("/i test");

            Assert.AreEqual(true, message?.Photo?.GetContent()?.Length == 1);

            message = poebot.ProcessRequest("/i disfav");
            Assert.AreEqual(true, message?.Photo?.GetContent()?.Length == 1);
        }
Exemplo n.º 7
0
        public void LabLayoutTest()
        {
            var poebot = new Poebot(api, new MockPhoto(false), new MockLanguage(language));

            var message = poebot.ProcessRequest("/l merc");

            Assert.AreEqual(true, message?.Photo?.GetContent()?.Length == 1);

            message = poebot.ProcessRequest("/l 4");
            Assert.AreEqual(true, message?.Photo?.GetContent()?.Length == 1);
        }
Exemplo n.º 8
0
        public void RedditImageTest()
        {
            var poebot = new Poebot(api, new MockPhoto(false), new MockLanguage(language));

            var message = poebot.ProcessRequest("https://www.reddit.com/r/pathofexile/comments/i1nt6z/always_has_been/");

            Assert.AreEqual("Always has been", message?.Text);
            Assert.AreEqual(true, message?.Photo?.GetContent()?.Length == 1);

            message = poebot.ProcessRequest("https://www.reddit.com/r/pathofexile/comments/i1dhvh/til_the_artwork_of_a_dab_of_ink_has_a_person/");
            Assert.AreEqual("TIL The artwork of "A Dab of Ink" has a person literally dabbing...", message?.Text);
            Assert.AreEqual(true, message?.Photo?.GetContent()?.Length == 1);
        }
Exemplo n.º 9
0
        public void WikiSearchTest()
        {
            var poebot = new Poebot(_api, new MockPhoto(false), new MockLanguage(_languages));

            var message = poebot.ProcessRequest("/w test");

            Assert.AreEqual(WebUtility.UrlDecode("https://pathofexile.gamepedia.com/Testudo"), WebUtility.UrlDecode(message?.Text));

            message = poebot.ProcessRequest("/w disf");
            Assert.AreEqual(WebUtility.UrlDecode("https://pathofexile.gamepedia.com/Atziri's_Disfavour"), WebUtility.UrlDecode(message?.Text));

            message = poebot.ProcessRequest("/w отвар рум");
            Assert.AreEqual(WebUtility.UrlDecode("https://pathofexile-ru.gamepedia.com/%D0%9E%D1%82%D0%B2%D0%B0%D1%80_%D0%A0%D1%83%D0%BC%D0%B8"), WebUtility.UrlDecode(message?.Text));
        }
Exemplo n.º 10
0
        public void PriceTest()
        {
            var poebot = new Poebot(_api, new MockPhoto(false), new MockLanguage(_languages));

            var message = poebot.ProcessRequest("/p exal orb");
            var regex   = new Regex(@"Минимальная: \d+.*c");

            Assert.AreNotEqual(null, message);
            Assert.AreEqual(true, regex.IsMatch(message.Text));

            message = poebot.ProcessRequest("/p exal orb 6l");
            Assert.AreNotEqual(null, message);
            Assert.AreEqual(true, regex.IsMatch(message.Text));

            message = poebot.ProcessRequest("/p tabula ra");
            regex   = new Regex(@"Минимальная: \d?[1-9]+\d?c");
            Assert.AreNotEqual(null, message);
            Assert.AreEqual(true, regex.IsMatch(message.Text));
        }
Exemplo n.º 11
0
        private static void Main()
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            Common.Logger = new ConsoleLogger();

            _rssUpdate           = new Timer(10 * 1000);
            _rssUpdate.Elapsed  += UpdateRss;
            _rssUpdate.AutoReset = true;
            //_rssUpdate.Enabled = true;

            var language = new Dictionary <long, ResponseLanguage>
            {
                { 0, ResponseLanguage.Russain }
            };

            var api = new PoeApi();

            Console.WriteLine("Working");

            while (true)
            {
                var poebot = new Poebot(api, new MockPhoto(true), new MockLanguage(language));
                var query  = Console.ReadLine();
                if (string.IsNullOrEmpty(query))
                {
                    continue;
                }
                var sw = new Stopwatch();
                sw.Start();
                var message = poebot.ProcessRequest(query);
                sw.Stop();
                if (message == null)
                {
                    Console.WriteLine("Некорректный запрос");
                    continue;
                }

                Console.WriteLine(message.Text);
                Console.WriteLine($"\nВремя обработки запроса: {sw.ElapsedMilliseconds} мс\n");
            }
        }
Exemplo n.º 12
0
        private async void TelegramBot_OnMessage(object sender, MessageEventArgs e)
        {
            await Task.Run(() =>
            {
                if (e.Message.Text == null)
                {
                    return;
                }
                if (e.Message.Date.AddMinutes(2) < DateTime.Now.ToUniversalTime())
                {
                    return;
                }

                var sobaka = e.Message.Text.Split('@');
                if (sobaka.Length > 1)
                {
                    if (sobaka[1] == _telegramBot.GetMeAsync().Result.Username)
                    {
                        e.Message.Text = sobaka[0];
                    }
                    else
                    {
                        return;
                    }
                }

                var poebot = new Poebot(Api,
                                        new TelegramPhoto(_cachePath, e.Message.Chat.Id, _telegramBot),
                                        new ChatLanguage(_langPath, e.Message.Chat.Id, _langsDictionary));
                var sw = new Stopwatch();
                sw.Start();
                var request = e.Message.Text;
                if (request.Contains("/sub "))
                {
                    request = $"{request}+{e.Message.Chat.Id}+{_subPath}";
                }

                var message = poebot.ProcessRequest(request);
                if (message == null)
                {
                    return;
                }
                if (message.Text != null)
                {
                    _telegramBot.SendTextMessageAsync(e.Message.Chat.Id, message.Text);
                }

                var content = message.Photo?.GetContent();
                if (content != null)
                {
                    _telegramBot.SendPhotoAsync(e.Message.Chat.Id, content[0]);
                }

                sw.Stop();
                if (!(request.Contains("/help") || request.Contains("/start")))
                {
                    Common.Logger?.LogInfo($"Запрос: {request}" +
                                           "\n\nОтвет:" +
                                           $"\n{message.Text ?? ""}" +
                                           $"\nВремя ответа: {sw.ElapsedMilliseconds}" +
                                           $"\n---");
                }
            });
        }