diff --git a/src/NadekoBot/Modules/Searches/Searches.cs b/src/NadekoBot/Modules/Searches/Searches.cs index ad160599..27840678 100644 --- a/src/NadekoBot/Modules/Searches/Searches.cs +++ b/src/NadekoBot/Modules/Searches/Searches.cs @@ -115,6 +115,8 @@ namespace NadekoBot.Modules.Searches if (string.IsNullOrWhiteSpace(terms)) return; + terms = WebUtility.UrlEncode(terms).Replace(' ', '+'); + try { var res = await NadekoBot.Google.GetImageAsync(terms).ConfigureAwait(false); @@ -131,7 +133,6 @@ namespace NadekoBot.Modules.Searches catch { _log.Warn("Falling back to Imgur search."); - terms = WebUtility.UrlEncode(terms).Replace(' ', '+'); var fullQueryLink = $"http://imgur.com/search?q={ terms }"; var config = Configuration.Default.WithDefaultLoader(); @@ -167,6 +168,7 @@ namespace NadekoBot.Modules.Searches terms = terms?.Trim(); if (string.IsNullOrWhiteSpace(terms)) return; + terms = WebUtility.UrlEncode(terms).Replace(' ', '+'); try { var res = await NadekoBot.Google.GetImageAsync(terms, new NadekoRandom().Next(0, 50)).ConfigureAwait(false); diff --git a/src/NadekoBot/Services/Impl/GoogleApiService.cs b/src/NadekoBot/Services/Impl/GoogleApiService.cs index f2934ba6..187bf272 100644 --- a/src/NadekoBot/Services/Impl/GoogleApiService.cs +++ b/src/NadekoBot/Services/Impl/GoogleApiService.cs @@ -199,7 +199,7 @@ namespace NadekoBot.Services.Impl } } - public async Task GetImageAsync(string query, int start = 0) + public async Task GetImageAsync(string query, int start = 1) { if (string.IsNullOrWhiteSpace(query)) throw new ArgumentNullException(nameof(query));