Ejemplo n.º 1
0
 public void DestructUser(ChannelUser user)
 {
     for (int i = user.Channels.Count - 1; i >= 0; i--)
     {
         user.Channels[i].Users.Remove(user);
     }
     Users.Remove(user);
 }
Ejemplo n.º 2
0
        public void BuildUserRelations(ChannelUser user)
        {
            Users.Add(user);
            if (!Database.CheckUserExistance(user.Name))
            {
                Database.CreateChannelUser(user.Name);
                return;
            }

            List<string> channels = Database.GetChannelNamesWithUser(user.Name);
            foreach (Channel c in Channels.Where(c => channels.Contains(c.Name)))
            {
                c.Users.Add(user);
                user.Channels.Add(c);
            }
        }
Ejemplo n.º 3
0
        public ErrorCode JoinUserToChannel(Channel channel, ChannelUser user, bool super = false)
        {
            //Bubbles down to JoinUserToChannel(string, string)
            if (!super && channel.HasMode(ChannelModes.PrivateMode) && !user.HasMode(UserModes.Invited))
            {
                return ErrorCode.InsufficientAccess;
            }

            ErrorCode ret = JoinUserToChannel(channel.Name, user.Name);
            if (ret == ErrorCode.Success)
            {
                channel.Users.Add(user);
                user.Channels.Add(channel);
            }
            return ret;
        }
Ejemplo n.º 4
0
 public ErrorCode SetUserModes(ChannelUser user, Channel channel)
 {
     return SetUserModes(user.Name, channel.Name, user.Modes.ToString());
 }
Ejemplo n.º 5
0
 public ErrorCode RemoveUserFromChannel(Channel channel, ChannelUser user)
 {
     //Bubbles down to RemoveUserFromChannel(string, string)
     ErrorCode ret = RemoveUserFromChannel(channel.Name, user.Name);
     if (ret == ErrorCode.Success)
     {
         channel.Users.Remove(user);
         user.Channels.Remove(channel);
     }
     return ret;
 }
Ejemplo n.º 6
0
 public ErrorCode RemoveChannelUser(ChannelUser user)
 {
     ErrorCode ret = RemoveChannelUser(user.Name);
     if (ret == ErrorCode.Success)
     {
         DestructUser(user);
     }
     return ret;
 }
Ejemplo n.º 7
0
        public ErrorCode JoinUserToChannel(Channel channel, TSPlayer player)
        {
            //Bubbles down to JoinUserToChannel(Channel, ChannelUser)
            if (!player.IsLoggedIn)
            {
                return ErrorCode.InsufficientAccess;
            }

            ChannelUser user;

            if (Database.CheckUserExistance(player.User.Name))
            {
                user = GetUser(player.User.Name);
                return JoinUserToChannel(channel, user);
            }

            if (Database.CreateChannelUser(player.User.Name))
            {
                user = new ChannelUser(player.User.Name);
            }
            else
            {
                return ErrorCode.UserCreateFailed;
            }

            return JoinUserToChannel(channel, user);
        }
Ejemplo n.º 8
0
 void PlayerHooks_PlayerPostLogin(PlayerPostLoginEventArgs e)
 {
     ChannelUser cu = new ChannelUser(e.Player.User.Name);
     ChannelManager.BuildUserRelations(cu);
 }