2023-02-16 20:34:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace SharpChat {
|
|
|
|
|
public class ChatCommandContext {
|
|
|
|
|
public string Name { get; }
|
|
|
|
|
public string[] Args { get; }
|
|
|
|
|
public ChatContext Chat { get; }
|
|
|
|
|
public ChatUser User { get; }
|
2023-02-16 21:25:41 +00:00
|
|
|
|
public ChatConnection Connection { get; }
|
2023-02-16 20:34:59 +00:00
|
|
|
|
public ChatChannel Channel { get; }
|
|
|
|
|
|
|
|
|
|
public ChatCommandContext(
|
|
|
|
|
string text,
|
|
|
|
|
ChatContext chat,
|
|
|
|
|
ChatUser user,
|
2023-02-16 21:25:41 +00:00
|
|
|
|
ChatConnection connection,
|
2023-02-16 20:34:59 +00:00
|
|
|
|
ChatChannel channel
|
|
|
|
|
) {
|
|
|
|
|
if(text == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(text));
|
|
|
|
|
|
|
|
|
|
Chat = chat ?? throw new ArgumentNullException(nameof(chat));
|
|
|
|
|
User = user ?? throw new ArgumentNullException(nameof(user));
|
2023-02-16 21:25:41 +00:00
|
|
|
|
Connection = connection ?? throw new ArgumentNullException(nameof(connection));
|
2023-02-16 20:34:59 +00:00
|
|
|
|
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
|
|
|
|
|
|
|
|
|
|
string[] parts = text[1..].Split(' ');
|
|
|
|
|
Name = parts.First().Replace(".", string.Empty);
|
|
|
|
|
Args = parts.Skip(1).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ChatCommandContext(
|
|
|
|
|
string name,
|
|
|
|
|
string[] args,
|
|
|
|
|
ChatContext chat,
|
|
|
|
|
ChatUser user,
|
2023-02-16 21:25:41 +00:00
|
|
|
|
ChatConnection connection,
|
2023-02-16 20:34:59 +00:00
|
|
|
|
ChatChannel 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));
|
2023-02-16 21:25:41 +00:00
|
|
|
|
Connection = connection ?? throw new ArgumentNullException(nameof(connection));
|
2023-02-16 20:34:59 +00:00
|
|
|
|
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool NameEquals(string name) {
|
|
|
|
|
return Name.Equals(name, StringComparison.InvariantCultureIgnoreCase);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|