Ejemplo n.º 1
0
        public virtual void AddClient(IClient c)
        {
            if (clients.Contains(c))
            {
                return;
            }

            clients.Add(c);

            if (!ClientModes.ContainsKey(c))
            {
                ClientModes.Add(c, "");
            }

            SendMessage(c, IRCMessage.GetStatic().CreateMessage(c, (ClientModes[c].Contains('o') ? "@" : "") + c.UserString, "JOIN", new string[] { "&" + ChannelName }), true);

            if (!string.IsNullOrEmpty(Topic))
            {
                c.SendMessage(IRCMessage.GetStatic().CreateMessage(c, BaseIRCLib.Server.GetServer().HostString, Reply.RPL_TOPIC, new string[] { c.NickName, "&" + ChannelName, "" + Topic }));
            }

            int currentNick = 0;

            string names = "";

            while (currentNick < clients.Count)
            {
                names += (ClientModes.ContainsKey(clients[currentNick]) && ClientModes[clients[currentNick]].Contains("o") ? "@" : (ClientModes.ContainsKey(clients[currentNick]) && ClientModes[clients[currentNick]].Contains("v") ? "+" : "")) + clients[currentNick].NickName + " ";

                currentNick++;

                if (names.Length > 480)
                {
                    names = names.Substring(0, names.Length - 1);

                    c.SendMessage(IRCMessage.GetStatic().CreateMessage(c, BaseIRCLib.Server.GetServer().HostString, Reply.RPL_NAMREPLY, new string[] { c.NickName, "=", "&" + ChannelName, names }));

                    names = "";
                }
            }

            if (!string.IsNullOrEmpty(names))
            {
                c.SendMessage(IRCMessage.GetStatic().CreateMessage(c, BaseIRCLib.Server.GetServer().HostString, Reply.RPL_NAMREPLY, new string[] { c.NickName, "=", "&" + ChannelName, names }));
            }

            c.SendMessage(IRCMessage.GetStatic().CreateMessage(c, BaseIRCLib.Server.GetServer().HostString, Reply.RPL_ENDOFNAMES, new string[] { c.NickName, "&" + ChannelName, "End of NAMES list" }));
        }
Ejemplo n.º 2
0
        public override void AddClient(IClient c)
        {
            if (c.GetType().Equals(typeof(IRCLib.Interfaces.IRC.IRCClient)))
            {
                if (clients.Contains(c))
                {
                    return;
                }

                bool asdf = Server.clientFriends.JoinChatRoom(chatID);
                if (!asdf)
                {
                    return;
                }

                while (string.IsNullOrEmpty(Server.clientFriends.GetChatRoomName(chatID)))
                {
                    System.Threading.Thread.Sleep(150);
                }

                int numClients = Server.clientFriends.GetFriendCountFromSource(chatID);
                for (int j = 0; j < numClients; j++)
                {
                    ulong asdff = Server.clientFriends.GetFriendFromSourceByIndex(chatID, j);

                    if (asdff == Server.clientUser.GetSteamID())
                    {
                        continue;
                    }

                    IClient cl = (BaseIRCLib.Server.GetServer() as Server).GetSteamClient(asdff);

                    if (cl == null)
                    {
                        if (Server.clientList.Clients.ContainsKey(asdff))
                        {
                            cl = Server.clientList.Clients[asdff];
                        }
                        else
                        {
                            cl = new IRCLib.Interfaces.Steam.SteamClient(asdff);
                        }

                        EPersonaState st = Server.clientFriends.GetFriendPersonaState(asdff);
                        cl.AwayMsg = (st == EPersonaState.k_EPersonaStateOnline ? "" : st.ToString().Remove(0, 15));
                        Database.GetDatabase().AddClient(cl);
                        Database.GetDatabase().GetChannel("&Friends").AddClient(cl);
                    }

                    if (clients.Contains(cl))
                    {
                        continue;
                    }

                    uint memberDetails      = 0;
                    uint localMemberDetails = 0;

                    if (Server.clientFriends.GetChatRoomMemberDetails(chatID, asdff, ref memberDetails, ref localMemberDetails))
                    {
                        if (memberDetails == 2 || memberDetails == 1)
                        {
                            ClientModes.Add(cl, "o");
                        }
                    }

                    base.AddClient(cl);
                }
            }
            else
            {
                uint memberDetails      = 0;
                uint localMemberDetails = 0;

                if (Server.clientFriends.GetChatRoomMemberDetails(chatID, (c as IRCLib.Interfaces.Steam.SteamClient).SteamID, ref memberDetails, ref localMemberDetails))
                {
                    if ((memberDetails == 2 || memberDetails == 1) && !ClientModes.ContainsKey(c))
                    {
                        ClientModes.Add(c, "o");
                    }
                }
            }

            base.AddClient(c);
        }
Ejemplo n.º 3
0
        public override void AddClient(IClient c)
        {
            if (c.GetType().Equals(typeof(IRCLib.Interfaces.IRC.IRCClient)))
            {
                Server.clientFriends.JoinChatRoom(chatID);

                int numClients = Server.clientFriends.GetFriendCountFromSource(chatID);
                for (int j = 0; j < numClients; j++)
                {
                    ulong asdff = Server.clientFriends.GetFriendFromSourceByIndex(chatID, j);

                    if (asdff == Server.clientUser.GetSteamID())
                    {
                        continue;
                    }

                    IClient cl = (BaseIRCLib.Server.GetServer() as Server).GetSteamClient(asdff);

                    if (cl == null)
                    {
                        if (Server.clientList.Clients.ContainsKey(asdff))
                        {
                            cl = Server.clientList.Clients[asdff];
                        }
                        else
                        {
                            cl = new IRCLib.Interfaces.Steam.SteamClient(asdff);
                        }

                        Database.GetDatabase().AddClient(cl);
                        Database.GetDatabase().GetChannel("Friends").AddClient(cl);
                    }

                    if (clients.Contains(cl))
                    {
                        continue;
                    }

                    uint memberDetails      = 0;
                    uint localMemberDetails = 0;

                    if (Server.clientFriends.GetChatRoomMemberDetails(chatID, asdff, ref memberDetails, ref localMemberDetails))
                    {
                        if (memberDetails == 2)
                        {
                            ClientModes.Add(cl, "o");
                        }
                    }

                    base.AddClient(cl);
                }
            }
            else
            {
                uint memberDetails      = 0;
                uint localMemberDetails = 0;

                if (Server.clientFriends.GetChatRoomMemberDetails(chatID, (c as IRCLib.Interfaces.Steam.SteamClient).SteamID, ref memberDetails, ref localMemberDetails))
                {
                    if (memberDetails == 2)
                    {
                        ClientModes.Add(c, "o");
                    }
                }
            }

            base.AddClient(c);
        }