Fixed ~img and ~rimg, closes #1001

This commit is contained in:
Kwoth 2017-01-25 03:19:43 +01:00
parent cde2931a51
commit a4c190c312
2 changed files with 4 additions and 2 deletions

View File

@ -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);

View File

@ -199,7 +199,7 @@ namespace NadekoBot.Services.Impl
}
}
public async Task<ImageResult> GetImageAsync(string query, int start = 0)
public async Task<ImageResult> GetImageAsync(string query, int start = 1)
{
if (string.IsNullOrWhiteSpace(query))
throw new ArgumentNullException(nameof(query));