added ~e621 nsfw command (at the request of kongslien)
This commit is contained in:
parent
0afb3cc4eb
commit
d07005876c
@ -170,7 +170,7 @@ namespace NadekoBot.Classes {
|
|||||||
if (tag == "loli") //loli doesn't work for some reason atm
|
if (tag == "loli") //loli doesn't work for some reason atm
|
||||||
tag = "flat_chest";
|
tag = "flat_chest";
|
||||||
|
|
||||||
var webpage = await GetResponseAsync($"http://danbooru.donmai.us/posts?page={ rng.Next(0, 30) }&tags={ tag.Replace(" ", "_") }");
|
var webpage = await GetResponseAsync($"http://danbooru.donmai.us/posts?page={ rng.Next(0, 15) }&tags={ tag.Replace(" ", "_") }");
|
||||||
var matches = Regex.Matches(webpage, "data-large-file-url=\"(?<id>.*?)\"");
|
var matches = Regex.Matches(webpage, "data-large-file-url=\"(?<id>.*?)\"");
|
||||||
|
|
||||||
return await $"http://danbooru.donmai.us{ matches[rng.Next(0, matches.Count)].Groups["id"].Value }".ShortenUrl();
|
return await $"http://danbooru.donmai.us{ matches[rng.Next(0, matches.Count)].Groups["id"].Value }".ShortenUrl();
|
||||||
@ -182,7 +182,7 @@ namespace NadekoBot.Classes {
|
|||||||
public static async Task<string> GetGelbooruImageLink(string tag) {
|
public static async Task<string> GetGelbooruImageLink(string tag) {
|
||||||
try {
|
try {
|
||||||
var rng = new Random();
|
var rng = new Random();
|
||||||
var url = $"http://gelbooru.com/index.php?page=post&s=list&pid={ rng.Next(0, 15) * 42 }&tags={ tag.Replace(" ", "_") }";
|
var url = $"http://gelbooru.com/index.php?page=post&s=list&pid={ rng.Next(0, 10) * 42 }&tags={ tag.Replace(" ", "_") }";
|
||||||
var webpage = await GetResponseAsync(url); // first extract the post id and go to that posts page
|
var webpage = await GetResponseAsync(url); // first extract the post id and go to that posts page
|
||||||
var matches = Regex.Matches(webpage, "span id=\"s(?<id>\\d*)\"");
|
var matches = Regex.Matches(webpage, "span id=\"s(?<id>\\d*)\"");
|
||||||
var postLink = $"http://gelbooru.com/index.php?page=post&s=view&id={ matches[rng.Next(0, matches.Count)].Groups["id"].Value }";
|
var postLink = $"http://gelbooru.com/index.php?page=post&s=view&id={ matches[rng.Next(0, matches.Count)].Groups["id"].Value }";
|
||||||
@ -195,6 +195,18 @@ namespace NadekoBot.Classes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static async Task<string> GetE621ImageLink(string tags) {
|
||||||
|
try {
|
||||||
|
var rng = new Random();
|
||||||
|
var url = $"https://e621.net/post/index/{rng.Next(0, 5)}/{Uri.EscapeUriString(tags)}";
|
||||||
|
var webpage = await GetResponseAsync(url); // first extract the post id and go to that posts page
|
||||||
|
var matches = Regex.Matches(webpage, "\"file_url\":\"(?<url>.*?)\"");
|
||||||
|
return matches[rng.Next(0,matches.Count)].Groups["url"].Value;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<string> ShortenUrl(string url) {
|
public static async Task<string> ShortenUrl(string url) {
|
||||||
if (NadekoBot.GoogleAPIKey == null || NadekoBot.GoogleAPIKey == "") return url;
|
if (NadekoBot.GoogleAPIKey == null || NadekoBot.GoogleAPIKey == "") return url;
|
||||||
try {
|
try {
|
||||||
|
@ -141,6 +141,7 @@ namespace NadekoBot.Modules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".roles")
|
cgb.CreateCommand(".roles")
|
||||||
.Description("List all roles on this server or a single user if specified.")
|
.Description("List all roles on this server or a single user if specified.")
|
||||||
.Parameter("user", ParameterType.Unparsed)
|
.Parameter("user", ParameterType.Unparsed)
|
||||||
@ -597,10 +598,10 @@ namespace NadekoBot.Modules {
|
|||||||
.Do(async e => {
|
.Do(async e => {
|
||||||
await Task.Run(async () => {
|
await Task.Run(async () => {
|
||||||
var rows = Classes.DBHandler.Instance.GetAllRows<Donator>();
|
var rows = Classes.DBHandler.Instance.GetAllRows<Donator>();
|
||||||
var donatorsOrdered = rows.OrderBy(d => d.Amount);
|
var donatorsOrdered = rows.OrderByDescending(d => d.Amount);
|
||||||
string str = $"`Total number of people who donated is {donatorsOrdered.Count()}`\n";
|
string str = $"`Total number of people who donated is {donatorsOrdered.Count()}`\n";
|
||||||
|
|
||||||
await e.Channel.SendMessage(string.Join(", ", donatorsOrdered.Select(d => d.UserName)));
|
await e.Channel.SendMessage(str + string.Join(", ", donatorsOrdered.Select(d => d.UserName)));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,6 +47,15 @@ namespace NadekoBot.Modules {
|
|||||||
tag = "";
|
tag = "";
|
||||||
await e.Send(await SearchHelper.GetGelbooruImageLink(tag));
|
await e.Send(await SearchHelper.GetGelbooruImageLink(tag));
|
||||||
});
|
});
|
||||||
|
cgb.CreateCommand("~e621")
|
||||||
|
.Description("Shows a random hentai image from e621.net with a given tag. Tag is optional but preffered. Use spaces for multiple tags.\n**Usage**: ~e621 yuri kissing")
|
||||||
|
.Parameter("tag", ParameterType.Unparsed)
|
||||||
|
.Do(async e => {
|
||||||
|
string tag = e.GetArg("tag");
|
||||||
|
if (tag == null)
|
||||||
|
tag = "";
|
||||||
|
await e.Send(await SearchHelper.GetE621ImageLink(tag));
|
||||||
|
});
|
||||||
cgb.CreateCommand("~cp")
|
cgb.CreateCommand("~cp")
|
||||||
.Description("We all know where this will lead you to.")
|
.Description("We all know where this will lead you to.")
|
||||||
.Parameter("anything", ParameterType.Unparsed)
|
.Parameter("anything", ParameterType.Unparsed)
|
||||||
|
Loading…
Reference in New Issue
Block a user