<commit_before>﻿using System;
using DarkSky.Services;
using Discord.Commands;
using GoogleGeoCoderCore;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace portalbot.Commands
{
    public class WeatherModule : ModuleBase
    {
        private static readonly Regex ValidCityState = new Regex(@"^[\p{L}\p{Mn}]+(?:[\s-][a-zA-Z]+)*(?:(\,|(\,\s))?[\p{L}\p{Mn}]{2,})$", RegexOptions.IgnoreCase);

        private readonly GoogleGeocodeService _geocoder;
        private readonly DarkSkyService _darkSky;

        public WeatherModule(GoogleGeocodeService geocoder, DarkSkyService darkSky)
        {
            _geocoder = geocoder;
            _darkSky = darkSky;
        }

        [Command("weather")]
        [Summary("Echos a message.")]
        [Alias("woppy")]
        public async Task Weather([Remainder, Summary("City (State optional")] string city)
        {
            if (!ValidCityState.IsMatch(city))
            {
                await ReplyAsync("Invalid city format, please try again. (eg. Montreal, QC)");
                return;
            }

            var location = GetLocation(city);

            const double tolerance = 0.001f;
            if (Math.Abs(location.Result.Latitude) < tolerance && Math.Abs(location.Result.Longitude) < tolerance)
            {
                await ReplyAsync("City not found, please try again.");
                return;
            }

            var forecast = _darkSky.GetForecast(location.Result.Latitude, location.Result.Longitude);
            var currently = forecast.Result.Response.Currently;

            if (currently.ApparentTemperature != null && currently.WindSpeed != null)
                await ReplyAsync($"Weather in ***{city}*** is currently ***{(int)currently.ApparentTemperature}°F***, with wind speed of ***{(int)currently.WindSpeed}mph***.");
        }

        private async Task<Location> GetLocation(string address)
        {
            var result = await _geocoder.GeocodeLocation(address);
            return result;
        }
    }
}
<commit_msg>Fix minor matching issue<commit_after>﻿using System;
using DarkSky.Services;
using Discord.Commands;
using GoogleGeoCoderCore;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace portalbot.Commands
{
    public class WeatherModule : ModuleBase
    {
        private static readonly Regex ValidCityState = new Regex(@"^[\p{L}\p{Mn}]+(?:[\s-][\p{L}\p{Mn}]+)*(?:(\,|(\,\s))?[\p{L}\p{Mn}]{2,})$", RegexOptions.IgnoreCase);

        private readonly GoogleGeocodeService _geocoder;
        private readonly DarkSkyService _darkSky;

        public WeatherModule(GoogleGeocodeService geocoder, DarkSkyService darkSky)
        {
            _geocoder = geocoder;
            _darkSky = darkSky;
        }

        [Command("weather")]
        [Summary("Echos a message.")]
        [Alias("woppy")]
        public async Task Weather([Remainder, Summary("City (State optional")] string city)
        {
            if (!ValidCityState.IsMatch(city))
            {
                await ReplyAsync("Invalid city format, please try again. (eg. Montreal, QC)");
                return;
            }

            var location = GetLocation(city);

            const double tolerance = 0.001f;
            if (Math.Abs(location.Result.Latitude) < tolerance && Math.Abs(location.Result.Longitude) < tolerance)
            {
                await ReplyAsync("City not found, please try again.");
                return;
            }

            var forecast = _darkSky.GetForecast(location.Result.Latitude, location.Result.Longitude);
            var currently = forecast.Result.Response.Currently;

            if (currently.ApparentTemperature != null && currently.WindSpeed != null)
                await ReplyAsync($"Weather in ***{city}*** is currently ***{(int)currently.ApparentTemperature}°F***, with wind speed of ***{(int)currently.WindSpeed}mph***.");
        }

        private async Task<Location> GetLocation(string address)
        {
            var result = await _geocoder.GeocodeLocation(address);
            return result;
        }
    }
}

{'fraction_non_alphanumeric': 0.1234269119070668, 'fraction_numerical': 0.002420135527589545, 'mean_word_length': 2.4327242524916945, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3092087', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1109, 'n_words': 253}