Improvements

This commit is contained in:
Kwoth 2016-11-09 19:28:26 +01:00
parent 72608fae28
commit cc08f71bc6
3 changed files with 10 additions and 10 deletions

View File

@ -501,21 +501,21 @@ $@"🌍 **Weather for** 【{obj["target"]}】
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(query)) if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(query))
{ {
await channel.SendMessageAsync("💢 Please enter `target query`.").ConfigureAwait(false); await channel.SendMessageAsync("💢 Please enter a target wikia, followed by search query.").ConfigureAwait(false);
return; return;
} }
await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false); await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false);
using (var http = new HttpClient()) using (var http = new HttpClient())
{ {
http.DefaultRequestHeaders.Clear(); http.DefaultRequestHeaders.Clear();
try try
{ {
var res = await http.GetStringAsync($"http://www.{Uri.EscapeUriString(target)}.wikia.com/api/v1/Search/List?query={Uri.EscapeUriString(query)}&limit=25&minArticleQuality=10&batch=1&namespaces=0%2C14").ConfigureAwait(false); var res = await http.GetStringAsync($"http://www.{Uri.EscapeUriString(target)}.wikia.com/api/v1/Search/List?query={Uri.EscapeUriString(query)}&limit=25&minArticleQuality=10&batch=1&namespaces=0%2C14").ConfigureAwait(false);
var items = JObject.Parse(res); var items = JObject.Parse(res);
var response = $@"`Found:` {items["items"][0]["title"].ToString()} var found = items["items"][0];
`Total Found:` {items["total"].ToString()} var response = $@"`Title:` {found["title"].ToString()}
`Batch:` {items["currentBatch"].ToString()}/{items["batches"].ToString()} `Quality:` {found["quality"]}
`URL:` <{await _google.ShortenUrl(items["items"][0]["url"].ToString()).ConfigureAwait(false)}> / `Quality`: {items["items"][0]["quality"].ToString()}"; `URL:` {await NadekoBot.Google.ShortenUrl(found["url"].ToString()).ConfigureAwait(false)}";
await channel.SendMessageAsync(response); await channel.SendMessageAsync(response);
} }
catch catch

View File

@ -7584,7 +7584,7 @@ namespace NadekoBot.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to `{0}wikia target query`. /// Looks up a localized string similar to `{0}wikia mtg Vigilance` or `{0}wikia mlp Dashy`.
/// </summary> /// </summary>
public static string wikia_usage { public static string wikia_usage {
get { get {

View File

@ -2662,6 +2662,6 @@
<value>Gives you back a wikia link</value> <value>Gives you back a wikia link</value>
</data> </data>
<data name="wikia_usage" xml:space="preserve"> <data name="wikia_usage" xml:space="preserve">
<value>`{0}wikia target query`</value> <value>`{0}wikia mtg Vigilance` or `{0}wikia mlp Dashy`</value>
</data> </data>
</root> </root>