public ModeChangeEventArgs(Hostmask actor, IRCObject target, string changes) { Actor = actor; Target = target; Changes = changes; }
internal void ParseNonNumeric(string message, string remainder, string action, string actor, string target) { var data = message.Contains(":") ? message.Split(new[] { ':' }, 2)[1] : remainder; switch (action) { case "PRIVMSG": { Events.OnMessage(new Events.MessageEventArgs(new Message(new Hostmask(actor), target, data))); break; } case "MODE": { var senderHostmask = actor.Contains("!") ? new Hostmask(actor) : new Hostmask("", "", actor); IRCObject targetObject = target.StartsWith("#") ? (IRCObject)ChannelCache.ByName(target.Remove(0, 1)) : UserCache.ByNick(target); Events.OnModeChangeEvent(new Events.ModeChangeEventArgs(senderHostmask, targetObject, data)); break; } case "JOIN": { if (actor.Remove(actor.IndexOf("!", StringComparison.Ordinal)) == _nick) { // WE joined a channel Console.WriteLine($"target string is: {data}"); ChannelCache.PutChannel(new Channel(data.Remove(0, 1), "")); } else { // somebody else joined a channel we are in var usr = UserCache.ByHostmask(new Hostmask(actor)); usr = usr ?? new User(new Hostmask(actor)); ChannelCache.ByName(data.Remove(0, 1)).AddUser(usr); } break; } case "PART": { if (actor.Remove(actor.IndexOf("!", StringComparison.Ordinal)) == _nick) { // WE left a channel ChannelCache.RemoveChannelByName(data.Remove(0, 1)); } else { // somebody else left a channel we are in var usr = UserCache.ByHostmask(new Hostmask(actor)); usr = usr ?? new User(new Hostmask(actor)); ChannelCache.ByName(data.Remove(0, 1)).RemoveUser(usr); } break; } case "NOTICE": { Events.OnNotice(new Events.MessageEventArgs(new Message(new Hostmask(actor), target, data))); break; } case "CAP": { switch (remainder.Split(' ')[0]) { case "ACK": // foreach (var str in data.Split(' ')) { _acknowledgedCapabilities.Add(str); } _acknowledgedCapabilities.AddRange(data.Split(' ')); Events.OnCapAckEvent(new Events.StringEventArgs(data)); var capstring_ACK = ""; _acknowledgedCapabilities.ForEach(strin => capstring_ACK += $"{strin} "); Console.WriteLine($"Caps acknowledged: {capstring_ACK}"); break; case "NAK": Events.OnCapNakEvent(new Events.StringEventArgs(data)); break; case "LS": Console.WriteLine("INCOMING CAP LIST!"); _supportedCapabilities.AddRange(data.Split(' ')); if (!(remainder.Length > 2 && remainder.Split(' ')[1] == "*")) { var capstring = ""; _supportedCapabilities.ForEach(strin => capstring += $"{strin} "); Events.OnCapLsEvent(new Events.StringEventArgs(capstring)); Console.WriteLine($"END OF CAP LIST, SUPPORTED CAPS: {capstring}"); } break; } break; } } }