Skip to content

Commit a949543

Browse files
committed
Fix: Core: ChatReader: Dont attempt to search for the Author name when 'Space' character was not found in the payload.
1 parent f62006a commit a949543

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Core/Chat/ChatReader.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,19 @@ public void Update(IAddonDataProvider reader)
6565

6666
string text = sb.ToString().ToLowerInvariant();
6767
sb.Clear();
68-
try
69-
{
70-
int firstSpaceIdx = text.AsSpan().IndexOf(' ');
71-
string author = text.AsSpan(0, firstSpaceIdx).ToString();
72-
string msg = text.AsSpan(firstSpaceIdx + 1).ToString();
73-
74-
ChatMessageEntry entry = new(DateTime.Now, type, author, msg);
75-
Messages.Add(entry);
76-
logger.LogInformation(entry.ToString());
77-
} catch (Exception e)
68+
69+
int firstSpaceIdx = text.AsSpan().IndexOf(' ');
70+
if (firstSpaceIdx == -1)
7871
{
79-
logger.LogError("ChatEntryError: " + e.ToString());
72+
logger.LogError($"Malformed payload: {text}");
73+
return;
8074
}
75+
76+
string author = text.AsSpan(0, firstSpaceIdx).ToString();
77+
string msg = text.AsSpan(firstSpaceIdx + 1).ToString();
78+
79+
ChatMessageEntry entry = new(DateTime.Now, type, author, msg);
80+
Messages.Add(entry);
81+
logger.LogInformation(entry.ToString());
8182
}
8283
}

0 commit comments

Comments
 (0)