Beispiel #1
0
 internal PermissionOverwrite(PermissionTarget targetType, ulong targetId, uint allow, uint deny)
 {
     TargetType = targetType;
     TargetId = targetId;
     Permissions = new DualChannelPermissions(allow, deny);
     Permissions.Lock();
 }
Beispiel #2
0
 internal PermissionOverwrite(PermissionTarget targetType, ulong targetId, uint allow, uint deny)
 {
     TargetType  = targetType;
     TargetId    = targetId;
     Permissions = new DualChannelPermissions(allow, deny);
     Permissions.Lock();
 }
		public Task SetChannelPermissions(Channel channel, Role role, DualChannelPermissions permissions = null)
		{
			if (channel == null) throw new ArgumentNullException(nameof(channel));
			if (role == null) throw new ArgumentNullException(nameof(role));
			CheckReady();

			return SetChannelPermissions(channel, role?.Id, PermissionTarget.Role, permissions?.Allow, permissions?.Deny);
		}
		public Task SetChannelPermissions(Channel channel, User user, DualChannelPermissions permissions = null)
		{
			if (channel == null) throw new ArgumentNullException(nameof(channel));
			if (user == null) throw new ArgumentNullException(nameof(user));
			CheckReady();

			return SetChannelPermissions(channel, user?.Id, PermissionTarget.User, permissions?.Allow, permissions?.Deny);
		}
Beispiel #5
0
        public Task AddPermissionsRule(Role role, DualChannelPermissions permissions = null)
        {
            if (role == null)
            {
                throw new ArgumentNullException(nameof(role));
            }

            return(AddPermissionsRule(role.Id, PermissionTarget.Role, permissions?.Allow, permissions?.Deny));
        }
Beispiel #6
0
        public Task AddPermissionsRule(User user, DualChannelPermissions permissions = null)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            return(AddPermissionsRule(user.Id, PermissionTarget.User, permissions?.Allow, permissions?.Deny));
        }
        public Task SetChannelPermissions(Channel channel, Role role, DualChannelPermissions permissions = null)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }
            if (role == null)
            {
                throw new ArgumentNullException(nameof(role));
            }
            CheckReady();

            return(SetChannelPermissions(channel, role?.Id, PermissionTarget.Role, permissions?.Allow, permissions?.Deny));
        }
        public Task SetChannelPermissions(Channel channel, User user, DualChannelPermissions permissions = null)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            CheckReady();

            return(SetChannelPermissions(channel, user?.Id, PermissionTarget.User, permissions?.Allow, permissions?.Deny));
        }
Beispiel #9
0
        public Task AddPermissionsRule(Role role, DualChannelPermissions permissions = null)
        {
            if (role == null) throw new ArgumentNullException(nameof(role));

            return AddPermissionsRule(role.Id, PermissionTarget.Role, permissions?.Allow, permissions?.Deny);
        }
Beispiel #10
0
        public Task AddPermissionsRule(User user, DualChannelPermissions permissions = null)
        {
            if (user == null) throw new ArgumentNullException(nameof(user));

            return AddPermissionsRule(user.Id, PermissionTarget.User, permissions?.Allow, permissions?.Deny);
        }
Beispiel #11
0
 private static string ResetRole(Server server, User user)
 {
     foreach (Channel c in server.Channels)
     {
         DualChannelPermissions dual = new DualChannelPermissions();
         dual.ReadMessages = null;
         client.SetChannelPermissions(c, user, dual);
     }
     return "Travel reset, please use any of the non-'general' places when you are ready to travel again.";
 }
Beispiel #12
0
        private static string ManageRole(User user, Server server, Channel channel, string rawText)
        {
            bool channelExists = false;
            string travelChannel = rawText.Split(new char[] { ' ' }, 2)[1].ToLower();

            //Make sure this has nothing to do with the general channel
            if (travelChannel == "general")
            {
                return "You can't travel to the general chat.";
            }
            if (channel.Name.ToLower() == "general")
            {
                return "You can't travel from the general chat.";
            }

            foreach (Channel c in server.Channels)
            {
                if (c.Name == travelChannel)
                {
                    channelExists = true;
                }
            }
            if (!channelExists)
            {
                return "That place does not exist. Check your spelling.";
            }
            foreach (Channel c in server.Channels)
            {
                if (c.Name != travelChannel && c.Name.ToLower() != "general")
                {
                    DualChannelPermissions dual = new DualChannelPermissions();
                    dual.ReadMessages = false;
                    client.SetChannelPermissions(c, user, dual);
                }
                else if (c.Name.ToLower() == "general")
                {

                }
                else
                {
                    DualChannelPermissions dual = new DualChannelPermissions();
                    dual.ReadMessages = true;
                    client.SetChannelPermissions(c, user, dual);
                    client.SendMessage(c, user.Name + " has arrived");
                }
            }
            return user.Name + " has left this place.";
        }