Compare commits

...

10 Commits

Author SHA1 Message Date
Kwoth
11d9db99ff Draw fixed, version upped 2022-06-29 17:53:15 +02:00
Kwoth
c66e0fb6b7 Possible fix for constant source generator crashes 2022-06-29 15:28:21 +02:00
Kwoth
1517a35ef7 Upped version to 4.2.10 2022-06-29 11:16:32 +02:00
Kwoth
c5179979d7 Fixed an issue with currency generation working only once 2022-06-29 00:18:15 +02:00
Kwoth
6b14c04e37 Merge branch 'v4' of https://gitlab.com/kwoth/nadekobot into v4 2022-06-28 10:55:59 +02:00
Kwoth
4ec3eb7855 Possible fix for the filterservice duplicate key bug 2022-06-28 10:55:35 +02:00
Kwoth
4752c4b7cd Update CHANGELOG.md 2022-06-26 08:54:40 +00:00
Kwoth
dfec2f589e Nuked nsfw from the public bot, it shouldn't show up anymore. Uncommented patron owner check 2022-06-25 21:03:16 +02:00
Kwoth
f616364d8a Upped version to 4.2.9 2022-06-25 10:42:16 +02:00
Kwoth
4294f8efd5 copy creds_example to output directory 2022-06-25 10:39:34 +02:00
9 changed files with 49 additions and 18 deletions

View File

@@ -1,9 +1,22 @@
# Changelog
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
## Unreleased
## [4.2.11] - 29.06.2022
### Fixed
- Fixed `.draw` command
## [4.2.10] - 29.06.2022
- Fixed currency generation working only once
## [4.2.9] - 25.06.2022
### Fixed
- Fixed `creds_example.yml` misssing from output directory
## [4.2.8] - 24.06.2022

View File

