mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a8e00a19ba | ||
|
8acf6b1194 | ||
|
11d9db99ff | ||
|
c66e0fb6b7 | ||
|
1517a35ef7 | ||
|
c5179979d7 | ||
|
6b14c04e37 | ||
|
4ec3eb7855 | ||
|
4752c4b7cd | ||
|
dfec2f589e | ||
|
f616364d8a | ||
|
4294f8efd5 | ||
|
69eb5f2c56 |
29
CHANGELOG.md
29
CHANGELOG.md
@@ -1,9 +1,34 @@
|
|||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||||
|
|
||||||
## Unreleased
|
## [4.2.12] - 30.06.2022
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.trivia --pokemon` showing incorrect pokemons
|
||||||
|
|
||||||
|
## [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
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `.timely` should be fixed
|
||||||
|
|
||||||
## [4.2.7] - 24.06.2022
|
## [4.2.7] - 24.06.2022
|
||||||
|
|
||||||
|
@@ -64,7 +64,9 @@ public class CmdAttribute : System.Attribute
|
|||||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||||
{
|
{
|
||||||
// #if DEBUG
|
// #if DEBUG
|
||||||
// SpinWait.SpinUntil(() => Debugger.IsAttached);
|
// if (!Debugger.IsAttached)
|
||||||
|
// Debugger.Launch();
|
||||||
|
// // SpinWait.SpinUntil(() => Debugger.IsAttached);
|
||||||
// #endif
|
// #endif
|
||||||
context.RegisterPostInitializationOutput(static ctx => ctx.AddSource(
|
context.RegisterPostInitializationOutput(static ctx => ctx.AddSource(
|
||||||
"CmdAttribute.g.cs",
|
"CmdAttribute.g.cs",
|
||||||
@@ -157,7 +159,9 @@ public class CmdAttribute : System.Attribute
|
|||||||
.Distinct();
|
.Distinct();
|
||||||
|
|
||||||
var methodModels = methods
|
var methodModels = methods
|
||||||
.Select(x => MethodDeclarationToMethodModel(compilation, x!));
|
.Select(x => MethodDeclarationToMethodModel(compilation, x!))
|
||||||
|
.Where(static x => x is not null)
|
||||||
|
.Cast<MethodModel>();
|
||||||
|
|
||||||
var groups = methodModels
|
var groups = methodModels
|
||||||
.GroupBy(static x => $"{x.Namespace}.{string.Join(".", x.Classes)}");
|
.GroupBy(static x => $"{x.Namespace}.{string.Join(".", x.Classes)}");
|
||||||
@@ -177,7 +181,7 @@ public class CmdAttribute : System.Attribute
|
|||||||
var model = new FileModel(
|
var model = new FileModel(
|
||||||
methods: elems,
|
methods: elems,
|
||||||
ns: elems[0].Namespace,
|
ns: elems[0].Namespace,
|
||||||
classHierarchy: elems[0].Classes
|
classHierarchy: elems![0].Classes
|
||||||
);
|
);
|
||||||
|
|
||||||
models.Add(model);
|
models.Add(model);
|
||||||
@@ -187,11 +191,21 @@ public class CmdAttribute : System.Attribute
|
|||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MethodModel MethodDeclarationToMethodModel(Compilation comp, MethodDeclarationSyntax decl)
|
private static MethodModel? MethodDeclarationToMethodModel(Compilation comp, MethodDeclarationSyntax decl)
|
||||||
{
|
{
|
||||||
// SpinWait.SpinUntil(static () => Debugger.IsAttached);
|
// 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(
|
var methodModel = new MethodModel(
|
||||||
@params: decl.ParameterList.Parameters
|
@params: decl.ParameterList.Parameters
|
||||||
.Where(p => p.Type is not null)
|
.Where(p => p.Type is not null)
|
||||||
|
@@ -44,7 +44,7 @@ public partial class Gambling
|
|||||||
var currentCard = cards.Draw();
|
var currentCard = cards.Draw();
|
||||||
cardObjects.Add(currentCard);
|
cardObjects.Add(currentCard);
|
||||||
var cardName = currentCard.ToString().ToLowerInvariant().Replace(' ', '_');
|
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();
|
using var img = images.Merge();
|
||||||
|
@@ -244,7 +244,7 @@ public class GamblingService : INService, IReadyExecutor
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
await _timelyLock.WaitAsync();
|
_timelyLock.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ namespace NadekoBot.Modules.Gambling.Services;
|
|||||||
public class PlantPickService : INService, IExecNoCommand
|
public class PlantPickService : INService, IExecNoCommand
|
||||||
{
|
{
|
||||||
//channelId/last generation
|
//channelId/last generation
|
||||||
public ConcurrentDictionary<ulong, DateTime> LastGenerations { get; } = new();
|
public ConcurrentDictionary<ulong, long> LastGenerations { get; } = new();
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly IBotStrings _strings;
|
private readonly IBotStrings _strings;
|
||||||
private readonly IImageCache _images;
|
private readonly IImageCache _images;
|
||||||
@@ -175,15 +175,15 @@ public class PlantPickService : INService, IExecNoCommand
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var config = _gss.Data;
|
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();
|
var rng = new NadekoRandom();
|
||||||
|
|
||||||
if (DateTime.UtcNow - TimeSpan.FromSeconds(config.Generation.GenCooldown)
|
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;
|
return;
|
||||||
|
|
||||||
var num = rng.Next(1, 101) + (config.Generation.Chance * 100);
|
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 dropAmount = config.Generation.MinAmount;
|
||||||
var dropAmountMax = config.Generation.MaxAmount;
|
var dropAmountMax = config.Generation.MaxAmount;
|
||||||
|
@@ -19,14 +19,14 @@ public class TriviaQuestionPool
|
|||||||
{
|
{
|
||||||
var pokes = await _cache.GetPokemonMapAsync();
|
var pokes = await _cache.GetPokemonMapAsync();
|
||||||
|
|
||||||
if (pokes is null or { Length: 0 })
|
if (pokes is null or { Count: 0 })
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
var num = _rng.Next(1, _maxPokemonId + 1);
|
var num = _rng.Next(1, _maxPokemonId + 1);
|
||||||
return new(new()
|
return new(new()
|
||||||
{
|
{
|
||||||
Question = "Who's That Pokémon?",
|
Question = "Who's That Pokémon?",
|
||||||
Answer = pokes[num].Name.ToTitleCase(),
|
Answer = pokes[num].ToTitleCase(),
|
||||||
Category = "Pokemon",
|
Category = "Pokemon",
|
||||||
ImageUrl = $@"https://nadeko.bot/images/pokemon/shadows/{num}.png",
|
ImageUrl = $@"https://nadeko.bot/images/pokemon/shadows/{num}.png",
|
||||||
AnswerImageUrl = $@"https://nadeko.bot/images/pokemon/real/{num}.png"
|
AnswerImageUrl = $@"https://nadeko.bot/images/pokemon/real/{num}.png"
|
||||||
|
@@ -4,6 +4,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace NadekoBot.Modules.Nsfw;
|
namespace NadekoBot.Modules.Nsfw;
|
||||||
|
|
||||||
|
#if !GLOBAL_NADEKO
|
||||||
[NoPublicBot]
|
[NoPublicBot]
|
||||||
public partial class NSFW : NadekoModule<ISearchImagesService>
|
public partial class NSFW : NadekoModule<ISearchImagesService>
|
||||||
{
|
{
|
||||||
@@ -437,3 +438,4 @@ public partial class NSFW : NadekoModule<ISearchImagesService>
|
|||||||
$"{data.Rating} ({data.Provider}) | {string.Join(" | ", data.Tags.Where(x => !string.IsNullOrWhiteSpace(x)).Take(5))}"));
|
$"{data.Rating} ({data.Provider}) | {string.Join(" | ", data.Tags.Where(x => !string.IsNullOrWhiteSpace(x)).Take(5))}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
@@ -50,7 +50,7 @@ public sealed class FilterService : IExecOnMessage
|
|||||||
new(configs.SelectMany(gc => gc.FilterLinksChannelIds.Select(fci => fci.ChannelId)));
|
new(configs.SelectMany(gc => gc.FilterLinksChannelIds.Select(fci => fci.ChannelId)));
|
||||||
|
|
||||||
var dict = configs.ToDictionary(gc => gc.GuildId,
|
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);
|
ServerFilteredWords = new(dict);
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ public sealed class PatronageService
|
|||||||
= new($"quota:last_hourly_reset");
|
= new($"quota:last_hourly_reset");
|
||||||
|
|
||||||
private readonly IBotCache _cache;
|
private readonly IBotCache _cache;
|
||||||
|
private readonly IBotCredsProvider _creds;
|
||||||
|
|
||||||
public PatronageService(
|
public PatronageService(
|
||||||
PatronageConfig pConf,
|
PatronageConfig pConf,
|
||||||
@@ -42,7 +43,8 @@ public sealed class PatronageService
|
|||||||
DiscordSocketClient client,
|
DiscordSocketClient client,
|
||||||
ISubscriptionHandler subsHandler,
|
ISubscriptionHandler subsHandler,
|
||||||
IEmbedBuilderService eb,
|
IEmbedBuilderService eb,
|
||||||
IBotCache cache)
|
IBotCache cache,
|
||||||
|
IBotCredsProvider creds)
|
||||||
{
|
{
|
||||||
_pConf = pConf;
|
_pConf = pConf;
|
||||||
_db = db;
|
_db = db;
|
||||||
@@ -50,6 +52,7 @@ public sealed class PatronageService
|
|||||||
_subsHandler = subsHandler;
|
_subsHandler = subsHandler;
|
||||||
_eb = eb;
|
_eb = eb;
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
|
_creds = creds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task OnReadyAsync()
|
public Task OnReadyAsync()
|
||||||
@@ -495,8 +498,8 @@ public sealed class PatronageService
|
|||||||
if (!confData.IsEnabled)
|
if (!confData.IsEnabled)
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
// if (_creds.IsOwner(userId))
|
if (_creds.GetCreds().IsOwner(userId))
|
||||||
// return default;
|
return default;
|
||||||
|
|
||||||
// get user tier
|
// get user tier
|
||||||
var patron = await GetPatronAsync(userId);
|
var patron = await GetPatronAsync(userId);
|
||||||
|
@@ -118,7 +118,7 @@
|
|||||||
<None Update="nadeko_icon.ico;libopus.so;libsodium.so;libsodium.dll;opus.dll">
|
<None Update="nadeko_icon.ico;libopus.so;libsodium.so;libsodium.dll;opus.dll">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="creds.yml">
|
<None Update="creds.yml;creds_example.yml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -9,5 +9,5 @@ public interface ILocalDataCache
|
|||||||
Task<IReadOnlyDictionary<string, SearchPokemon>> GetPokemonsAsync();
|
Task<IReadOnlyDictionary<string, SearchPokemon>> GetPokemonsAsync();
|
||||||
Task<IReadOnlyDictionary<string, SearchPokemonAbility>> GetPokemonAbilitiesAsync();
|
Task<IReadOnlyDictionary<string, SearchPokemonAbility>> GetPokemonAbilitiesAsync();
|
||||||
Task<TriviaQuestionModel[]> GetTriviaQuestionsAsync();
|
Task<TriviaQuestionModel[]> GetTriviaQuestionsAsync();
|
||||||
Task<PokemonNameId[]> GetPokemonMapAsync();
|
Task<IReadOnlyDictionary<int, string>> GetPokemonMapAsync();
|
||||||
}
|
}
|
@@ -67,11 +67,37 @@ public sealed class LocalDataCache : ILocalDataCache, INService
|
|||||||
=> await GetOrCreateCachedDataAsync(_pokemonAbilitiesKey, POKEMON_ABILITIES_FILE);
|
=> await GetOrCreateCachedDataAsync(_pokemonAbilitiesKey, POKEMON_ABILITIES_FILE);
|
||||||
|
|
||||||
|
|
||||||
private static TypedKey<PokemonNameId[]> _pokeMapKey
|
private static TypedKey<IReadOnlyDictionary<int, string>> _pokeMapKey
|
||||||
= new("pokemon:ab_map");
|
= new("pokemon:ab_map2"); // 2 because ab_map was storing arrays
|
||||||
|
|
||||||
public async Task<PokemonNameId[]?> GetPokemonMapAsync()
|
public async Task<IReadOnlyDictionary<int, string>?> GetPokemonMapAsync()
|
||||||
=> await GetOrCreateCachedDataAsync(_pokeMapKey, POKEMON_MAP_PATH);
|
=> await _cache.GetOrAddAsync(_pokeMapKey,
|
||||||
|
async () =>
|
||||||
|
{
|
||||||
|
var fileName = POKEMON_MAP_PATH;
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
{
|
||||||
|
Log.Warning($"{fileName} is missing. Relevant data can't be loaded");
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var stream = File.OpenRead(fileName);
|
||||||
|
var arr = await JsonSerializer.DeserializeAsync<PokemonNameId[]>(stream, _opts);
|
||||||
|
|
||||||
|
return (IReadOnlyDictionary<int, string>?)arr?.ToDictionary(x => x.Id, x => x.Name);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex,
|
||||||
|
"Error reading {FileName} file: {ErrorMessage}",
|
||||||
|
fileName,
|
||||||
|
ex.Message);
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
private static TypedKey<TriviaQuestionModel[]> _triviaKey
|
private static TypedKey<TriviaQuestionModel[]> _triviaKey
|
||||||
|
@@ -7,7 +7,7 @@ namespace NadekoBot.Services;
|
|||||||
|
|
||||||
public sealed class StatsService : IStatsService, IReadyExecutor, INService
|
public sealed class StatsService : IStatsService, IReadyExecutor, INService
|
||||||
{
|
{
|
||||||
public const string BOT_VERSION = "4.2.7";
|
public const string BOT_VERSION = "4.2.12";
|
||||||
|
|
||||||
public string Author
|
public string Author
|
||||||
=> "Kwoth#2452";
|
=> "Kwoth#2452";
|
||||||
|
Reference in New Issue
Block a user