all nsfw commands except ~hentaibomb and ~autohentai will work on public bot again
This commit is contained in:
parent
4d2d27d48f
commit
12eb216a4b
@ -19,7 +19,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
[NadekoModule("NSFW", "~")]
|
[NadekoModule("NSFW", "~")]
|
||||||
public class NSFW : DiscordModule
|
public class NSFW : DiscordModule
|
||||||
{
|
{
|
||||||
#if !GLOBAL_NADEKO
|
|
||||||
private static ConcurrentDictionary<ulong, Timer> AutoHentaiTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
|
private static ConcurrentDictionary<ulong, Timer> AutoHentaiTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
|
||||||
private static ConcurrentHashSet<ulong> _hentaiBombBlacklist { get; } = new ConcurrentHashSet<ulong>();
|
private static ConcurrentHashSet<ulong> _hentaiBombBlacklist { get; } = new ConcurrentHashSet<ulong>();
|
||||||
|
|
||||||
@ -66,79 +66,79 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
public Task Hentai([Remainder] string tag = null) =>
|
public Task Hentai([Remainder] string tag = null) =>
|
||||||
InternalHentai(Context.Channel, tag, false);
|
InternalHentai(Context.Channel, tag, false);
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
//[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireUserPermission(ChannelPermission.ManageMessages)]
|
//[RequireUserPermission(ChannelPermission.ManageMessages)]
|
||||||
public async Task AutoHentai(int interval = 0, string tags = null)
|
//public async Task AutoHentai(int interval = 0, string tags = null)
|
||||||
{
|
//{
|
||||||
Timer t;
|
// Timer t;
|
||||||
|
|
||||||
if (interval == 0)
|
// if (interval == 0)
|
||||||
{
|
// {
|
||||||
if (AutoHentaiTimers.TryRemove(Context.Channel.Id, out t))
|
// if (AutoHentaiTimers.TryRemove(Context.Channel.Id, out t))
|
||||||
{
|
// {
|
||||||
t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
|
// t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
|
||||||
await Context.Channel.SendConfirmAsync("Autohentai stopped.").ConfigureAwait(false);
|
// await Context.Channel.SendConfirmAsync("Autohentai stopped.").ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (interval < 20)
|
// if (interval < 20)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
var tagsArr = tags?.Split('|');
|
// var tagsArr = tags?.Split('|');
|
||||||
|
|
||||||
t = new Timer(async (state) =>
|
// t = new Timer(async (state) =>
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (tagsArr == null || tagsArr.Length == 0)
|
// if (tagsArr == null || tagsArr.Length == 0)
|
||||||
await InternalHentai(Context.Channel, null, true).ConfigureAwait(false);
|
// await InternalHentai(Context.Channel, null, true).ConfigureAwait(false);
|
||||||
else
|
// else
|
||||||
await InternalHentai(Context.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)], true).ConfigureAwait(false);
|
// await InternalHentai(Context.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)], true).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
catch { }
|
// catch { }
|
||||||
}, null, interval * 1000, interval * 1000);
|
// }, null, interval * 1000, interval * 1000);
|
||||||
|
|
||||||
AutoHentaiTimers.AddOrUpdate(Context.Channel.Id, t, (key, old) =>
|
// AutoHentaiTimers.AddOrUpdate(Context.Channel.Id, t, (key, old) =>
|
||||||
{
|
// {
|
||||||
old.Change(Timeout.Infinite, Timeout.Infinite);
|
// old.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
return t;
|
// return t;
|
||||||
});
|
// });
|
||||||
|
|
||||||
await Context.Channel.SendConfirmAsync($"Autohentai started. Reposting every {interval}s with one of the following tags:\n{string.Join(", ", tagsArr)}")
|
// await Context.Channel.SendConfirmAsync($"Autohentai started. Reposting every {interval}s with one of the following tags:\n{string.Join(", ", tagsArr)}")
|
||||||
.ConfigureAwait(false);
|
// .ConfigureAwait(false);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
//[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task HentaiBomb([Remainder] string tag = null)
|
//public async Task HentaiBomb([Remainder] string tag = null)
|
||||||
{
|
//{
|
||||||
if (!_hentaiBombBlacklist.Add(Context.User.Id))
|
// if (!_hentaiBombBlacklist.Add(Context.User.Id))
|
||||||
return;
|
// return;
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
tag = tag?.Trim() ?? "";
|
// tag = tag?.Trim() ?? "";
|
||||||
tag = "rating%3Aexplicit+" + tag;
|
// tag = "rating%3Aexplicit+" + tag;
|
||||||
|
|
||||||
var links = await Task.WhenAll(GetGelbooruImageLink(tag),
|
// var links = await Task.WhenAll(GetGelbooruImageLink(tag),
|
||||||
GetDanbooruImageLink(tag),
|
// GetDanbooruImageLink(tag),
|
||||||
GetKonachanImageLink(tag),
|
// GetKonachanImageLink(tag),
|
||||||
GetYandereImageLink(tag)).ConfigureAwait(false);
|
// GetYandereImageLink(tag)).ConfigureAwait(false);
|
||||||
|
|
||||||
var linksEnum = links?.Where(l => l != null);
|
// var linksEnum = links?.Where(l => l != null);
|
||||||
if (links == null || !linksEnum.Any())
|
// if (links == null || !linksEnum.Any())
|
||||||
{
|
// {
|
||||||
await Context.Channel.SendErrorAsync("No results found.").ConfigureAwait(false);
|
// await Context.Channel.SendErrorAsync("No results found.").ConfigureAwait(false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
await Context.Channel.SendMessageAsync(String.Join("\n\n", linksEnum)).ConfigureAwait(false);
|
// await Context.Channel.SendMessageAsync(String.Join("\n\n", linksEnum)).ConfigureAwait(false);
|
||||||
}
|
// }
|
||||||
finally {
|
// finally {
|
||||||
await Task.Delay(5000).ConfigureAwait(false);
|
// await Task.Delay(5000).ConfigureAwait(false);
|
||||||
_hentaiBombBlacklist.TryRemove(Context.User.Id);
|
// _hentaiBombBlacklist.TryRemove(Context.User.Id);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public Task Yandere([Remainder] string tag = null)
|
public Task Yandere([Remainder] string tag = null)
|
||||||
@ -147,7 +147,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public Task Konachan([Remainder] string tag = null)
|
public Task Konachan([Remainder] string tag = null)
|
||||||
=> Searches.Searches.InternalDapiCommand(Context.Message, tag, Searches.Searches.DapiSearchType.Konachan);
|
=> Searches.Searches.InternalDapiCommand(Context.Message, tag, Searches.Searches.DapiSearchType.Konachan);
|
||||||
#endif
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task E621([Remainder] string tag = null)
|
public async Task E621([Remainder] string tag = null)
|
||||||
{
|
{
|
||||||
@ -279,7 +279,6 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
public static Task<string> GetRule34ImageLink(string tag) =>
|
public static Task<string> GetRule34ImageLink(string tag) =>
|
||||||
Searches.Searches.InternalDapiSearch(tag, Searches.Searches.DapiSearchType.Rule34);
|
Searches.Searches.InternalDapiSearch(tag, Searches.Searches.DapiSearchType.Rule34);
|
||||||
|
|
||||||
#if !GLOBAL_NADEKO
|
|
||||||
public static Task<string> GetYandereImageLink(string tag) =>
|
public static Task<string> GetYandereImageLink(string tag) =>
|
||||||
Searches.Searches.InternalDapiSearch(tag, Searches.Searches.DapiSearchType.Yandere);
|
Searches.Searches.InternalDapiSearch(tag, Searches.Searches.DapiSearchType.Yandere);
|
||||||
|
|
||||||
@ -288,6 +287,5 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
public static Task<string> GetGelbooruImageLink(string tag) =>
|
public static Task<string> GetGelbooruImageLink(string tag) =>
|
||||||
Searches.Searches.InternalDapiSearch(tag, Searches.Searches.DapiSearchType.Gelbooru);
|
Searches.Searches.InternalDapiSearch(tag, Searches.Searches.DapiSearchType.Gelbooru);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user