sharp-chat/SharpChat/UserCommandContext.cs

34 lines
978 B
C#

using System;
using System.Linq;
namespace SharpChat {
public class UserCommandContext {
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 UserCommandContext(
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);
}
}
}