Exemplo n.º 1
0
 private void Quit(Dictionary<string, dynamic> dict)
 {
     Connection con = Connections[(int)dict["cid"]];
     ChatBuffer buf = con.Buffers[(int)dict["bid"]];
     String message = dict["msg"];
     Member m = new Member { Nickname = dict["nick"], Mask = new Usermask { Identprefix = dict["ident_prefix"], User = dict["from_name"], Userhost = dict["from_host"], Mask = dict["hostmask"] } };
     buf.RemoveMember(m, message, dict["eid"]);
 }
Exemplo n.º 2
0
 private void JoinedChannel(Dictionary<string, dynamic> dict)
 {
     Connection con = Connections[(int)dict["cid"]];
     ChatBuffer buf = con.Buffers[(int)dict["bid"]];
     long eid = dict["eid"];
     Member m = new Member { Nickname = dict["nick"], Mask = new Usermask { Identprefix = dict["ident_prefix"], User = dict["from_name"], Userhost = dict["from_host"], Mask = dict["hostmask"] } };
     buf.AddMessage(new Message { ChannelName = buf.Name, Eid = eid, From = m.Nickname, Text = m.Nickname + " has joined the channel..", Format = false });
     buf.AddMember(m);
 }
Exemplo n.º 3
0
        private void ChannelInit(Dictionary<string, dynamic> dict)
        {
            int bid = (int)dict["bid"];
            int cid = (int)dict["cid"];
            Connection currCon = Connections[cid];

            if (!(currCon.Buffers[bid] is ChannelBuffer))
            {
                Console.WriteLine("Buffer not channel");
                return;
            }
            ChannelBuffer buffer = (ChannelBuffer)currCon.Buffers[bid];
            buffer.Name = dict["chan"];
            foreach (var member in dict["members"])
            {
                Member m = new Member { Nickname = member["nick"], Realname = member["realname"], Ircserver = member["ircserver"], Mode = member["mode"], Away = member["away"], Mask = new Usermask { Identprefix = member["ident_prefix"], User = member["user"], Userhost = member["userhost"], Mask = member["usermask"] } };
                buffer.AddMember(m);
            }
            buffer.Mode = dict["mode"];
            Topic topic = new Topic { Text = dict["topic"]["text"], Author = dict["topic"]["nick"], Time = dict["topic"]["time"], Mask = new Usermask { Identprefix = dict["topic"]["ident_prefix"], User = dict["topic"]["user"], Userhost = dict["topic"]["userhost"], Mask = dict["topic"]["usermask"] } };
            buffer.Topic = topic;
            DateTime time = new DateTime(1970, 01, 01, 0, 0, 0, 0);
            buffer.Timestamp = time.AddSeconds(Math.Max(0, dict["timestamp"]));
            buffer.ChannelType = dict["channel_type"];
            buffer.ChannelUrl = dict["url"];
        }
Exemplo n.º 4
0
 internal void RemoveMember(Member m, string message, long eid = -1, bool _event = true)
 {
     Member member = _members.Find(x => x.Nickname == m.Nickname);
     if (member == null)
         return;
     _members.Remove(member);
     _dispatcher.Invoke(new Action(() => Members.Remove(m)));
     if (memberRemoved != null && _event)
         memberRemoved(this, new MemberQuitEventArgs {Member = m, Message = message, Eid = eid});
     SortMembers();
 }
Exemplo n.º 5
0
 internal void KickMember(string kicker, string msg, string kicked, Usermask mask, long eid)
 {
     Member kickerMember = GetMember(kicker);
     Member kickedMember = GetMember(kicked);
     if (kickedMember == null)
         kickerMember = new Member {Nickname = kicker};
     if (kickedMember == null)
         kickedMember = new Member {Nickname = kicker};
     RemoveMember(kickedMember, "", -1, false);
     if (memberKicked != null)
         memberKicked(this,
             new MemberKickedEventArgs {Eid = eid, Kicked = kickedMember, Kicker = kickerMember, Message = msg});
     AddMessage(new Message
     {
         ChannelName = Name,
         Eid = eid,
         From = kicker,
         Text = "has kicked " + kicked + " (" + msg + ")"
     });
 }
Exemplo n.º 6
0
        internal void AddMember(Member m)
        {
            if (_members.Find(x => x.Nickname == m.Nickname) != null)
                return;
            _members.Add(m);
            if (memberAdded != null)
                memberAdded(this, new MemberEventArgs {Member = m});

            _dispatcher.Invoke(() => Members.Add(m));
            SortMembers();
            //  Console.WriteLine(m.nickname+" joined " + name);
        }