sharp-chat/SharpChat/Commands/SockChatClientCommandContext.cs

35 lines
1,007 B
C#
Raw Normal View History

using System;
using System.Linq;
namespace SharpChat.Commands {
public class SockChatClientCommandContext {
public string Name { get; }
public string[] Args { get; }
public ChatContext Chat { get; }
public UserInfo User { get; }
public ConnectionInfo Connection { get; }
public ChannelInfo Channel { get; }
public SockChatClientCommandContext(
string text,
ChatContext chat,
UserInfo user,
ConnectionInfo connection,
ChannelInfo channel
) {
Chat = chat;
User = user;
Connection = connection;
Channel = channel;
string[] parts = text[1..].Split(' ');
Name = parts.First().Replace(".", string.Empty);
Args = parts.Skip(1).ToArray();
}
public bool NameEquals(string name) {
return Name.Equals(name, StringComparison.InvariantCultureIgnoreCase);
}
}
}