nsfw translated. whole 5 strings out of which 3 are the same. :)
This commit is contained in:
@@ -20,8 +20,8 @@ namespace NadekoBot.Modules.NSFW
|
||||
public class NSFW : NadekoModule
|
||||
{
|
||||
|
||||
private static ConcurrentDictionary<ulong, Timer> AutoHentaiTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
|
||||
private static ConcurrentHashSet<ulong> _hentaiBombBlacklist { get; } = new ConcurrentHashSet<ulong>();
|
||||
private static readonly ConcurrentDictionary<ulong, Timer> AutoHentaiTimers = new ConcurrentDictionary<ulong, Timer>();
|
||||
private static readonly ConcurrentHashSet<ulong> HentaiBombBlacklist = new ConcurrentHashSet<ulong>();
|
||||
|
||||
private async Task InternalHentai(IMessageChannel channel, string tag, bool noError)
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
tag = "rating%3Aexplicit+" + tag;
|
||||
|
||||
var rng = new NadekoRandom();
|
||||
Task<string> provider = Task.FromResult("");
|
||||
var provider = Task.FromResult("");
|
||||
switch (rng.Next(0, 4))
|
||||
{
|
||||
case 0:
|
||||
@@ -45,20 +45,18 @@ namespace NadekoBot.Modules.NSFW
|
||||
case 3:
|
||||
provider = GetYandereImageLink(tag);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
var link = await provider.ConfigureAwait(false);
|
||||
if (string.IsNullOrWhiteSpace(link))
|
||||
{
|
||||
if (!noError)
|
||||
await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("not_found").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
.WithImageUrl(link)
|
||||
.WithDescription("Tag: " + tag))
|
||||
.WithDescription($"{GetText("tag")}: " + tag))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -74,11 +72,10 @@ namespace NadekoBot.Modules.NSFW
|
||||
|
||||
if (interval == 0)
|
||||
{
|
||||
if (AutoHentaiTimers.TryRemove(Context.Channel.Id, out t))
|
||||
{
|
||||
t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
|
||||
await Context.Channel.SendConfirmAsync("Autohentai stopped.").ConfigureAwait(false);
|
||||
}
|
||||
if (!AutoHentaiTimers.TryRemove(Context.Channel.Id, out t)) return;
|
||||
|
||||
t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
|
||||
await ReplyConfirmLocalized("autohentai_stopped").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,7 +93,10 @@ namespace NadekoBot.Modules.NSFW
|
||||
else
|
||||
await InternalHentai(Context.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)], true).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}, null, interval * 1000, interval * 1000);
|
||||
|
||||
AutoHentaiTimers.AddOrUpdate(Context.Channel.Id, t, (key, old) =>
|
||||
@@ -105,15 +105,16 @@ namespace NadekoBot.Modules.NSFW
|
||||
return t;
|
||||
});
|
||||
|
||||
await Context.Channel.SendConfirmAsync($"Autohentai started. Reposting every {interval}s with one of the following tags:\n{string.Join(", ", tagsArr)}")
|
||||
.ConfigureAwait(false);
|
||||
await ReplyConfirmLocalized("autohentai_started",
|
||||
interval,
|
||||
string.Join(", ", tagsArr)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task HentaiBomb([Remainder] string tag = null)
|
||||
{
|
||||
if (!_hentaiBombBlacklist.Add(Context.User.Id))
|
||||
if (!HentaiBombBlacklist.Add(Context.User.Id))
|
||||
return;
|
||||
try
|
||||
{
|
||||
@@ -125,19 +126,19 @@ namespace NadekoBot.Modules.NSFW
|
||||
GetKonachanImageLink(tag),
|
||||
GetYandereImageLink(tag)).ConfigureAwait(false);
|
||||
|
||||
var linksEnum = links?.Where(l => l != null);
|
||||
var linksEnum = links?.Where(l => l != null).ToArray();
|
||||
if (links == null || !linksEnum.Any())
|
||||
{
|
||||
await Context.Channel.SendErrorAsync("No results found.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("not_found").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await Context.Channel.SendMessageAsync(String.Join("\n\n", linksEnum)).ConfigureAwait(false);
|
||||
await Context.Channel.SendMessageAsync(string.Join("\n\n", linksEnum)).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await Task.Delay(5000).ConfigureAwait(false);
|
||||
_hentaiBombBlacklist.TryRemove(Context.User.Id);
|
||||
HentaiBombBlacklist.TryRemove(Context.User.Id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -157,7 +158,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
var url = await GetE621ImageLink(tag).ConfigureAwait(false);
|
||||
|
||||
if (url == null)
|
||||
await Context.Channel.SendErrorAsync(Context.User.Mention + " No results.");
|
||||
await ReplyErrorLocalized("not_found").ConfigureAwait(false);
|
||||
else
|
||||
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
.WithDescription(Context.User.Mention + " " + tag)
|
||||
@@ -178,7 +179,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
var url = await GetDanbooruImageLink(tag).ConfigureAwait(false);
|
||||
|
||||
if (url == null)
|
||||
await Context.Channel.SendErrorAsync(Context.User.Mention + " No results.").ConfigureAwait(false);
|
||||
await ReplyErrorLocalized("not_found").ConfigureAwait(false);
|
||||
else
|
||||
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
.WithDescription(Context.User.Mention + " " + tag)
|
||||
@@ -227,9 +228,9 @@ namespace NadekoBot.Modules.NSFW
|
||||
JToken obj;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new NadekoRandom().Next(0, 10330) }").ConfigureAwait(false))[0];
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{new NadekoRandom().Next(0, 10330)}").ConfigureAwait(false))[0];
|
||||
}
|
||||
await Context.Channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
|
||||
await Context.Channel.SendMessageAsync($"http://media.oboobs.ru/{obj["preview"]}").ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -245,9 +246,9 @@ namespace NadekoBot.Modules.NSFW
|
||||
JToken obj;
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new NadekoRandom().Next(0, 4335) }").ConfigureAwait(false))[0];
|
||||
obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{new NadekoRandom().Next(0, 4335)}").ConfigureAwait(false))[0];
|
||||
}
|
||||
await Context.Channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
|
||||
await Context.Channel.SendMessageAsync($"http://media.obutts.ru/{obj["preview"]}").ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user