public void DropUser(UserData u) { foreach (var kp in u.channels) { kp.Key.users.Remove(u); } _users.Remove(u); }
private IrcEvent CmdProcPrivmsgNotice(UserData sender, EntityData target, string text, bool isNotice) { MessageType t = isNotice ? MessageType.Notice : MessageType.Normal; if (text.StartsWith("\u0001") && text.EndsWith("\u0001")) { // CTCP message text = text.Substring(1, text.Length - 2); // cut off control characters if (!isNotice) { // PRIVMSG is CTCP request if (text.StartsWith("ACTION ", StringComparison.InvariantCultureIgnoreCase)) { // Never mind, it's an ACTION (/me) text = text.Substring(7); t = MessageType.Action; // Will fall through to the bottom of the method... } else { if (target is ChannelData) { return new ChannelCtcpEvent((User)sender, (Channel)target, CtcpType.Request, text); } else { return new CtcpEvent((User)sender, (User)target, CtcpType.Request, text); } } } else { // NOTICE is CTCP response return new CtcpEvent((User)sender, (User)target, CtcpType.Response, text); } } if (target is ChannelData) { return new ChannelMessageEvent((User)sender, (Channel)target, t, text); } else { return new UserMessageEvent((User)sender, (User)Entities.Self, t, text); } }
private IrcEvent ParseJoin(UserData sender, EntityData target, string[] param, string text) { if (sender.isclient) { // Client joined new channel - requesting more info immediately WriteOut("MODE " + param[0]); } Entities.Join((ChannelData)target, sender); // Join user and channel before exporting return new JoinEvent((User)sender, (Channel)target); }
internal User(UserData ud) { _nick = ud.nick; _host = ud.host; _isClient = ud.isclient; _isIncomplete = ud.incomplete; _channels = new Dictionary<string, UserMode>(); foreach (KeyValuePair<ChannelData, UserMode> kp in ud.channels) { _channels.Add(kp.Key.name, kp.Value); } }
private IrcEvent ParseKick(UserData sender, EntityData target, string[] param, string text) { var target_u = Entities.GetUser(param[1]); // Export before deleting data var ev = new KickEvent((User)sender, (Channel)target, (User)target_u, text); if (target_u.isclient) Entities.DropChannel((ChannelData)target); else Entities.Unjoin((ChannelData)target, target_u); return ev; }
private IrcEvent ParseMode(UserData sender, EntityData target, string[] param, string text) { if (target is ChannelData) { // Must rebuild mode string from params string mode = ""; for (int i = 1; i < param.Length; i++) { mode += " " + param[i]; } if (mode.Length > 0) ((ChannelData)target).ModeSet(mode.Substring(1)); // Mode has already been applied when exported return new ChannelModeEvent((User)sender, (Channel)target, param[1]); } else { return new ServerModeEvent((User)target, text); } }
public void Join(ChannelData c, UserData u) { c.users.Add(u); u.AddChannel(c); _channels.Add(c); _users.Add(u); }
public EntityManager(string initNick) { _channels = new HashSet<ChannelData>(); _users = new HashSet<UserData>(); _self = new UserData(this, initNick, true); }
public void UnsetUserMode(ChannelData c, UserData u, UserMode um) { if (u.channels.ContainsKey(c)) { u.channels[c] &= ~um; } }
public void Unjoin(ChannelData c, UserData u) { c.users.Remove(u); u.channels.Remove(c); if (u.channels.Count == 0) _users.Remove(u); }
private IrcEvent ParseNotice(UserData sender, EntityData target, string[] param, string text) { return CmdProcPrivmsgNotice(sender, target, text, true); }
private IrcEvent ParseNick(UserData sender, EntityData target, string[] param, string text) { // Export before altering data var ev = new NickChangeEvent((User)sender, text); sender.nick = text; return ev; }
private IrcEvent ParseInvite(UserData sender, EntityData target, string[] param, string text) { return new InviteEvent((User)sender, (User)Entities.Self, text); }
private IrcEvent ParseTopic(UserData sender, EntityData target, string[] param, string text) { // Export before updating data var ev = new TopicEvent((User)sender, (Channel)target, text); var target_c = (ChannelData)target; if (text == "") { target_c.topic = ""; target_c.topic_setter = ""; target_c.topic_settime = null; } else { target_c.topic = text; target_c.topic_setter = sender.nick; target_c.topic_settime = DateTime.Now; } return ev; }
private IrcEvent ParseQuit(UserData sender, EntityData target, string[] param, string text) { // Export before deleting data var ev = new QuitEvent((User)sender, text); Entities.DropUser(sender); return ev; }
private IrcEvent ParsePart(UserData sender, EntityData target, string[] param, string text) { // Export before deleting data var ev = new PartEvent((User)sender, (Channel)target, text); if (sender.isclient) Entities.DropChannel((ChannelData)target); else Entities.Unjoin((ChannelData)target, sender); return ev; }