Пример #1
0
        public bool HandleRequest(Post message)
        {
            if (message.Message.StartsWith("pogoda dziś", StringComparison.InvariantCultureIgnoreCase))
            {
                var    splited  = message.Message.Split(new char[] { ' ' }, 3); // niepotrzebne aktualnie
                string response = weatherService.AccuResponse($"{accuUrl}/forecasts/v1/daily/1day/264814?apikey={accuKey}&language=pl-pl&details=true&metric=true");
                connection.SendMessage(message.Channel, response);

                return(true);
            }
            else if (message.Message.StartsWith("pogoda", StringComparison.InvariantCultureIgnoreCase))
            {
                var splited = message.Message.Split(new char[] { ' ' }, 2);


                if (splited.Length == 2)
                {
                    string response = weatherService.WeatherResponse($"{weatherURL}?q={splited[1]}&appid={appKey}&units=metric&lang=pl");
                    connection.SendMessage(message.Channel, response);
                }
                else
                {
                    string response = weatherService.WeatherResponse($"{weatherURL}?q=Siedlce&appid={appKey}&units=metric&lang=pl");
                    connection.SendMessage(message.Channel, response);
                }

                return(true);
            }
            return(false);
        }