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) public ConsoleService(IConfiguration aspConfig)
{ {
Shared.DBConnectionString = aspConfig["DBConnectionString"]; Shared.DBConnectionString = aspConfig["DBConnectionString"];
Shared.SetupSlashCommands = aspConfig["SetupSlashCommands"]?.ToLower() == "true";
DiscordTokens = aspConfig.GetSection("DiscordTokens").Get<IEnumerable<string>>(); DiscordTokens = aspConfig.GetSection("DiscordTokens").Get<IEnumerable<string>>();
TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get<IEnumerable<TwitchConfig>>(); TwitchConfigs = aspConfig.GetSection("TwitchConfigs").Get<IEnumerable<TwitchConfig>>();
Conversion.Converter.Load(aspConfig["ExchangePairsLocation"]); Conversion.Converter.Load(aspConfig["ExchangePairsLocation"]);

View File

@ -80,12 +80,12 @@ namespace vassago.Conversion
public static string Convert(decimal numericTerm, string sourceunit, string destinationUnit) public static string Convert(decimal numericTerm, string sourceunit, string destinationUnit)
{ {
var normalizedSourceUnit = normalizeUnit(sourceunit); var normalizedSourceUnit = NormalizeUnit(sourceunit);
if (string.IsNullOrWhiteSpace(normalizedSourceUnit)) if (string.IsNullOrWhiteSpace(normalizedSourceUnit))
{ {
return $"parse failure: what's {sourceunit}?"; return $"parse failure: what's {sourceunit}?";
} }
var normalizedDestUnit = normalizeUnit(destinationUnit); var normalizedDestUnit = NormalizeUnit(destinationUnit);
if (string.IsNullOrWhiteSpace(normalizedDestUnit)) if (string.IsNullOrWhiteSpace(normalizedDestUnit))
{ {
return $"parse failure: what's {destinationUnit}?"; return $"parse failure: what's {destinationUnit}?";
@ -127,11 +127,10 @@ namespace vassago.Conversion
return $"{String.Format("{0:N}", accumulator)} {normalizedDestUnit}"; 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."; 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)) if(string.IsNullOrWhiteSpace(unit))
return null; return null;
@ -150,11 +149,11 @@ namespace vassago.Conversion
} }
if (normalizedUnit.EndsWith("es")) 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')) else if (normalizedUnit.EndsWith('s'))
{ {
return normalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 1)); return NormalizeUnit(normalizedUnit.Substring(0, normalizedUnit.Length - 1));
} }
return null; return null;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,4 +10,5 @@ public static class Shared
public static Random r = new Random(); public static Random r = new Random();
public static string DBConnectionString { get; set; } public static string DBConnectionString { get; set; }
public static HttpClient HttpClient { get; internal set; } = new HttpClient(); 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 class ChannelsController() : Controller
{ {
public async Task<IActionResult> Details(Guid id) public IActionResult Details(Guid id)
{ {
var allChannels = Rememberer.ChannelsOverview(); var allChannels = Rememberer.ChannelsOverview();
if(allChannels == null) if(allChannels == null)

View File

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

View File

@ -13,5 +13,6 @@
"TwitchConfigs": [ "TwitchConfigs": [
], ],
"exchangePairsLocation": "assets/exchangepairs.json", "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="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
<PackageReference Include="QRCoder" Version="1.4.2" /> <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.Swagger" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" />