Esempio n. 1
0
        private void cmd_currentTimeDiff()
        {
            DateTime now = MasterAPI.CurrentTime();

            TimeSpan diff = now - DateTime.Now;

            Bot.Say("-" + diff.ToString());
        }
Esempio n. 2
0
        private void cmd_currentTime()
        {
            DateTime now = MasterAPI.CurrentTime();

            Bot.Say(now.ToString());
        }
Esempio n. 3
0
        private void cmd_weather()
        {
            Weather weather = null;
            string  city    = Message.NextCommand();
            string  country = Message.NextCommand();
            string  time    = Message.NextCommand();

            bool getForecast = false;
            int  hour        = 0;

            if (int.TryParse(city, out hour))
            {
                city        = "";
                country     = "";
                getForecast = true;
            }
            else if (int.TryParse(country, out hour))
            {
                country     = "";
                getForecast = true;
            }
            else if (int.TryParse(time, out hour))
            {
                getForecast = true;
            }

            if (getForecast)
            {
                DateTime now  = DateTime.Now;
                DateTime date = new DateTime(now.Year, now.Month, now.Day);

                hour = hour > 24 ? 24 : hour;
                hour = hour < 0 ? 0 : hour;

                if (hour < now.Hour)
                {
                    date = date.AddDays(1);
                }

                date = date.AddHours(hour);

                weather = MasterAPI.WeatherOrForecast(city, country, date);
            }
            else
            {
                weather = MasterAPI.WeatherOrForecast(city, country, null);
            }

            if (weather != null)
            {
                string message =
                    weather.City.Name + " " + weather.Date.ToShortDateTimeString() +
                    " | Lämpötila: " + weather.Temperature + TXT.CENTIGRADE +
                    ", tuntuu kuin: " + weather.FeelsLike +
                    " | Pilvisyys: " + weather.Cloudiness + "%" +
                    " | Ilmankosteus: " + weather.Humidity + "%" +
                    " | Tuulennopeus: " + weather.WindSpeed + "m/s" +
                    weather.WeatherDescription;

                Bot.Action(message);
            }
        }