~konachan added :D
This commit is contained in:
parent
eff92b3328
commit
3859e00e88
@ -55,6 +55,20 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
await channel.SendMessageAsync(link).ConfigureAwait(false);
|
await channel.SendMessageAsync(link).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
public async Task Konachan(IUserMessage umsg, [Remainder] string tag = null)
|
||||||
|
{
|
||||||
|
var channel = (ITextChannel)umsg.Channel;
|
||||||
|
|
||||||
|
tag = tag?.Trim() ?? "";
|
||||||
|
var link = await GetKonachanImageLink(tag).ConfigureAwait(false);
|
||||||
|
if (string.IsNullOrWhiteSpace(link))
|
||||||
|
await channel.SendMessageAsync("Search yielded no results ;(");
|
||||||
|
else
|
||||||
|
await channel.SendMessageAsync(link).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task Gelbooru(IUserMessage umsg, [Remainder] string tag = null)
|
public async Task Gelbooru(IUserMessage umsg, [Remainder] string tag = null)
|
||||||
@ -147,6 +161,25 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<string> GetKonachanImageLink(string tag)
|
||||||
|
{
|
||||||
|
var rng = new NadekoRandom();
|
||||||
|
|
||||||
|
var link = $"http://konachan.com/post?" +
|
||||||
|
$"page={rng.Next(0, 5)}";
|
||||||
|
if (!string.IsNullOrWhiteSpace(tag))
|
||||||
|
link += $"&tags={tag.Replace(" ", "_")}";
|
||||||
|
using (var http = new HttpClient())
|
||||||
|
{
|
||||||
|
var webpage = await http.GetStringAsync(link).ConfigureAwait(false);
|
||||||
|
var matches = Regex.Matches(webpage, "<a class=\"directlink largeimg\" href=\"(?<ll>.*?)\">");
|
||||||
|
|
||||||
|
if (matches.Count == 0)
|
||||||
|
return null;
|
||||||
|
return await NadekoBot.Google.ShortenUrl(matches[rng.Next(0, matches.Count)].Groups["ll"].Value).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<string> GetDanbooruImageLink(string tag)
|
public static async Task<string> GetDanbooruImageLink(string tag)
|
||||||
{
|
{
|
||||||
var rng = new NadekoRandom();
|
var rng = new NadekoRandom();
|
||||||
|
27
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
27
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -3326,6 +3326,33 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to konachan.
|
||||||
|
/// </summary>
|
||||||
|
public static string konachan_cmd {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("konachan_cmd", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Shows a random hentai image from konachan with a given tag. Tag is optional but preffered. (multiple tags are appended with +).
|
||||||
|
/// </summary>
|
||||||
|
public static string konachan_desc {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("konachan_desc", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to `~konachan yuri`.
|
||||||
|
/// </summary>
|
||||||
|
public static string konachan_usage {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("konachan_usage", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to lcsc.
|
/// Looks up a localized string similar to lcsc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2209,7 +2209,7 @@
|
|||||||
<value>safebooru</value>
|
<value>safebooru</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="safebooru_desc" xml:space="preserve">
|
<data name="safebooru_desc" xml:space="preserve">
|
||||||
<value>Shows a random image from safebooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)</value>
|
<value>Shows a random image from safebooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="safebooru_usage" xml:space="preserve">
|
<data name="safebooru_usage" xml:space="preserve">
|
||||||
<value>`~safebooru yuri+kissing`</value>
|
<value>`~safebooru yuri+kissing`</value>
|
||||||
@ -2263,7 +2263,7 @@
|
|||||||
<value>danbooru</value>
|
<value>danbooru</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="danbooru_desc" xml:space="preserve">
|
<data name="danbooru_desc" xml:space="preserve">
|
||||||
<value>Shows a random hentai image from danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)</value>
|
<value>Shows a random hentai image from danbooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="danbooru_usage" xml:space="preserve">
|
<data name="danbooru_usage" xml:space="preserve">
|
||||||
<value>`~danbooru yuri+kissing`</value>
|
<value>`~danbooru yuri+kissing`</value>
|
||||||
@ -2272,7 +2272,7 @@
|
|||||||
<value>gelbooru</value>
|
<value>gelbooru</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="gelbooru_desc" xml:space="preserve">
|
<data name="gelbooru_desc" xml:space="preserve">
|
||||||
<value>Shows a random hentai image from gelbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +)</value>
|
<value>Shows a random hentai image from gelbooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="gelbooru_usage" xml:space="preserve">
|
<data name="gelbooru_usage" xml:space="preserve">
|
||||||
<value>`~gelbooru yuri+kissing`</value>
|
<value>`~gelbooru yuri+kissing`</value>
|
||||||
@ -2281,7 +2281,7 @@
|
|||||||
<value>rule34</value>
|
<value>rule34</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="rule34_desc" xml:space="preserve">
|
<data name="rule34_desc" xml:space="preserve">
|
||||||
<value>Shows a random image from rule34.xx with a given tag. Tag is optional but preffered. (multiple tags are appended with +)</value>
|
<value>Shows a random image from rule34.xx with a given tag. Tag is optional but preferred. (multiple tags are appended with +)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="rule34_usage" xml:space="preserve">
|
<data name="rule34_usage" xml:space="preserve">
|
||||||
<value>`~rule34 yuri+kissing`</value>
|
<value>`~rule34 yuri+kissing`</value>
|
||||||
@ -2290,7 +2290,7 @@
|
|||||||
<value>e621</value>
|
<value>e621</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="e621_desc" xml:space="preserve">
|
<data name="e621_desc" xml:space="preserve">
|
||||||
<value>Shows a random hentai image from e621.net with a given tag. Tag is optional but preffered. Use spaces for multiple tags.</value>
|
<value>Shows a random hentai image from e621.net with a given tag. Tag is optional but preferred. Use spaces for multiple tags.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="e621_usage" xml:space="preserve">
|
<data name="e621_usage" xml:space="preserve">
|
||||||
<value>`~e621 yuri kissing`</value>
|
<value>`~e621 yuri kissing`</value>
|
||||||
@ -2682,4 +2682,13 @@
|
|||||||
<data name="voicemute_usage" xml:space="preserve">
|
<data name="voicemute_usage" xml:space="preserve">
|
||||||
<value>`.voicemute @Someone`</value>
|
<value>`.voicemute @Someone`</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="konachan_cmd" xml:space="preserve">
|
||||||
|
<value>konachan</value>
|
||||||
|
</data>
|
||||||
|
<data name="konachan_desc" xml:space="preserve">
|
||||||
|
<value>Shows a random hentai image from konachan with a given tag. Tag is optional but preferred. (multiple tags are appended with +)</value>
|
||||||
|
</data>
|
||||||
|
<data name="konachan_usage" xml:space="preserve">
|
||||||
|
<value>`~konachan yuri`</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user