clear up compiler warnings

This commit is contained in:
adam 2025-03-19 13:55:16 -04:00
parent fc73df1d63
commit 5ff601a60c
16 changed files with 35 additions and 31 deletions

View File

@ -12,6 +12,7 @@ namespace vassago
public ConsoleService(IConfiguration aspConfig)
{
Shared.DBConnectionString = aspConfig["DBConnectionString"];
Shared.SetupSlashCommands = aspConfig["SetupSlashCommands"]?.ToLower() == "true";
DiscordTokens = aspConfig.GetSection("DiscordTokens").Get<IEnumerable<string>>();
TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get<IEnumerable<TwitchConfig>>();
Conversion.Converter.Load(aspConfig["ExchangePairsLocation"]);

View File

@ -80,12 +80,12 @@ namespace vassago.Conversion
public static string Convert(decimal numericTerm, string sourceunit, string destinationUnit)
{
var normalizedSourceUnit = normalizeUnit(sourceunit);
var normalizedSourceUnit = NormalizeUnit(sourceunit);
if (string.IsNullOrWhiteSpace(normalizedSourceUnit))
{
return $"parse failure: what's {sourceunit}?";
}
var normalizedDestUnit = normalizeUnit(destinationUnit);
var normalizedDestUnit = NormalizeUnit(destinationUnit);
if (string.IsNullOrWhiteSpace(normalizedDestUnit))
{
return $"parse failure: what's {destinationUnit}?";
@ -127,11 +127,10 @@ namespace vassago.Conversion
return $"{String.Format("{0:N}", accumulator)} {normalizedDestUnit}";
}
}
return "you can never read this.";
}
return "dimensional analysis failure - I know those units but can't find a path between them.";
}
private static string normalizeUnit(string unit)
private static string NormalizeUnit(string unit)
{
if(string.IsNullOrWhiteSpace(unit))
return null;
@ -150,11 +149,11 @@ namespace vassago.Conversion
}
if (normalizedUnit.EndsWith("es"))
{
return normalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 2));
return NormalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 2));
}
else if (normalizedUnit.EndsWith('s'))
{
return normalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 1));
return NormalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 1));
}
return null;
}

View File

@ -13,7 +13,7 @@ namespace vassago.Migrations
{
[DbContext(typeof(ChattingContext))]
[Migration("20230704160720_initial")]
partial class initial
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace vassago.Migrations
{
/// <inheritdoc />
public partial class initial : Migration
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)

View File

@ -13,7 +13,7 @@ namespace vassago.Migrations
{
[DbContext(typeof(ChattingContext))]
[Migration("20231203193139_channeltype")]
partial class channeltype
partial class ChannelType
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -5,7 +5,7 @@
namespace vassago.Migrations
{
/// <inheritdoc />
public partial class channeltype : Migration
public partial class ChannelType : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)

View File

@ -13,7 +13,7 @@ namespace vassago.Migrations
{
[DbContext(typeof(ChattingContext))]
[Migration("20240510202057_channelpermissions_partofchannel")]
partial class channelpermissions_partofchannel
partial class Channelpermissions_partofchannel
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace vassago.Migrations
{
/// <inheritdoc />
public partial class channelpermissions_partofchannel : Migration
public partial class Channelpermissions_partofchannel : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)

View File

@ -13,7 +13,7 @@ namespace vassago.Migrations
{
[DbContext(typeof(ChattingContext))]
[Migration("20250204004906_cascade")]
partial class cascade
partial class Cascade
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -5,7 +5,7 @@
namespace vassago.Migrations
{
/// <inheritdoc />
public partial class cascade : Migration
public partial class Cascade : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)

View File

@ -17,23 +17,25 @@ namespace vassago.ProtocolInterfaces.DiscordInterface
Id = "freedomunits",
UpdatedAt = new DateTime(2023, 5, 21, 13, 3, 0),
guild = 825293851110801428, //TODO: demagic this magic number
register = register_FreedomUnits
register = Register_FreedomUnits
}
};
public static async Task Register(DiscordSocketClient client)
{
return;
var commandsInContext = await client.GetGlobalApplicationCommandsAsync();
await Register(client, commandsInContext, null);
foreach (var guild in client.Guilds)
if(Shared.SetupSlashCommands)
{
try
var commandsInContext = await client.GetGlobalApplicationCommandsAsync();
await Register(client, commandsInContext, null);
foreach (var guild in client.Guilds)
{
await Register(client, await guild.GetApplicationCommandsAsync(), guild);
}
catch (HttpException ex)
{
Console.Error.WriteLine($"error registering slash commands for guild {guild.Name} (id {guild.Id}) - {ex.Message}");
try
{
await Register(client, await guild.GetApplicationCommandsAsync(), guild);
}
catch (HttpException ex)
{
Console.Error.WriteLine($"error registering slash commands for guild {guild.Name} (id {guild.Id}) - {ex.Message}");
}
}
}
}
@ -66,7 +68,7 @@ namespace vassago.ProtocolInterfaces.DiscordInterface
}
}
private static async Task register_FreedomUnits(bool isNew, DiscordSocketClient client, SocketGuild guild)
private static async Task Register_FreedomUnits(bool isNew, DiscordSocketClient client, SocketGuild guild)
{
var builtCommand = new SlashCommandBuilder()
.WithName("freedomunits")

View File

@ -10,4 +10,5 @@ public static class Shared
public static Random r = new Random();
public static string DBConnectionString { get; set; }
public static HttpClient HttpClient { get; internal set; } = new HttpClient();
public static bool SetupSlashCommands { get; set; }
}

View File

@ -10,7 +10,7 @@ namespace vassago.WebInterface.Controllers;
public class ChannelsController() : Controller
{
public async Task<IActionResult> Details(Guid id)
public IActionResult Details(Guid id)
{
var allChannels = Rememberer.ChannelsOverview();
if(allChannels == null)

View File

@ -19,7 +19,7 @@
</tr>
<tr>
<th scope="row">Channel type</th>
<td>@(ThisChannel.ChannelType != null ? Enumerations.GetDescription(ThisChannel.ChannelType) : "?")</td>
<td>@(Enumerations.GetDescription(ThisChannel.ChannelType))</td>
</tr>
<tr>
<th scope="row">Lewdness Filter Level</th>

View File

@ -13,5 +13,6 @@
"TwitchConfigs": [
],
"exchangePairsLocation": "assets/exchangepairs.json",
"DBConnectionString": "Host=azure.club;Database=db;Username=user;Password=password"
"DBConnectionString": "Host=azure.club;Database=db;Username=user;Password=password",
"SetupSlashCommands": false
}

View File

@ -20,7 +20,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageReference Include="QRCoder" Version="1.4.2" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="RestSharp" Version="112.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" />