예제 #1
0
 public void DropUser(UserData u)
 {
     foreach (var kp in u.channels) {
         kp.Key.users.Remove(u);
     }
     _users.Remove(u);
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
 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);
 }
예제 #4
0
파일: User.cs 프로젝트: Rafa652/IRCQueueBot
        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);
            }
        }
예제 #5
0
        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;
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        public void Join(ChannelData c, UserData u)
        {
            c.users.Add(u);
            u.AddChannel(c);

            _channels.Add(c);
            _users.Add(u);
        }
예제 #8
0
 public EntityManager(string initNick)
 {
     _channels = new HashSet<ChannelData>();
     _users = new HashSet<UserData>();
     _self = new UserData(this, initNick, true);
 }
예제 #9
0
 public void UnsetUserMode(ChannelData c, UserData u, UserMode um)
 {
     if (u.channels.ContainsKey(c)) {
         u.channels[c] &= ~um;
     }
 }
예제 #10
0
        public void Unjoin(ChannelData c, UserData u)
        {
            c.users.Remove(u);
            u.channels.Remove(c);

            if (u.channels.Count == 0) _users.Remove(u);
        }
예제 #11
0
 private IrcEvent ParseNotice(UserData sender, EntityData target, string[] param, string text)
 {
     return CmdProcPrivmsgNotice(sender, target, text, true);
 }
예제 #12
0
 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;
 }
예제 #13
0
 private IrcEvent ParseInvite(UserData sender, EntityData target, string[] param, string text)
 {
     return new InviteEvent((User)sender, (User)Entities.Self, text);
 }
예제 #14
0
        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;
        }
예제 #15
0
 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;
 }
예제 #16
0
 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;
 }