Name adjustments and moved some things to the common lib.
This commit is contained in:
parent
b8ec381f3b
commit
0cc5d46ea9
50 changed files with 323 additions and 323 deletions
SharpChat
49
SharpChat/ClientCommandContext.cs
Normal file
49
SharpChat/ClientCommandContext.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
namespace SharpChat {
|
||||
public class ClientCommandContext {
|
||||
public string Name { get; }
|
||||
public string[] Args { get; }
|
||||
public Context Chat { get; }
|
||||
public User User { get; }
|
||||
public Connection Connection { get; }
|
||||
public Channel Channel { get; }
|
||||
|
||||
public ClientCommandContext(
|
||||
string text,
|
||||
Context chat,
|
||||
User user,
|
||||
Connection connection,
|
||||
Channel channel
|
||||
) {
|
||||
ArgumentNullException.ThrowIfNull(text);
|
||||
|
||||
Chat = chat ?? throw new ArgumentNullException(nameof(chat));
|
||||
User = user ?? throw new ArgumentNullException(nameof(user));
|
||||
Connection = connection ?? throw new ArgumentNullException(nameof(connection));
|
||||
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
|
||||
|
||||
string[] parts = text[1..].Split(' ');
|
||||
Name = parts.First().Replace(".", string.Empty);
|
||||
Args = [.. parts.Skip(1)];
|
||||
}
|
||||
|
||||
public ClientCommandContext(
|
||||
string name,
|
||||
string[] args,
|
||||
Context chat,
|
||||
User user,
|
||||
Connection connection,
|
||||
Channel channel
|
||||
) {
|
||||
Name = name ?? throw new ArgumentNullException(nameof(name));
|
||||
Args = args ?? throw new ArgumentNullException(nameof(args));
|
||||
Chat = chat ?? throw new ArgumentNullException(nameof(chat));
|
||||
User = user ?? throw new ArgumentNullException(nameof(user));
|
||||
Connection = connection ?? throw new ArgumentNullException(nameof(connection));
|
||||
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
|
||||
}
|
||||
|
||||
public bool NameEquals(string name) {
|
||||
return Name.Equals(name, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue