This commit is contained in:
Master Kwoth
2017-11-14 06:18:54 +01:00
13 changed files with 32 additions and 39 deletions

View File

@ -47,6 +47,7 @@ namespace NadekoBot.Modules.Administration
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[Priority(0)]
public async Task LanguageSet()
{
var cul = _localization.GetCultureInfo(Context.Guild);
@ -57,6 +58,7 @@ namespace NadekoBot.Modules.Administration
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequireUserPermission(GuildPermission.Administrator)]
[Priority(1)]
public async Task LanguageSet(string name)
{
try

View File

@ -26,7 +26,7 @@ namespace NadekoBot.Modules.Searches
if (novelData == null)
{
await ReplyErrorLocalized("error_finding_novel").ConfigureAwait(false);
await ReplyErrorLocalized("failed_finding_novel").ConfigureAwait(false);
return;
}
@ -35,7 +35,7 @@ namespace NadekoBot.Modules.Searches
.WithTitle(novelData.Title)
.WithUrl(novelData.Link)
.WithImageUrl(novelData.ImageUrl)
.AddField(efb => efb.WithName(GetText("authors")).WithValue(String.Join("\n", novelData.Authors)).WithIsInline(true))
.AddField(efb => efb.WithName(GetText("authors")).WithValue(string.Join("\n", novelData.Authors)).WithIsInline(true))
.AddField(efb => efb.WithName(GetText("status")).WithValue(novelData.Status).WithIsInline(true))
.AddField(efb => efb.WithName(GetText("genres")).WithValue(string.Join(" ", novelData.Genres.Any() ? novelData.Genres : new[] { "none" })).WithIsInline(true))
.WithFooter(efb => efb.WithText(GetText("score") + " " + novelData.Score));

View File

@ -67,6 +67,8 @@ namespace NadekoBot.Modules.Searches.Services
var document = await BrowsingContext.New(config).OpenAsync(link);
var imageElem = document.QuerySelector("div.seriesimg > img");
if (imageElem == null)
return null;
var imageUrl = ((IHtmlImageElement)imageElem).Source;
var descElem = document.QuerySelector("div#editdescription > p");

View File

@ -51,12 +51,29 @@ namespace NadekoBot.Modules.Searches.Services
public ConcurrentDictionary<ulong, Timer> AutoButtTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
private readonly ConcurrentDictionary<ulong, HashSet<string>> _blacklistedTags = new ConcurrentDictionary<ulong, HashSet<string>>();
private readonly Timer _t;
private readonly SemaphoreSlim _cryptoLock = new SemaphoreSlim(1, 1);
public async Task<CryptoData[]> CryptoData()
{
var data = await _cache.Redis.GetDatabase()
.StringGetAsync("crypto_data").ConfigureAwait(false);
string data;
var r = _cache.Redis.GetDatabase();
await _cryptoLock.WaitAsync().ConfigureAwait(false);
try
{
data = await r.StringGetAsync("crypto_data").ConfigureAwait(false);
if (data == null)
{
data = await Http.GetStringAsync("https://api.coinmarketcap.com/v1/ticker/")
.ConfigureAwait(false);
await r.StringSetAsync("crypto_data", data, TimeSpan.FromHours(1)).ConfigureAwait(false);
}
}
finally
{
_cryptoLock.Release();
}
return JsonConvert.DeserializeObject<CryptoData[]>(data);
}
@ -114,29 +131,6 @@ namespace NadekoBot.Modules.Searches.Services
return Task.CompletedTask;
};
if (client.ShardId == 0)
{
_t = new Timer(async _ =>
{
var r = _cache.Redis.GetDatabase();
try
{
var data = (string)(await r.StringGetAsync("crypto_data").ConfigureAwait(false));
if (data == null)
{
data = await Http.GetStringAsync("https://api.coinmarketcap.com/v1/ticker/")
.ConfigureAwait(false);
await r.StringSetAsync("crypto_data", data, TimeSpan.FromHours(6)).ConfigureAwait(false);
}
}
catch (Exception ex)
{
_log.Warn(ex);
}
}, null, TimeSpan.Zero, TimeSpan.FromHours(1));
}
//joke commands
if (File.Exists("data/wowjokes.json"))
{

View File

@ -118,7 +118,7 @@ namespace NadekoBot.Modules.Utility
[OwnerOnly]
public async Task Activity(int page = 1)
{
const int activityPerPage = 15;
const int activityPerPage = 10;
page -= 1;
if (page < 0)