Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
name: "Deploy binaries"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.x
dotnet-version: 9.x
- name: Install dependencies
run: dotnet restore "${{ github.workspace }}/BanchoSharp/BanchoSharp.csproj"
- name: Build
Expand All @@ -47,7 +47,7 @@ jobs:

- name: Publish to NuGet on version change
id: publish_nuget
uses: brandedoutcast/publish-nuget@v2.5.2
uses: brandedoutcast/publish-nuget@v2.5.5
with:
NUGET_KEY: "${{ secrets.NUGET_API_KEY }}"
PROJECT_FILE_PATH: "BanchoSharp/BanchoSharp.csproj"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jobs:
test-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 9.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions BanchoSharp/BanchoSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -12,7 +12,7 @@
<PackageProjectUrl>https://github.com/hburn7/BanchoSharp</PackageProjectUrl>
<RepositoryUrl>https://github.com/hburn7/BanchoSharp</RepositoryUrl>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageVersion>1.4.4</PackageVersion>
<PackageVersion>1.5.0</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion BanchoSharp/Messaging/SlashCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private bool IsSlashCommand() => !string.IsNullOrWhiteSpace(_prompt) &&
_prompt.StartsWith("/") &&
_prompt.Length > 1;

private string[]? GetParamsForCommand() => Command.ToLower() switch
private string[]? GetParamsForCommand() => Command?.ToLower() switch
{
"join" => GetFirstArgOrDefault(),
"part" => GetFirstArgOrDefault(),
Expand Down
4 changes: 3 additions & 1 deletion BanchoSharp/Multiplayer/MultiplayerLobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ public MultiplayerLobby(IBanchoClient client, long id, string name) : base($"#mp
public event Action<int>? OnLobbyTimerStarted;
public event Action? OnLobbyTimerFinished;
public event Action<int>? OnMatchStartTimerStarted;
#pragma warning disable CS0067
public event Action? OnMatchStartTimerFinished;
#pragma warning restore CS0067
public event Action? OnMatchAborted;
public event Action? OnMatchStarted;
public event Action? OnMatchFinished;
Expand Down Expand Up @@ -942,7 +944,7 @@ private void UpdatePlayerJoinedInSlot(string banchoResponse)
private void UpdateBeatmapFromMpSettings(string banchoResponse)
{
int id = -1;
string difficulty, artist, title;
string? difficulty, artist, title;
difficulty = artist = title = null;

string[] splits = banchoResponse.Split(" - ");
Expand Down
2 changes: 1 addition & 1 deletion BanchoSharpExample/BanchoSharpExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
Expand Down
14 changes: 11 additions & 3 deletions BanchoSharpExample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
using BanchoSharp;

var client = new BanchoClient(new BanchoClientConfig(new IrcCredentials(Environment.GetEnvironmentVariable("IRC_USERNAME"),
Environment.GetEnvironmentVariable("IRC_PASS")), LogLevel.Trace));
var username = Environment.GetEnvironmentVariable("IRC_USERNAME");
var password = Environment.GetEnvironmentVariable("IRC_PASS");

client.OnAuthenticated += async () =>
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
{
Console.WriteLine("Please set IRC_USERNAME and IRC_PASS environment variables.");
return;
}

var client = new BanchoClient(new BanchoClientConfig(new IrcCredentials(username, password), LogLevel.Trace));

client.OnAuthenticated += () =>
{
client.BanchoBotEvents.OnTournamentLobbyCreated += lobby => Console.WriteLine($"Tournament lobby created: {lobby.Id}");
};
Expand Down
12 changes: 6 additions & 6 deletions BanchoSharpTests/BanchoSharpTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -11,11 +11,11 @@

<ItemGroup>
<PackageReference Include="Humanizer" Version="2.14.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.9.2" />
<PackageReference Include="coverlet.collector" Version="6.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions BanchoSharpTests/ClientConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ public void Setup()
_client = new BanchoClient();
}

[TearDown]
public void TearDown()
{
_client?.Dispose();
}

[Test]
public async Task TestSaveMessagesConfig()
{
Expand Down
3 changes: 3 additions & 0 deletions BanchoSharpTests/ClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class ClientTests
[SetUp]
public void Setup() => _client = new BanchoClient();

[TearDown]
public void TearDown() => _client?.Dispose();

[Test]
public async Task TestJoinChannelAsync()
{
Expand Down
4 changes: 2 additions & 2 deletions BanchoSharpTests/ExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ namespace BanchoSharpTests;
public class ExceptionTests
{
[SetUp]
public async Task Setup() {}
public void Setup() {}

[Test]
public async Task TestNotConnectedException()
public void TestNotConnectedException()
{
BanchoClient client = new();
Assert.Multiple(() =>
Expand Down
16 changes: 11 additions & 5 deletions BanchoSharpTests/MultiplayerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public void Setup()
_lobby = DefaultLobby(_client);
}

[TearDown]
public void TearDown()
{
_client?.Dispose();
}

[TestCase("OWC 2021: (United States) vs. (Germany)", "https://osu.ppy.sh/mp/106275696", 106275696,
Mods.HalfTime | Mods.Freemod, 1096903, "Unmei no Dark Side -Rolling Gothic mix", "Kanpyohgo", "Satellite's Lunatic",
LobbyFormat.TagCoop, WinCondition.Score, TeamColor.None, true, PlayerState.NotReady,
Expand Down Expand Up @@ -79,13 +85,13 @@ public void TestMpSettingsUpdates(string lobbyName, string historyUrl, int match
Assert.That(_lobby.HistoryUrl, Is.EqualTo(historyUrl));
Assert.That(_lobby.Id, Is.EqualTo(matchId));
Assert.That(_lobby.Mods, Is.EqualTo(lobbyMods));
Assert.That(_lobby.CurrentBeatmap.Id, Is.EqualTo(beatmapId));
Assert.That(_lobby.CurrentBeatmap.Title, Is.EqualTo(beatmapTitle));
Assert.That(_lobby.CurrentBeatmap.Artist, Is.EqualTo(beatmapArtist));
Assert.That(_lobby.CurrentBeatmap.Difficulty, Is.EqualTo(beatmapDifficulty));
Assert.That(_lobby.CurrentBeatmap?.Id, Is.EqualTo(beatmapId));
Assert.That(_lobby.CurrentBeatmap?.Title, Is.EqualTo(beatmapTitle));
Assert.That(_lobby.CurrentBeatmap?.Artist, Is.EqualTo(beatmapArtist));
Assert.That(_lobby.CurrentBeatmap?.Difficulty, Is.EqualTo(beatmapDifficulty));
Assert.That(_lobby.Format, Is.EqualTo(format));
Assert.That(_lobby.WinCondition, Is.EqualTo(winCondition));
Assert.That(_lobby.Host.Equals(_lobby.Players[0]), Is.EqualTo(p1IsHost));
Assert.That(_lobby.Host?.Equals(_lobby.Players[0]), Is.EqualTo(p1IsHost));
Assert.That(_lobby.Players[0].Team, Is.EqualTo(p1TeamColor));
Assert.That(_lobby.Players[0].State, Is.EqualTo(p1State));
Assert.That(_lobby.Players[0].Id, Is.EqualTo(p1Id));
Expand Down