@@ -64,7 +64,9 @@ public class CmdAttribute : System.Attribute
public void Initialize(IncrementalGeneratorInitializationContext context)
{
// #if DEBUG
// SpinWait.SpinUntil(() => Debugger.IsAttached);
// if (!Debugger.IsAttached)
// Debugger.Launch();
// // SpinWait.SpinUntil(() => Debugger.IsAttached);
// #endif
context.RegisterPostInitializationOutput(static ctx => ctx.AddSource(
"CmdAttribute.g.cs",
@@ -157,7 +159,8 @@ public class CmdAttribute : System.Attribute
.Distinct();
var methodModels = methods
.Select(x => MethodDeclarationToMethodModel(compilation, x!));
.Select(x => MethodDeclarationToMethodModel(compilation, x!))
.Where(static x => x is not null);
var groups = methodModels
.GroupBy(static x => $"{x.Namespace}.{string.Join(".", x.Classes)}");
@@ -187,11 +190,21 @@ public class CmdAttribute : System.Attribute
return models;
}
private static MethodModel MethodDeclarationToMethodModel(Compilation comp, MethodDeclarationSyntax decl)
private static MethodModel? MethodDeclarationToMethodModel(Compilation comp, MethodDeclarationSyntax decl)
{
// SpinWait.SpinUntil(static () => Debugger.IsAttached);
var semanticModel = comp.GetSemanticModel(decl.SyntaxTree);
SemanticModel semanticModel;
try
{
semanticModel = comp.GetSemanticModel(decl.SyntaxTree);
}
catch
{
// for some reason this method can throw "Not part of this compilation" argument exception
return null;
}
var methodModel = new MethodModel(
@params: decl.ParameterList.Parameters
.Where(p => p.Type is not null)

View File

@@ -44,7 +44,7 @@ public partial class Gambling
var currentCard = cards.Draw();
cardObjects.Add(currentCard);
var cardName = currentCard.ToString().ToLowerInvariant().Replace(' ', '_');
images.Add(Image.Load(await File.ReadAllBytesAsync($"data/images/cards/{cardName}.png")));
images.Add(Image.Load(await File.ReadAllBytesAsync($"data/images/cards/{cardName}.jpg")));
}
using var img = images.Merge();

View File

@@ -16,7 +16,7 @@ namespace NadekoBot.Modules.Gambling.Services;
public class PlantPickService : INService, IExecNoCommand
{
//channelId/last generation
public ConcurrentDictionary<ulong, DateTime> LastGenerations { get; } = new();
public ConcurrentDictionary<ulong, long> LastGenerations { get; } = new();
private readonly DbService _db;
private readonly IBotStrings _strings;
private readonly IImageCache _images;
@@ -175,15 +175,15 @@ public class PlantPickService : INService, IExecNoCommand
try
{
var config = _gss.Data;
var lastGeneration = LastGenerations.GetOrAdd(channel.Id, DateTime.MinValue);
var lastGeneration = LastGenerations.GetOrAdd(channel.Id, DateTime.MinValue.ToBinary());
var rng = new NadekoRandom();
if (DateTime.UtcNow - TimeSpan.FromSeconds(config.Generation.GenCooldown)
< lastGeneration) //recently generated in this channel, don't generate again
< DateTime.FromBinary(lastGeneration)) //recently generated in this channel, don't generate again
return;
var num = rng.Next(1, 101) + (config.Generation.Chance * 100);
if (num > 100 && LastGenerations.TryUpdate(channel.Id, DateTime.UtcNow, lastGeneration))
if (num > 100 && LastGenerations.TryUpdate(channel.Id, DateTime.UtcNow.ToBinary(), lastGeneration))
{
var dropAmount = config.Generation.MinAmount;
var dropAmountMax = config.Generation.MaxAmount;

View File

@@ -4,6 +4,7 @@ using Newtonsoft.Json.Linq;
namespace NadekoBot.Modules.Nsfw;
#if !GLOBAL_NADEKO
[NoPublicBot]
public partial class NSFW : NadekoModule<ISearchImagesService>
{
@@ -436,4 +437,5 @@ public partial class NSFW : NadekoModule<ISearchImagesService>
.WithFooter(
$"{data.Rating} ({data.Provider}) | {string.Join(" | ", data.Tags.Where(x => !string.IsNullOrWhiteSpace(x)).Take(5))}"));
}
}
}
#endif

View File

@@ -50,7 +50,7 @@ public sealed class FilterService : IExecOnMessage
new(configs.SelectMany(gc => gc.FilterLinksChannelIds.Select(fci => fci.ChannelId)));
var dict = configs.ToDictionary(gc => gc.GuildId,
gc => new ConcurrentHashSet<string>(gc.FilteredWords.Select(fw => fw.Word)));
gc => new ConcurrentHashSet<string>(gc.FilteredWords.Select(fw => fw.Word).Distinct()));
ServerFilteredWords = new(dict);

View File

@@ -35,6 +35,7 @@ public sealed class PatronageService
= new($"quota:last_hourly_reset");
private readonly IBotCache _cache;
private readonly IBotCredsProvider _creds;
public PatronageService(
PatronageConfig pConf,
@@ -42,7 +43,8 @@ public sealed class PatronageService
DiscordSocketClient client,
ISubscriptionHandler subsHandler,
IEmbedBuilderService eb,
IBotCache cache)
IBotCache cache,
IBotCredsProvider creds)
{
_pConf = pConf;
_db = db;
@@ -50,6 +52,7 @@ public sealed class PatronageService
_subsHandler = subsHandler;
_eb = eb;
_cache = cache;
_creds = creds;
}
public Task OnReadyAsync()
@@ -495,8 +498,8 @@ public sealed class PatronageService
if (!confData.IsEnabled)
return default;
// if (_creds.IsOwner(userId))
// return default;
if (_creds.GetCreds().IsOwner(userId))
return default;
// get user tier
var patron = await GetPatronAsync(userId);

View File

@@ -118,7 +118,7 @@
<None Update="nadeko_icon.ico;libopus.so;libsodium.so;libsodium.dll;opus.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="creds.yml">
<None Update="creds.yml;creds_example.yml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
public sealed class StatsService : IStatsService, IReadyExecutor, INService
{
public const string BOT_VERSION = "4.2.8";
public const string BOT_VERSION = "4.2.11";
public string Author
=> "Kwoth#2452";