43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
namespace IrcTokens
|
|
{
|
|
/// <summary>
|
|
/// Represents the three parts of a hostmask. Parse with the constructor.
|
|
/// </summary>
|
|
public class Hostmask
|
|
{
|
|
public string NickName { get; set; }
|
|
public string UserName { get; set; }
|
|
public string HostName { get; set; }
|
|
|
|
public override string ToString() => _source;
|
|
|
|
private readonly string _source;
|
|
|
|
public Hostmask(string source)
|
|
{
|
|
if (source == null) return;
|
|
|
|
_source = source;
|
|
|
|
if (source.Contains('@'))
|
|
{
|
|
var split = source.Split('@');
|
|
|
|
NickName = split[0];
|
|
HostName = split[1];
|
|
}
|
|
else
|
|
{
|
|
NickName = source;
|
|
}
|
|
|
|
if (NickName.Contains('!'))
|
|
{
|
|
var userSplit = NickName.Split('!');
|
|
NickName = userSplit[0];
|
|
UserName = userSplit[1];
|
|
}
|
|
}
|
|
}
|
|
}
|