private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, bool useLure, bool useInvasion) { var lureImageUrl = IconFetcher.Instance.GetLureIcon(whConfig.Servers[guild.Id].IconStyle, LureType); var invasionImageUrl = IconFetcher.Instance.GetInvasionIcon(whConfig.Servers[guild.Id].IconStyle, GruntType); var imageUrl = useInvasion ? invasionImageUrl : useLure ? lureImageUrl : Url; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var staticMapLink = StaticMap.GetUrl(whConfig.Urls.StaticMap, useInvasion ? whConfig.StaticMaps["invasions"] : useLure ? whConfig.StaticMaps["lures"] : /* TODO: */ "", Latitude, Longitude, imageUrl); var gmapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, city, Latitude, Longitude).GetAddress(whConfig); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var invasion = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? MasterFile.Instance.GruntTypes[GruntType] : null; var leaderString = Translator.Instance.Translate("grunt_" + Convert.ToInt32(GruntType)); var pokemonType = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? Notifications.GetPokemonTypeFromString(invasion?.Type) : PokemonType.None; var invasionTypeEmoji = pokemonType == PokemonType.None ? leaderString : pokemonType.GetTypeEmojiIcons(); var invasionEncounters = GruntType > 0 ? invasion.GetPossibleInvasionEncounters() : string.Empty; var now = DateTime.UtcNow.ConvertTimeFromCoordinates(Latitude, Longitude); var lureExpireTimeLeft = now.GetTimeRemaining(LureExpireTime).ToReadableStringNoSeconds(); var invasionExpireTimeLeft = now.GetTimeRemaining(InvasionExpireTime).ToReadableStringNoSeconds(); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "has_lure", Convert.ToString(HasLure) }, { "lure_type", LureType.ToString() }, { "lure_expire_time", LureExpireTime.ToLongTimeString() }, { "lure_expire_time_24h", LureExpireTime.ToString("HH:mm:ss") }, { "lure_expire_time_left", lureExpireTimeLeft }, { "has_invasion", Convert.ToString(HasInvasion) }, { "grunt_type", invasion?.Type }, { "grunt_type_emoji", invasionTypeEmoji }, { "grunt_gender", invasion?.Grunt }, { "invasion_expire_time", InvasionExpireTime.ToLongTimeString() }, { "invasion_expire_time_24h", InvasionExpireTime.ToString("HH:mm:ss") }, { "invasion_expire_time_left", invasionExpireTimeLeft }, { "invasion_encounters", $"**Encounter Reward Chance:**\r\n" + invasionEncounters }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, //Pokestop properties { "pokestop_id", PokestopId ?? defaultMissingValue }, { "pokestop_name", Name ?? defaultMissingValue }, { "pokestop_url", Url ?? defaultMissingValue }, { "lure_img_url", lureImageUrl }, { "invasion_img_url", invasionImageUrl }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city) { var lureImageUrl = IconFetcher.Instance.GetLureIcon(whConfig.Servers[guild.Id].IconStyle, LureType); var invasionImageUrl = IconFetcher.Instance.GetInvasionIcon(whConfig.Servers[guild.Id].IconStyle, GruntType); var imageUrl = HasInvasion ? invasionImageUrl : HasLure ? lureImageUrl : Url; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var templatePath = Path.Combine(whConfig.StaticMaps.TemplatesFolder, HasInvasion ? whConfig.StaticMaps.Invasions.TemplateFile : HasLure ? whConfig.StaticMaps.Lures.TemplateFile : whConfig.StaticMaps.Lures.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, whConfig.Urls.StaticMap, HasInvasion ? whConfig.StaticMaps.Invasions.ZoomLevel : HasLure ? whConfig.StaticMaps.Lures.ZoomLevel : whConfig.StaticMaps.Lures.ZoomLevel, Latitude, Longitude, imageUrl, null); var gmapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? gmapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? appleMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? wazeMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? scannerMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); Geofence.Location address = null; if (!string.IsNullOrEmpty(whConfig.GoogleMapsKey)) { address = Utils.GetGoogleAddress(city, Latitude, Longitude, whConfig.GoogleMapsKey); } else if (!string.IsNullOrEmpty(whConfig.NominatimEndpoint)) { address = Utils.GetNominatimAddress(city, Latitude, Longitude, whConfig.NominatimEndpoint); } //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var invasion = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? MasterFile.Instance.GruntTypes[GruntType] : null; var leaderString = Translator.Instance.Translate("grunt_" + Convert.ToInt32(GruntType)); var pokemonType = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? Commands.Notifications.GetPokemonTypeFromString(invasion?.Type) : PokemonType.None; var invasionTypeEmoji = pokemonType == PokemonType.None ? leaderString : pokemonType.GetTypeEmojiIcons(); var invasionEncounters = GruntType > 0 ? invasion.GetPossibleInvasionEncounters() : string.Empty; const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "has_lure", Convert.ToString(HasLure) }, { "lure_type", LureType.ToString() }, { "lure_expire_time", LureExpireTime.ToLongTimeString() }, { "lure_expire_time_24h", LureExpireTime.ToString("HH:mm:ss") }, { "lure_expire_time_left", LureExpireTime.GetTimeRemaining().ToReadableStringNoSeconds() }, { "has_invasion", Convert.ToString(HasInvasion) }, { "grunt_type", invasion?.Type }, { "grunt_type_emoji", invasionTypeEmoji }, { "grunt_gender", invasion?.Grunt }, { "invasion_expire_time", InvasionExpireTime.ToLongTimeString() }, { "invasion_expire_time_24h", InvasionExpireTime.ToString("HH:mm:ss") }, { "invasion_expire_time_left", InvasionExpireTime.GetTimeRemaining().ToReadableStringNoSeconds() }, { "invasion_encounters", $"**Encounter Reward Chance:**\r\n" + invasionEncounters }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Math.Round(Latitude, 5).ToString() }, { "lng_5", Math.Round(Longitude, 5).ToString() }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, //Pokestop properties { "pokestop_id", PokestopId ?? defaultMissingValue }, { "pokestop_name", Name ?? defaultMissingValue }, { "pokestop_url", Url ?? defaultMissingValue }, { "lure_img_url", lureImageUrl }, { "invasion_img_url", invasionImageUrl }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }