Update SearchesModule.cs
Bot tells you, when you reached your daily limit with the Google Api.
This commit is contained in:
parent
fa213d2a1b
commit
0b20e8536a
@ -14,6 +14,7 @@ using System.Drawing;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Searches
|
namespace NadekoBot.Modules.Searches
|
||||||
{
|
{
|
||||||
@ -157,9 +158,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
|
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
|
||||||
await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
|
await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (HttpRequestException exception)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 {ex.Message}").ConfigureAwait(false);
|
if (exception.Message.Contains ("403 (Forbidden)"))
|
||||||
|
{
|
||||||
|
await e.Channel.SendMessage ("Daily limit reached!")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await e.Channel.SendMessage ("Something went wrong.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -176,9 +184,16 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
|
var obj = JObject.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false));
|
||||||
await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
|
await e.Channel.SendMessage(obj["items"][0]["link"].ToString()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (HttpRequestException exception)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage($"💢 {ex.Message}").ConfigureAwait(false);
|
if (exception.Message.Contains ("403 (Forbidden)"))
|
||||||
|
{
|
||||||
|
await e.Channel.SendMessage ("Daily limit reached!")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await e.Channel.SendMessage ("Something went wrong.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cgb.CreateCommand(Prefix + "lmgtfy")
|
cgb.CreateCommand(Prefix + "lmgtfy")
|
||||||
|
Loading…
Reference in New Issue
Block a user