Added many more braces for multiline if's, Improved .crypto command quite a bit and applied locale-specific format

This commit is contained in:
Kwoth
2022-02-04 06:00:17 +01:00
parent f77f2f433f
commit eda38e64d1
129 changed files with 635 additions and 233 deletions

View File

@@ -48,10 +48,12 @@ public sealed class BotCredsProvider : IBotCredsProvider
MigrateCredentials();
if (!File.Exists(CredsPath))
{
Log.Warning(
"{CredsPath} is missing. Attempting to load creds from environment variables prefixed with 'NadekoBot_'. Example is in {CredsExamplePath}",
CredsPath,
CredsExamplePath);
}
_config = new ConfigurationBuilder().AddYamlFile(CredsPath, false, true)
.AddEnvironmentVariables("NadekoBot_")
@@ -80,17 +82,21 @@ public sealed class BotCredsProvider : IBotCredsProvider
|| string.IsNullOrWhiteSpace(_creds.RestartCommand?.Args))
{
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
_creds.RestartCommand = new()
{
Args = "dotnet",
Cmd = "NadekoBot.dll -- {0}"
};
}
else
{
_creds.RestartCommand = new()
{
Args = "NadekoBot.exe",
Cmd = "{0}"
};
}
}
if (string.IsNullOrWhiteSpace(_creds.RedisOptions))

View File

@@ -33,6 +33,7 @@ public class FontProvider : INService
// try loading some emoji and jap fonts on windows as fallback fonts
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
try
{
var fontsfolder = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
@@ -41,6 +42,7 @@ public class FontProvider : INService
FallBackFonts.AddRange(_fonts.InstallCollection(Path.Combine(fontsfolder, "segoe.ttc")));
}
catch { }
}
// any fonts present in data/fonts should be added as fallback fonts
// this will allow support for special characters when drawing text

View File

@@ -103,12 +103,14 @@ public class Localization : ILocalization, INService
_commandData.TryGetValue(key, out var toReturn);
if (toReturn is null)
{
return new()
{
Cmd = key,
Desc = key,
Usage = new[] { key }
};
}
return toReturn;
}

View File

@@ -230,17 +230,20 @@ public sealed class RedisImagesCache : IImageCache, IReadyExecutor
await Db.ListRightPushAsync(GetRedisKey(key), vals);
if (uris.Length != vals.Length)
{
Log.Information(
"{Loaded}/{Max} URIs for the key '{ImageKey}' have been loaded.\n"
+ "Some of the supplied URIs are either unavailable or invalid",
vals.Length,
uris.Length,
key);
}
}
private async Task<byte[]> GetImageData(Uri uri)
{
if (uri.IsFile)
{
try
{
var bytes = await File.ReadAllBytesAsync(uri.LocalPath);
@@ -251,6 +254,7 @@ public sealed class RedisImagesCache : IImageCache, IReadyExecutor
Log.Warning(ex, "Failed reading image bytes from uri: {Uri}", uri.ToString());
return null;
}
}
try
{

View File

@@ -51,16 +51,20 @@ public class RedisLocalDataCache : ILocalDataCache
if (!File.Exists(POKEMON_LIST_FILE))
Log.Warning($"{POKEMON_LIST_FILE} is missing. Pokemon abilities not loaded");
else
{
Pokemons =
JsonConvert.DeserializeObject<Dictionary<string, SearchPokemon>>(
File.ReadAllText(POKEMON_LIST_FILE));
}
if (!File.Exists(POKEMON_ABILITIES_FILE))
Log.Warning($"{POKEMON_ABILITIES_FILE} is missing. Pokemon abilities not loaded.");
else
{
PokemonAbilities =
JsonConvert.DeserializeObject<Dictionary<string, SearchPokemonAbility>>(
File.ReadAllText(POKEMON_ABILITIES_FILE));
}
try
{