コード例 #1
0
        public ErrorCode CreateChannel(string name, string shortName, string colour, string modes, out Channel c)
        {
            bool ret = Database.CreateChannel(name, shortName, colour, modes);

            if (ret)
            {
                c = new Channel(name, shortName, colour, modes);
                Channels.Add(c);
            }
            else
            {
                c = null;
            }
            return ret ? ErrorCode.Success : ErrorCode.ChannelCreateFailed;
        }
コード例 #2
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;
        }
コード例 #3
0
 public ErrorCode SetUserModes(ChannelUser user, Channel channel)
 {
     return SetUserModes(user.Name, channel.Name, user.Modes.ToString());
 }
コード例 #4
0
 public ErrorCode CreateChannel(string name, string colour, string modes, out Channel c)
 {
     return CreateChannel(name, null, colour, modes, out c);
 }
コード例 #5
0
 public ErrorCode SetChannelModes(Channel channel)
 {
     return SetChannelModes(channel.Name, channel.Modes.ToString());
 }
コード例 #6
0
        public ErrorCode RemoveUserFromChannel(Channel channel, TSPlayer player)
        {
            //Bubbles down to RemoveUserFromChannel(Channel, ChannelUser)
            if (!player.IsLoggedIn)
            {
                return ErrorCode.InsufficientAccess;
            }

            if (!Database.CheckUserExistance(player.User.Name))
            {
                return ErrorCode.UserNotFound;
            }

            ChannelUser user = GetUser(player.User.Name);

            return RemoveUserFromChannel(channel, user);
        }
コード例 #7
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;
 }
コード例 #8
0
 public ErrorCode RemoveChannel(Channel channel)
 {
     ErrorCode ret = RemoveChannel(channel.Name);
     if (ret == ErrorCode.Success)
     {
         Channels.Remove(channel);
         foreach (ChannelUser user in channel.Users)
         {
             user.Channels.Remove(channel);
             if (user.ActiveChannel == channel)
             {
                 user.SetActiveChannel(null);
             }
         }
     }
     return ret;
 }
コード例 #9
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);
        }