mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a8e00a19ba | ||
|
8acf6b1194 |
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
## [4.2.12] - 30.06.2022
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.trivia --pokemon` showing incorrect pokemons
|
||||||
|
|
||||||
## [4.2.11] - 29.06.2022
|
## [4.2.11] - 29.06.2022
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@@ -160,7 +160,8 @@ public class CmdAttribute : System.Attribute
|
|||||||
|
|
||||||
var methodModels = methods
|
var methodModels = methods
|
||||||
.Select(x => MethodDeclarationToMethodModel(compilation, x!))
|
.Select(x => MethodDeclarationToMethodModel(compilation, x!))
|
||||||
.Where(static x => x is not null);
|
.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)}");
|
||||||
@@ -180,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);
|
||||||
|
@@ -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"
|
||||||
|
@@ -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.11";
|
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