From 616abc70303990fbf8096fc6ada5fac100a6c66a Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 19 Apr 2020 20:52:41 -0400 Subject: init --- IrcTokens/Hostmask.cs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 IrcTokens/Hostmask.cs (limited to 'IrcTokens/Hostmask.cs') diff --git a/IrcTokens/Hostmask.cs b/IrcTokens/Hostmask.cs new file mode 100644 index 0000000..05470ef --- /dev/null +++ b/IrcTokens/Hostmask.cs @@ -0,0 +1,42 @@ +namespace IrcTokens +{ + /// + /// Represents the three parts of a hostmask. Parse with the constructor. + /// + 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]; + } + } + } +} -- cgit 1.4.1