sharp-chat/SharpChat/ChatPacketHandlerContext.cs
2025-04-25 15:49:46 +00:00

21 lines
735 B
C#

using System;
namespace SharpChat {
public class ChatPacketHandlerContext(
string text,
ChatContext chat,
ChatConnection connection
) {
public string Text { get; } = text ?? throw new ArgumentNullException(nameof(text));
public ChatContext Chat { get; } = chat ?? throw new ArgumentNullException(nameof(chat));
public ChatConnection Connection { get; } = connection ?? throw new ArgumentNullException(nameof(connection));
public bool CheckPacketId(string packetId) {
return Text == packetId || Text.StartsWith(packetId + '\t');
}
public string[] SplitText(int expect) {
return Text.Split('\t', expect + 1);
}
}
}