Ejemplo n.º 1
0
        /// <summary>
        /// Creates the default privileges comming with a new channel.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <returns>A collection of the default privileges.</returns>
        public static List <Entites.Privileges> Create(Entites.Channel channel)
        {
            List <Entites.Privileges> privileges = new List <Entites.Privileges> {
                GetNewUser(channel), GetNewMod(channel)
            };

            foreach (Entites.Privileges p in privileges)
            {
                Rules.Create(p.Rules);
                p.RulesId = p.Rules.RulesId;
                DAL.Privileges.Create(p);
            }
            return(privileges);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Mod command. Adds a new privileges group.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="core">The core.</param>
        public static void AddPrivileges(Command command, Core core = null)
        {
            if (Tools.IsNotModThenSendWarning(command))
            {
                return;
            }

            string[] args = command.Arguement.Split(new[] { ' ' }, 2);
            if (args.Length == 0)
            {
                Entites.Message.SendMessage(Message.Answer(command.Message,
                                                           "The command is \"/addprivileges name [copiedprivileges]\"."));
                return;
            }
            if (GetPrivileges(command.Message.UserToChannel.Channel, args[0]) != null)
            {
                Entites.Message.SendMessage(Message.Answer(command.Message,
                                                           $"A privileges group named {args[0]} already exists."));
                return;
            }

            Entites.Privileges copying = args.Length == 1
                ? GetDefaultUser(command.Message.UserToChannel.Channel)
                : GetPrivileges(command.Message.UserToChannel.Channel, args[1]);
            if (copying == null)
            {
                Entites.Message.SendMessage(Message.Answer(command.Message,
                                                           $"No privileges group nammed {args[1]} was found."));
                return;
            }

            DAL.Privileges.Create(new Entites.Privileges(args[0], false, command.Message.UserToChannel.Channel,
                                                         Rules.Create(Entites.Rules.Copy(DAL.Privileges.LoadRules(copying).Rules))));
            Entites.Message.SendMessage(Message.Answer(command.Message,
                                                       $"The privileges group named {args[0]} {(args.Length == 2 ? $"inheriting {args[1]} " : "")}was successfully created!"));
        }