forked from adam/discord-bot-shtik
clear up compiler warnings
This commit is contained in:
parent
fc73df1d63
commit
5ff601a60c
@ -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"]);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
2
Migrations/20230704160720_initial.Designer.cs
generated
2
Migrations/20230704160720_initial.Designer.cs
generated
@ -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)
|
||||||
|
@ -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)
|
||||||
|
@ -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)
|
||||||
|
@ -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)
|
||||||
|
@ -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)
|
||||||
|
@ -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)
|
||||||
|
2
Migrations/20250204004906_cascade.Designer.cs
generated
2
Migrations/20250204004906_cascade.Designer.cs
generated
@ -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)
|
||||||
|
@ -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)
|
||||||
|
@ -17,12 +17,13 @@ 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();
|
var commandsInContext = await client.GetGlobalApplicationCommandsAsync();
|
||||||
await Register(client, commandsInContext, null);
|
await Register(client, commandsInContext, null);
|
||||||
foreach (var guild in client.Guilds)
|
foreach (var guild in client.Guilds)
|
||||||
@ -37,6 +38,7 @@ namespace vassago.ProtocolInterfaces.DiscordInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static async Task Register(DiscordSocketClient client, IEnumerable<SocketApplicationCommand> commandsInContext, SocketGuild guild)
|
private static async Task Register(DiscordSocketClient client, IEnumerable<SocketApplicationCommand> commandsInContext, SocketGuild guild)
|
||||||
{
|
{
|
||||||
@ -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")
|
||||||
|
@ -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; }
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
@ -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>
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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" />
|
||||||
|
Loading…
Reference in New Issue
Block a user