Skip to content

Commit

Permalink
Merge pull request #53 from hburn7/hotfix/duplicate-message-received-…
Browse files Browse the repository at this point in the history
…events

Remove duplicate OnPrivateMessageReceived invocation
  • Loading branch information
hburn7 authored Sep 20, 2024
2 parents 74a1705 + 4a8676b commit 7331d2f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions BanchoSharp/BanchoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ private void RegisterEvents()
if (m is IPrivateIrcMessage priv)
{
_banchoBotEventInvoker.ProcessMessage(priv);
OnPrivateMessageReceived?.Invoke(priv);

var channel = GetChannel(priv.IsDirect ? priv.Sender : priv.Recipient);
if (priv.IsDirect)
Expand Down Expand Up @@ -420,14 +419,13 @@ private async Task ListenerAsync()

OnMessageReceived?.Invoke(message);

if (message is IPrivateIrcMessage dm)
{
OnPrivateMessageReceived?.Invoke(dm);
if (message is not IPrivateIrcMessage dm) continue;

OnPrivateMessageReceived?.Invoke(dm);

if (dm.Recipient == ClientConfig.Credentials.Username)
{
OnAuthenticatedUserDMReceived?.Invoke(dm);
}
if (dm.Recipient == ClientConfig.Credentials.Username)
{
OnAuthenticatedUserDMReceived?.Invoke(dm);
}
}
}
Expand Down

0 comments on commit 7331d2f

Please sign in to comment.