Skip to content

Commit

Permalink
Add messages during bancho restart
Browse files Browse the repository at this point in the history
  • Loading branch information
matte-ek committed Apr 25, 2023
1 parent 2d81678 commit 865546c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion BanchoMultiplayerBot/Behaviour/LobbyManagerBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BanchoMultiplayerBot.Extensions;
using BanchoSharp;
using BanchoSharp.Interfaces;
using BanchoSharp.Multiplayer;
using Serilog;

Expand Down Expand Up @@ -27,6 +28,7 @@ public void Setup(Lobby lobby)
_lobby.MultiplayerLobby.OnMatchAborted += OnMatchFinishedOrAborted;
_lobby.MultiplayerLobby.OnSettingsUpdated += OnRoomSettingsUpdated;

_lobby.OnBanchoMessage += OnBanchoMessage;
_lobby.OnAdminMessage += OnAdminMessage;

_lobby.OnLobbyChannelJoined += RunSettingsCommand;
Expand All @@ -51,7 +53,25 @@ public void Setup(Lobby lobby)
};
}

private void OnAdminMessage(BanchoSharp.Interfaces.IPrivateIrcMessage message)
private void OnBanchoMessage(IPrivateIrcMessage message)
{
// Bot receives the message from both #lobby and #osu, so only check #osu
// to avoid duplicate messages.
if (message.Recipient != "#osu")
{
return;
}

if (!message.Content.StartsWith("Bancho will be restarting for maintenance in 1 minute."))
{
return;
}

_lobby.SendMessage("Bancho is about to restart, the lobby should be automatically re-created in few minutes after Bancho is restarted.");
_lobby.SendMessage("Try searching for the lobby if you cannot find it in the list, thanks for playing!");
}

private void OnAdminMessage(IPrivateIrcMessage message)
{
if (message.Content.StartsWith("!addref"))
{
Expand Down

0 comments on commit 865546c

Please sign in to comment.