Wikia Search
This commit is contained in:
parent
56eb10cf81
commit
c06b1ae33c
@ -465,6 +465,41 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
}
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Wikia(IUserMessage umsg, string targ, [Remainder] string query = null)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
var arg = query;
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
{
|
||||
await channel.SendMessageAsync("💢 Please enter `target query`.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
http.DefaultRequestHeaders.Clear();
|
||||
string target = targ;
|
||||
string search = arg;
|
||||
try
|
||||
{
|
||||
var res = await http.GetStringAsync($"http://www.{Uri.EscapeUriString(target)}.wikia.com/api/v1/Search/List?query={Uri.EscapeUriString(search)}&limit=25&minArticleQuality=10&batch=1&namespaces=0%2C14").ConfigureAwait(false);
|
||||
var items = JObject.Parse(res);
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"`Found:` {items["items"][0]["title"].ToString()}");
|
||||
sb.AppendLine($"`Total Found:` {items["total"].ToString()}");
|
||||
sb.AppendLine($"`Batch:` {items["currentBatch"].ToString()}/{items["batches"].ToString()}");
|
||||
sb.Append($"`URL:` <{await _google.ShortenUrl(items["items"][0]["url"].ToString()).ConfigureAwait(false)}> / `Quality`: {items["items"][0]["quality"].ToString()}");
|
||||
await channel.SendMessageAsync(sb.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
await channel.SendMessageAsync($"💢 Failed finding `{arg}`.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task MCPing(IUserMessage umsg, [Remainder] string query = null)
|
||||
|
27
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
27
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -7511,6 +7511,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to wikia.
|
||||
/// </summary>
|
||||
public static string wikia_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("wikia_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Gives you back a wikia link.
|
||||
/// </summary>
|
||||
public static string wikia_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("wikia_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}wikia target query`.
|
||||
/// </summary>
|
||||
public static string wikia_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("wikia_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to wowjoke.
|
||||
/// </summary>
|
||||
|
@ -2637,4 +2637,13 @@
|
||||
<data name="mcq_usage" xml:space="preserve">
|
||||
<value>`{0}mcq server:ip`</value>
|
||||
</data>
|
||||
<data name="wikia_cmd" xml:space="preserve">
|
||||
<value>wikia</value>
|
||||
</data>
|
||||
<data name="wikia_desc" xml:space="preserve">
|
||||
<value>Gives you back a wikia link</value>
|
||||
</data>
|
||||
<data name="wikia_usage" xml:space="preserve">
|
||||
<value>`{0}wikia target query`</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user